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
This commit is contained in:
Lorenzo Affetti 2015-11-10 12:56:59 +01:00 committed by Stephen Finucane
parent bbda16f634
commit 14342d629b
3 changed files with 10 additions and 5 deletions

View File

@ -5,7 +5,6 @@
"nova_object.data": {
"host": "host2",
"node": "host2",
"power_state": "pending",
"task_state": "rebuilding",
"action_initiator_user": "admin"
}

View File

@ -5,7 +5,6 @@
"nova_object.data":{
"host": "host2",
"node": "host2",
"power_state": "pending",
"action_initiator_user": "admin"
}
},

View File

@ -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(