From 14342d629b714f172545f133314b5ce584503cae Mon Sep 17 00:00:00 2001 From: Lorenzo Affetti Date: Tue, 10 Nov 2015 12:56:59 +0100 Subject: [PATCH] FakeDriver: adding and removing instances on live migration. There was no code in FakeDriver that updated the internal dict `self.instances` when a FakeInstance was live migrated. This commit fills this gap. As a result, a couple of versioned notification samples get updated since we are now properly tracking a live migrated instance on the destination host as running vs pending power state. Closes-Bug: 1426433 Change-Id: I9562e1bcbb18c7d543d5a6b36011fa28c13dfa79 --- doc/notification_samples/instance-evacuate.json | 1 - .../instance-live_migration_post_dest-end.json | 1 - nova/virt/fake.py | 13 ++++++++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/doc/notification_samples/instance-evacuate.json b/doc/notification_samples/instance-evacuate.json index c3251182c418..57f603de093f 100644 --- a/doc/notification_samples/instance-evacuate.json +++ b/doc/notification_samples/instance-evacuate.json @@ -5,7 +5,6 @@ "nova_object.data": { "host": "host2", "node": "host2", - "power_state": "pending", "task_state": "rebuilding", "action_initiator_user": "admin" } diff --git a/doc/notification_samples/instance-live_migration_post_dest-end.json b/doc/notification_samples/instance-live_migration_post_dest-end.json index fe3e08bf6eda..e98d2dabd7c2 100644 --- a/doc/notification_samples/instance-live_migration_post_dest-end.json +++ b/doc/notification_samples/instance-live_migration_post_dest-end.json @@ -5,7 +5,6 @@ "nova_object.data":{ "host": "host2", "node": "host2", - "power_state": "pending", "action_initiator_user": "admin" } }, diff --git a/nova/virt/fake.py b/nova/virt/fake.py index 42e1117e66e6..69a97b311e1c 100644 --- a/nova/virt/fake.py +++ b/nova/virt/fake.py @@ -262,7 +262,11 @@ class FakeDriver(driver.ComputeDriver): network_info, block_migration=False, block_device_info=None): - pass + # Called from the destination host after a successful live migration + # so spawn the instance on this host to track it properly. + image_meta = injected_files = admin_password = allocations = None + self.spawn(context, instance, image_meta, injected_files, + admin_password, allocations) def power_off(self, instance, timeout=0, retry_interval=0): if instance.uuid in self.instances: @@ -882,8 +886,11 @@ class FakeLiveMigrateDriver(FakeDriver): def post_live_migration(self, context, instance, block_device_info, migrate_data=None): - if instance.uuid in self.instances: - del self.instances[instance.uuid] + # Runs on the source host, called from + # ComputeManager._post_live_migration so just delete the instance + # from being tracked on the source host. + self.destroy(context, instance, network_info=None, + block_device_info=block_device_info) class FakeLiveMigrateDriverWithNestedCustomResources(