From 27c56a19e4af6433beff6ef38d208583a02424be Mon Sep 17 00:00:00 2001 From: suzhengwei Date: Thu, 25 May 2017 11:23:03 +0800 Subject: [PATCH] fix clod_migrate problem 1.TypeError: watcher_non_live_migrate_instance() got an unexpected keyword argument 'dest_hostname' 2.Conflict: Cannot 'stop' instance ****** while it is in vm_state stopped (HTTP 409) Closes-Bug: #1693434 Change-Id: I7293dd5d08e33c2e534d072da8592172bc438c9e --- watcher/common/nova_helper.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/watcher/common/nova_helper.py b/watcher/common/nova_helper.py index a58575b0e..04250a9c2 100644 --- a/watcher/common/nova_helper.py +++ b/watcher/common/nova_helper.py @@ -105,7 +105,7 @@ class NovaHelper(object): % (volume.id, status, timeout)) return volume.status == status - def watcher_non_live_migrate_instance(self, instance_id, node_id, + def watcher_non_live_migrate_instance(self, instance_id, dest_hostname, keep_original_image_name=True): """This method migrates a given instance @@ -268,7 +268,7 @@ class NovaHelper(object): # We create the new instance from # the intermediate image of the original instance new_instance = self. \ - create_instance(node_id, + create_instance(dest_hostname, instance_name, image_uuid, flavor_name, @@ -573,6 +573,9 @@ class NovaHelper(object): if not instance: LOG.debug("Instance not found: %s" % instance_id) return False + elif getattr(instance, 'OS-EXT-STS:vm_state') == "stopped": + LOG.debug("Instance has been stopped: %s" % instance_id) + return True else: self.nova.servers.stop(instance_id)