diff options
-rw-r--r-- | nova/compute/manager.py | 14 | ||||
-rw-r--r-- | nova/tests/compute/test_compute.py | 16 |
2 files changed, 17 insertions, 13 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py index f138a3708..819ec25ab 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -1486,9 +1486,9 @@ class ComputeManager(manager.SchedulerDependentManager): self._notify_about_instance_usage(context, instance, "reboot.start") current_power_state = self._get_power_state(context, instance) - self._instance_update(context, instance['uuid'], - power_state=current_power_state, - vm_state=vm_states.ACTIVE) + instance = self._instance_update(context, instance['uuid'], + power_state=current_power_state, + vm_state=vm_states.ACTIVE) if instance['power_state'] != power_state.RUNNING: state = instance['power_state'] @@ -1509,10 +1509,10 @@ class ComputeManager(manager.SchedulerDependentManager): # Fall through and reset task_state to None current_power_state = self._get_power_state(context, instance) - self._instance_update(context, instance['uuid'], - power_state=current_power_state, - vm_state=vm_states.ACTIVE, - task_state=None) + instance = self._instance_update(context, instance['uuid'], + power_state=current_power_state, + vm_state=vm_states.ACTIVE, + task_state=None) self._notify_about_instance_usage(context, instance, "reboot.end") diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py index d44899350..73d58d32a 100644 --- a/nova/tests/compute/test_compute.py +++ b/nova/tests/compute/test_compute.py @@ -1010,6 +1010,10 @@ class ComputeTestCase(BaseTestCase): instance = dict(uuid='fake-instance', power_state='unknown') + updated_instance1 = dict(uuid='updated-instance1', + power_state='fake') + updated_instance2 = dict(uuid='updated-instance2', + power_state='fake') fake_nw_info = 'fake-network-info' fake_nw_model = network_model.NetworkInfo() @@ -1040,7 +1044,7 @@ class ComputeTestCase(BaseTestCase): instance).AndReturn(fake_power_state1) self.compute._instance_update(econtext, instance['uuid'], power_state=fake_power_state1, - vm_state=vm_states.ACTIVE) + vm_state=vm_states.ACTIVE).AndReturn(updated_instance1) # Reboot should check the driver to see if legacy nwinfo is # needed. If it is, the model's legacy() method should be @@ -1058,7 +1062,7 @@ class ComputeTestCase(BaseTestCase): # this is called with the wrong args, so we have to hack # around it. reboot_call_info = {} - expected_call_info = {'args': (instance, expected_nw_info, + expected_call_info = {'args': (updated_instance1, expected_nw_info, reboot_type, fake_block_dev_info), 'kwargs': {}} @@ -1070,13 +1074,13 @@ class ComputeTestCase(BaseTestCase): # Power state should be updated again self.compute._get_power_state(econtext, - instance).AndReturn(fake_power_state2) - self.compute._instance_update(econtext, instance['uuid'], + updated_instance1).AndReturn(fake_power_state2) + self.compute._instance_update(econtext, updated_instance1['uuid'], power_state=fake_power_state2, task_state=None, - vm_state=vm_states.ACTIVE) + vm_state=vm_states.ACTIVE).AndReturn(updated_instance2) self.compute._notify_about_instance_usage(econtext, - instance, + updated_instance2, 'reboot.end') self.mox.ReplayAll() |