From bc0f2235d9b27e604b9264b5c19adce3cf306bc2 Mon Sep 17 00:00:00 2001 From: Brian Elliott Date: Sun, 13 May 2012 21:06:29 +0000 Subject: Added a instance state update notification Added a instance update notification (compute.instance.update) that will report on changes to vm_state and task_state. The goal here is to provide useful insight into instance state transitions. (e.g. BUILDING->ACTIVE) The new notification has minimial dependencies and is intended for wide use across the different layers/packages within nova. Calls in compute api/manager, scheduler, and the virt layer that modify the instance state have been instrumented with this notification. Change-Id: I223eb7eccc8aa079b782f6bb17727cd0b71d18ed --- nova/scheduler/driver.py | 7 ++++++- nova/scheduler/manager.py | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'nova/scheduler') diff --git a/nova/scheduler/driver.py b/nova/scheduler/driver.py index 82bba0ce4..8e49e5aa4 100644 --- a/nova/scheduler/driver.py +++ b/nova/scheduler/driver.py @@ -28,6 +28,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.openstack.common import importutils from nova.openstack.common import jsonutils @@ -226,7 +227,11 @@ class Scheduler(object): # Changing instance_state. values = {"vm_state": vm_states.MIGRATING} - db.instance_update(context, instance_id, values) + + # update instance state and notify + (old_ref, new_instance_ref) = db.instance_update_and_get_original( + context, instance_id, values) + notifications.send_update(context, old_ref, new_instance_ref) src = instance_ref['host'] cast_to_compute_host(context, src, 'live_migration', diff --git a/nova/scheduler/manager.py b/nova/scheduler/manager.py index a2cef11a8..470368b03 100644 --- a/nova/scheduler/manager.py +++ b/nova/scheduler/manager.py @@ -29,6 +29,7 @@ from nova import exception from nova import flags from nova import log as logging from nova import manager +from nova import notifications from nova.notifier import api as notifier from nova.openstack.common import cfg from nova.openstack.common import excutils @@ -173,7 +174,11 @@ class SchedulerManager(manager.Manager): state = vm_state.upper() LOG.warning(_('Setting instance to %(state)s state.'), locals(), instance_uuid=instance_uuid) - db.instance_update(context, instance_uuid, updates) + + # update instance state and notify on the transition + (old_ref, new_ref) = db.instance_update_and_get_original(context, + instance_uuid, updates) + notifications.send_update(context, old_ref, new_ref) payload = dict(request_spec=request_spec, instance_properties=properties, -- cgit