summaryrefslogtreecommitdiffstats
path: root/nova/notifications.py
diff options
context:
space:
mode:
authorBrian Elliott <brian.elliott@rackspace.com>2012-05-30 21:14:31 +0000
committerBrian Elliott <brian.elliott@rackspace.com>2012-05-30 21:18:01 +0000
commitabea7d8f797675135b4419ff07491df4ecaed829 (patch)
tree64dd27b41726dfe63cb3d35b3885ada0629730ee /nova/notifications.py
parentb04cd354f9c28403536593169b3fcfd828dba389 (diff)
downloadnova-abea7d8f797675135b4419ff07491df4ecaed829.tar.gz
nova-abea7d8f797675135b4419ff07491df4ecaed829.tar.xz
nova-abea7d8f797675135b4419ff07491df4ecaed829.zip
Fix instance update notification publisher id
Fixes instance update notifications to follow the nova convention for publisher ids. The notification publisher id will now be of the format service.host (e.g. compute.somehostname). Change-Id: Ib5c4c962b9ac3e0bac90703b20465f99dfd047c0
Diffstat (limited to 'nova/notifications.py')
-rw-r--r--nova/notifications.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/nova/notifications.py b/nova/notifications.py
index 4e3d1362d..6b4e1ab8b 100644
--- a/nova/notifications.py
+++ b/nova/notifications.py
@@ -43,18 +43,18 @@ FLAGS = flags.FLAGS
FLAGS.register_opt(notify_state_opt)
-def send_update(context, old_instance, new_instance, host=None):
+def send_update(context, old_instance, new_instance, service=None, host=None):
"""Send compute.instance.update notification to report changes
in vm state and (optionally) task state
"""
send_update_with_states(context, new_instance, old_instance["vm_state"],
new_instance["vm_state"], old_instance["task_state"],
- new_instance["task_state"], host)
+ new_instance["task_state"], service, host)
def send_update_with_states(context, instance, old_vm_state, new_vm_state,
- old_task_state, new_task_state, host=None):
+ old_task_state, new_task_state, service=None, host=None):
"""Send compute.instance.update notification to report changes
in vm state and (optionally) task state
"""
@@ -76,14 +76,15 @@ def send_update_with_states(context, instance, old_vm_state, new_vm_state,
if fire_update:
try:
_send_instance_update_notification(context, instance, old_vm_state,
- old_task_state, new_vm_state, new_task_state, host)
+ old_task_state, new_vm_state, new_task_state, service,
+ host)
except Exception:
LOG.exception(_("Failed to send state update notification"),
instance=instance)
def _send_instance_update_notification(context, instance, old_vm_state,
- old_task_state, new_vm_state, new_task_state, host=None):
+ old_task_state, new_vm_state, new_task_state, service=None, host=None):
"""Send 'compute.instance.exists' notification to inform observers
about instance state changes"""
@@ -117,10 +118,14 @@ def _send_instance_update_notification(context, instance, old_vm_state,
image_meta_props = image_meta(system_metadata)
payload["image_meta"] = image_meta_props
- if not host:
- host = FLAGS.host
+ # if the service name (e.g. api/scheduler/compute) is not provided, default
+ # to "compute"
+ if not service:
+ service = "compute"
- notifier_api.notify(context, host, 'compute.instance.update',
+ publisher_id = notifier_api.publisher_id(service, host)
+
+ notifier_api.notify(context, publisher_id, 'compute.instance.update',
notifier_api.INFO, payload)