diff options
Diffstat (limited to 'nova/virt')
| -rw-r--r-- | nova/virt/baremetal/proxy.py | 22 | ||||
| -rw-r--r-- | nova/virt/xenapi/host.py | 30 |
2 files changed, 38 insertions, 14 deletions
diff --git a/nova/virt/baremetal/proxy.py b/nova/virt/baremetal/proxy.py index 90011f28b..ba8296127 100644 --- a/nova/virt/baremetal/proxy.py +++ b/nova/virt/baremetal/proxy.py @@ -42,6 +42,7 @@ from nova import db from nova import exception from nova import flags from nova import log as logging +from nova import notifications from nova.openstack.common import cfg from nova import utils from nova.virt.baremetal import dom @@ -253,14 +254,20 @@ class ProxyConnection(driver.ComputeDriver): try: LOG.debug(_("Key is injected but instance is not running yet"), instance=instance) - db.instance_update(context, instance['id'], - {'vm_state': vm_states.BUILDING}) + (old_ref, new_ref) = db.instance_update_and_get_original( + context, instance['id'], + {'vm_state': vm_states.BUILDING}) + notifications.send_update(context, old_ref, new_ref) + state = self._conn.create_domain(xml_dict, bpath) if state == power_state.RUNNING: LOG.debug(_('instance %s: booted'), instance['name'], instance=instance) - db.instance_update(context, instance['id'], + (old_ref, new_ref) = db.instance_update_and_get_original( + context, instance['id'], {'vm_state': vm_states.ACTIVE}) + notifications.send_update(context, old_ref, new_ref) + LOG.debug(_('~~~~~~ current state = %s ~~~~~~'), state, instance=instance) LOG.debug(_("instance %s spawned successfully"), @@ -271,9 +278,12 @@ class ProxyConnection(driver.ComputeDriver): except Exception as Exn: LOG.debug(_("Bremetal assignment is overcommitted."), instance=instance) - db.instance_update(context, instance['id'], - {'vm_state': vm_states.OVERCOMMIT, - 'power_state': power_state.SUSPENDED}) + (old_ref, new_ref) = db.instance_update_and_get_original( + context, instance['id'], + {'vm_state': vm_states.OVERCOMMIT, + 'power_state': power_state.SUSPENDED}) + notifications.send_update(context, old_ref, new_ref) + timer.stop() timer.f = _wait_for_boot diff --git a/nova/virt/xenapi/host.py b/nova/virt/xenapi/host.py index cceca0da0..d5f568360 100644 --- a/nova/virt/xenapi/host.py +++ b/nova/virt/xenapi/host.py @@ -26,6 +26,7 @@ from nova.compute import vm_states from nova import context from nova import db from nova import exception +from nova import notifications from nova.virt.xenapi import vm_utils LOG = logging.getLogger(__name__) @@ -74,21 +75,34 @@ class Host(object): vm_counter = vm_counter + 1 dest = _host_find(ctxt, self._session, host, host_ref) - db.instance_update(ctxt, instance.id, - {'host': dest, - 'vm_state': vm_states.MIGRATING}) + (old_ref, new_ref) = \ + db.instance_update_and_get_original(ctxt, + instance.id, + {'host': dest, + 'vm_state': vm_states.MIGRATING}) + notifications.send_update(ctxt, old_ref, new_ref) + self._session.call_xenapi('VM.pool_migrate', vm_ref, host_ref, {}) migrations_counter = migrations_counter + 1 - db.instance_update(ctxt, instance.id, - {'vm_state': vm_states.ACTIVE}) + + (old_ref, new_ref) = \ + db.instance_update_and_get_original(ctxt, + instance.id, + {'vm_state': vm_states.ACTIVE}) + notifications.send_update(ctxt, old_ref, new_ref) + break except self.XenAPI.Failure: LOG.exception('Unable to migrate VM %(vm_ref)s' 'from %(host)s' % locals()) - db.instance_update(ctxt, instance.id, - {'host': host, - 'vm_state': vm_states.ACTIVE}) + (old_ref, new_ref) = \ + db.instance_update_and_get_original(ctxt, + instance.id, + {'hosts': host, + 'vm_state': vm_states.ACTIVE}) + notifications.send_update(ctxt, old_ref, new_ref) + if vm_counter == migrations_counter: return 'on_maintenance' else: |
