diff options
author | Wangpan <hzwangpan@corp.netease.com> | 2013-06-07 09:21:42 +0800 |
---|---|---|
committer | Wangpan <hzwangpan@corp.netease.com> | 2013-06-17 09:03:31 +0800 |
commit | c1211f24aa9895e5bbc9f503e0f13d2d7a65504b (patch) | |
tree | 2217a73239760ea76e66c51fdf94a5aecf917e28 /nova/notifications.py | |
parent | d147af21db2db77f578e527883cf2c68abc56496 (diff) | |
download | nova-c1211f24aa9895e5bbc9f503e0f13d2d7a65504b.tar.gz nova-c1211f24aa9895e5bbc9f503e0f13d2d7a65504b.tar.xz nova-c1211f24aa9895e5bbc9f503e0f13d2d7a65504b.zip |
Add old display name to update notification
Add old display name to payload of update notification when it is
changed, so the notification consumer could know the display name is
changed which is the same as task_state.
Fixes bug 1191612
Change-Id: I47b8ad8ffc2988212b59fb141e83b8110994b8da
Diffstat (limited to 'nova/notifications.py')
-rw-r--r-- | nova/notifications.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/nova/notifications.py b/nova/notifications.py index 13e2a8fca..a90fa855e 100644 --- a/nova/notifications.py +++ b/nova/notifications.py @@ -106,8 +106,12 @@ def send_update(context, old_instance, new_instance, service=None, host=None): else: try: + old_display_name = None + if new_instance["display_name"] != old_instance["display_name"]: + old_display_name = old_instance["display_name"] _send_instance_update_notification(context, new_instance, - service=service, host=host) + service=service, host=host, + old_display_name=old_display_name) except Exception: LOG.exception(_("Failed to send state update notification"), instance=new_instance) @@ -155,7 +159,7 @@ def send_update_with_states(context, instance, old_vm_state, new_vm_state, def _send_instance_update_notification(context, instance, old_vm_state=None, old_task_state=None, new_vm_state=None, new_task_state=None, - service="compute", host=None): + service="compute", host=None, old_display_name=None): """Send 'compute.instance.update' notification to inform observers about instance state changes. """ @@ -185,6 +189,10 @@ def _send_instance_update_notification(context, instance, old_vm_state=None, bw = bandwidth_usage(instance, audit_start) payload["bandwidth"] = bw + # add old display name if it is changed + if old_display_name: + payload["old_display_name"] = old_display_name + publisher_id = notifier_api.publisher_id(service, host) notifier_api.notify(context, publisher_id, 'compute.instance.update', |