diff --git a/api/v1/serializers/instance_serializer.py b/api/v1/serializers/instance_serializer.py index 0f419d1b..5cf3f809 100644 --- a/api/v1/serializers/instance_serializer.py +++ b/api/v1/serializers/instance_serializer.py @@ -23,6 +23,7 @@ class InstanceSerializer(serializers.ModelSerializer): activity = serializers.CharField(read_only=True, source='esh_activity') fault = serializers.ReadOnlyField(source='esh_fault') size_alias = serializers.CharField(read_only=True, source='esh_size') + size = serializers.SerializerMethodField() machine_alias = serializers.CharField(read_only=True, source='esh_source') machine_name = serializers.CharField(read_only=True, source='esh_source_name') @@ -51,6 +52,14 @@ def __init__(self, *args, **kwargs): self.request_user = user super(InstanceSerializer, self).__init__(*args, **kwargs) + def get_size(self, obj): + from api.v2.serializers.summaries import ( + SizeSummarySerializer + ) + size = obj.get_size() + serializer = SizeSummarySerializer(size, context=self.context) + return serializer.data + class Meta: model = Instance exclude = ('source', 'provider_alias', diff --git a/service/instance.py b/service/instance.py index b5dfb298..47dc3830 100644 --- a/service/instance.py +++ b/service/instance.py @@ -109,12 +109,12 @@ def resize_instance(esh_driver, esh_instance, size_alias, provider_uuid, identity_uuid, user): _permission_to_act(identity_uuid, "Resize") size = esh_driver.get_size(size_alias) - redeploy_task = resize_and_redeploy( + finish_resize_task = resize_and_redeploy( esh_driver, esh_instance, identity_uuid) esh_driver.resize_instance(esh_instance, size) - redeploy_task.apply_async() + finish_resize_task.apply_async() # Write build state for new size update_status( esh_driver, @@ -358,7 +358,6 @@ def resize_and_redeploy(esh_driver, esh_instance, core_identity_uuid): Use this function to kick off the async task when you ONLY want to deploy (No add fixed, No add floating) """ - from service.tasks.driver import deploy_init_to from service.tasks.driver import wait_for_instance, complete_resize from service.deploy import deploy_test touch_script = deploy_test() @@ -367,21 +366,11 @@ def resize_and_redeploy(esh_driver, esh_instance, core_identity_uuid): task_one = wait_for_instance.s( esh_instance.id, esh_driver.__class__, esh_driver.provider, esh_driver.identity, "verify_resize") - raise Exception("Programmer -- Fix this method based on the TODO") - # task_two = deploy_script.si( - # esh_driver.__class__, esh_driver.provider, - # esh_driver.identity, esh_instance.id, touch_script) - task_three = complete_resize.si( + task_two = complete_resize.si( esh_driver.__class__, esh_driver.provider, esh_driver.identity, esh_instance.id, - core_identity.provider.id, core_identity.id, core_identity.created_by) - task_four = deploy_init_to.si( - esh_driver.__class__, esh_driver.provider, - esh_driver.identity, esh_instance.id, core_identity, redeploy=True) - # Link em all together! + core_identity.provider.uuid, core_identity.uuid, core_identity.created_by) task_one.link(task_two) - task_two.link(task_three) - task_three.link(task_four) return task_one @@ -1860,7 +1849,7 @@ def run_instance_action(user, identity, instance_id, action_type, action_params) identity_uuid = identity.uuid logger.info("User %s has initiated instance action %s to be executed on Instance %s" % (user, action_type, instance_id)) if 'resize' == action_type: - size_alias = action_params.get('size', '') + size_alias = action_params.get('resize_size', '') if isinstance(size_alias, int): size_alias = str(size_alias) result_obj = resize_instance(