@detail_route(methods=['post'])
    @schedule_transition()
    def resize(self, request, instance, uuid=None):
        if instance.state != models.Instance.States.OFFLINE:
            return Response({'detail': 'Instance must be offline'},
                            status=status.HTTP_409_CONFLICT)

        serializer = serializers.InstanceResizeSerializer(instance, data=request.data)
        serializer.is_valid(raise_exception=True)

        flavor = serializer.validated_data.get('flavor')

        # Serializer makes sure that exactly one of the branches will match
        if flavor is not None:
            instance_cloud = instance.cloud_project_membership.cloud
            if flavor.cloud != instance_cloud:
                return Response({'flavor': "New flavor is not within the same cloud"},
                                status=status.HTTP_400_BAD_REQUEST)

            # System volume size does not get updated since some backends
            # do not support resizing of a root volume
            # instance.system_volume_size = flavor.disk
            instance.ram = flavor.ram
            instance.cores = flavor.cores
            instance.flavor_name = flavor.name
            instance.save(update_fields=['ram', 'cores', 'flavor_name'])

            event_logger.instance_flavor.info(
                'Virtual machine {instance_name} has been scheduled to change flavor.',
                event_type='iaas_instance_flavor_change_scheduled',
                event_context={'instance': instance, 'flavor': flavor}
            )
            return 'flavor change', None, dict(flavor_uuid=flavor.uuid.hex)

        else:
            new_size = serializer.validated_data['disk_size']
            if instance.data_volume_size <= new_size:
                return Response({'disk_size': "Disk size must be strictly greater than the current one"},
                                status=status.HTTP_400_BAD_REQUEST)

            instance.data_volume_size = new_size
            instance.save(update_fields=['data_volume_size'])

            event_logger.instance_volume.info(
                'Virtual machine {instance_name} has been scheduled to extend disk.',
                event_type='iaas_instance_volume_extension_scheduled',
                event_context={'instance': instance, 'volume_size': new_size}
            )
            return 'disk extension', None
dataset/ETHPy150Open opennode/nodeconductor/nodeconductor/iaas/views.py/InstanceViewSet.resize/swapped operands of `<=`