From 20656789e919f36733ac9fd0766a56a1c96d1e34 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Thu, 9 Sep 2010 02:35:11 -0700 Subject: set state everywhere --- nova/compute/manager.py | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 878205a36..5f7a94106 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -59,7 +59,7 @@ class ComputeManager(manager.Manager): # FIXME(ja): include other fields from state? instance_ref = self.db.instance_get(context, instance_id) state = self.driver.get_info(instance_ref.name)['state'] - self.db.instance_state(context, instance_id, state) + self.db.instance_set_state(context, instance_id, state) @defer.inlineCallbacks @exception.wrap_exception @@ -76,17 +76,19 @@ class ComputeManager(manager.Manager): {'host': self.host}) # TODO(vish) check to make sure the availability zone matches - self.db.instance_state(context, - instance_id, - power_state.NOSTATE, - 'spawning') + self.db.instance_set_state(context, + instance_id, + power_state.NOSTATE, + 'spawning') try: yield self.driver.spawn(instance_ref) except Exception: # pylint: disable-msg=W0702 logging.exception("instance %s: Failed to spawn", instance_ref['name']) - self.db.instance_state(context, instance_id, power_state.SHUTDOWN) + self.db.instance_set_state(context, + instance_id, + power_state.SHUTDOWN) self._update_state(context, instance_id) @@ -102,10 +104,10 @@ class ComputeManager(manager.Manager): raise exception.Error('trying to destroy already destroyed' ' instance: %s' % instance_id) - self.db.instance_state(context, - instance_id, - power_state.NOSTATE, - 'shutting_down') + self.db.instance_set_state(context, + instance_id, + power_state.NOSTATE, + 'shutting_down') yield self.driver.destroy(instance_ref) # TODO(ja): should we keep it in a terminated state for a bit? @@ -127,10 +129,10 @@ class ComputeManager(manager.Manager): power_state.RUNNING)) logging.debug('instance %s: rebooting', instance_ref['name']) - self.db.instance_state(context, - instance_id, - power_state.NOSTATE, - 'rebooting') + self.db.instance_set_state(context, + instance_id, + power_state.NOSTATE, + 'rebooting') yield self.driver.reboot(instance_ref) self._update_state(context, instance_id) -- cgit