diff --git a/watcher/common/nova_helper.py b/watcher/common/nova_helper.py index c8aee3066..792e150fb 100644 --- a/watcher/common/nova_helper.py +++ b/watcher/common/nova_helper.py @@ -73,15 +73,7 @@ class NovaHelper(object): return self.nova.availability_zones.list(detailed=True) def find_instance(self, instance_id): - search_opts = {'all_tenants': True} - instances = self.nova.servers.list(detailed=True, - search_opts=search_opts) - instance = None - for _instance in instances: - if _instance.id == instance_id: - instance = _instance - break - return instance + return self.nova.servers.get(instance_id) def wait_for_volume_status(self, volume, status, timeout=60, poll_interval=1): diff --git a/watcher/tests/common/test_nova_helper.py b/watcher/tests/common/test_nova_helper.py index 38bda9837..b7ad8d8ea 100644 --- a/watcher/tests/common/test_nova_helper.py +++ b/watcher/tests/common/test_nova_helper.py @@ -49,7 +49,7 @@ class TestNovaHelper(base.TestCase): @staticmethod def fake_nova_find_list(nova_util, find=None, list=None): - nova_util.nova.servers.find.return_value = find + nova_util.nova.servers.get.return_value = find if list is None: nova_util.nova.servers.list.return_value = [] else: @@ -102,6 +102,8 @@ class TestNovaHelper(base.TestCase): ) self.assertTrue(is_success) + setattr(server, 'OS-EXT-SRV-ATTR:host', + self.source_node) self.fake_nova_find_list(nova_util, find=server, list=None) is_success = nova_util.live_migrate_instance( self.instance_uuid, self.destination_node