From 7f7ef760302522bd36ce691fb2fa404130a0e15e Mon Sep 17 00:00:00 2001 From: "Lucas H. Xu" Date: Thu, 9 Mar 2017 17:25:47 -0500 Subject: [PATCH 1/3] add new instance action: resize --- service/instance.py | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/service/instance.py b/service/instance.py index b5dfb298..556d4fbd 100644 --- a/service/instance.py +++ b/service/instance.py @@ -367,21 +367,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 +1850,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( From 015140e9250b1b3ba8ea15e2581b18916f3e4329 Mon Sep 17 00:00:00 2001 From: "Lucas H. Xu" Date: Mon, 13 Mar 2017 16:52:11 -0400 Subject: [PATCH 2/3] update on the backend --- api/v1/serializers/instance_serializer.py | 9 +++++++++ service/instance.py | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) 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 556d4fbd..4c9dd78e 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, From 3d21f6895c648a7c107172c6e2a797e0adc01c07 Mon Sep 17 00:00:00 2001 From: "Lucas H. Xu" Date: Wed, 15 Mar 2017 16:42:46 -0400 Subject: [PATCH 3/3] delete unused imported lib --- service/instance.py | 1 - 1 file changed, 1 deletion(-) diff --git a/service/instance.py b/service/instance.py index 4c9dd78e..47dc3830 100644 --- a/service/instance.py +++ b/service/instance.py @@ -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()