Merge "Fix instance update notification publisher id"
This commit is contained in:
@@ -43,18 +43,18 @@ FLAGS = flags.FLAGS
|
|||||||
FLAGS.register_opt(notify_state_opt)
|
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
|
"""Send compute.instance.update notification to report changes
|
||||||
in vm state and (optionally) task state
|
in vm state and (optionally) task state
|
||||||
"""
|
"""
|
||||||
|
|
||||||
send_update_with_states(context, new_instance, old_instance["vm_state"],
|
send_update_with_states(context, new_instance, old_instance["vm_state"],
|
||||||
new_instance["vm_state"], old_instance["task_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,
|
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
|
"""Send compute.instance.update notification to report changes
|
||||||
in vm state and (optionally) task state
|
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:
|
if fire_update:
|
||||||
try:
|
try:
|
||||||
_send_instance_update_notification(context, instance, old_vm_state,
|
_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:
|
except Exception:
|
||||||
LOG.exception(_("Failed to send state update notification"),
|
LOG.exception(_("Failed to send state update notification"),
|
||||||
instance=instance)
|
instance=instance)
|
||||||
|
|
||||||
|
|
||||||
def _send_instance_update_notification(context, instance, old_vm_state,
|
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
|
"""Send 'compute.instance.exists' notification to inform observers
|
||||||
about instance state changes"""
|
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)
|
image_meta_props = image_meta(system_metadata)
|
||||||
payload["image_meta"] = image_meta_props
|
payload["image_meta"] = image_meta_props
|
||||||
|
|
||||||
if not host:
|
# if the service name (e.g. api/scheduler/compute) is not provided, default
|
||||||
host = FLAGS.host
|
# 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)
|
notifier_api.INFO, payload)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -233,7 +233,8 @@ class Scheduler(object):
|
|||||||
# update instance state and notify
|
# update instance state and notify
|
||||||
(old_ref, new_instance_ref) = db.instance_update_and_get_original(
|
(old_ref, new_instance_ref) = db.instance_update_and_get_original(
|
||||||
context, instance_id, values)
|
context, instance_id, values)
|
||||||
notifications.send_update(context, old_ref, new_instance_ref)
|
notifications.send_update(context, old_ref, new_instance_ref,
|
||||||
|
service="scheduler")
|
||||||
|
|
||||||
src = instance_ref['host']
|
src = instance_ref['host']
|
||||||
cast_to_compute_host(context, src, 'live_migration',
|
cast_to_compute_host(context, src, 'live_migration',
|
||||||
|
|||||||
@@ -178,7 +178,8 @@ class SchedulerManager(manager.Manager):
|
|||||||
# update instance state and notify on the transition
|
# update instance state and notify on the transition
|
||||||
(old_ref, new_ref) = db.instance_update_and_get_original(context,
|
(old_ref, new_ref) = db.instance_update_and_get_original(context,
|
||||||
instance_uuid, updates)
|
instance_uuid, updates)
|
||||||
notifications.send_update(context, old_ref, new_ref)
|
notifications.send_update(context, old_ref, new_ref,
|
||||||
|
service="scheduler")
|
||||||
|
|
||||||
payload = dict(request_spec=request_spec,
|
payload = dict(request_spec=request_spec,
|
||||||
instance_properties=properties,
|
instance_properties=properties,
|
||||||
|
|||||||
Reference in New Issue
Block a user