diff options
| author | Brian Elliott <brian.elliott@rackspace.com> | 2012-05-13 21:06:29 +0000 |
|---|---|---|
| committer | Brian Elliott <brian.elliott@rackspace.com> | 2012-05-24 16:53:40 +0000 |
| commit | bc0f2235d9b27e604b9264b5c19adce3cf306bc2 (patch) | |
| tree | f8c9b9aa9b9dbbceca9a4d5f58e52db0f98fd3cc /nova/scheduler | |
| parent | 9c9c4d78530a3a1e50dd5b7496ef54e51c4b48f5 (diff) | |
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
Diffstat (limited to 'nova/scheduler')
| -rw-r--r-- | nova/scheduler/driver.py | 7 | ||||
| -rw-r--r-- | nova/scheduler/manager.py | 7 |
2 files changed, 12 insertions, 2 deletions
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, |
