diff options
Diffstat (limited to 'nova/notifications.py')
-rw-r--r-- | nova/notifications.py | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/nova/notifications.py b/nova/notifications.py index 998abee65..933af1f20 100644 --- a/nova/notifications.py +++ b/nova/notifications.py @@ -109,16 +109,6 @@ def _send_instance_update_notification(context, instance, old_vm_state, bw = bandwidth_usage(instance, audit_start) payload["bandwidth"] = bw - try: - system_metadata = db.instance_system_metadata_get( - context, instance.uuid) - except exception.NotFound: - system_metadata = {} - - # add image metadata - image_meta_props = image_meta(system_metadata) - payload["image_meta"] = image_meta_props - # if the service name (e.g. api/scheduler/compute) is not provided, default # to "compute" if not service: @@ -222,6 +212,19 @@ def usage_from_instance(context, instance_ref, network_info, instance_type_name = instance_ref.get('instance_type', {}).get('name', '') + if system_metadata is None: + try: + if instance_ref.get('deleted'): + with utils.temporary_mutation(context, read_deleted='yes'): + system_metadata = db.instance_system_metadata_get( + context, instance_ref['uuid']) + else: + system_metadata = db.instance_system_metadata_get( + context, instance_ref['uuid']) + + except exception.NotFound: + system_metadata = {} + usage_info = dict( # Owner properties tenant_id=instance_ref['project_id'], @@ -273,5 +276,9 @@ def usage_from_instance(context, instance_ref, network_info, if network_info is not None: usage_info['fixed_ips'] = network_info.fixed_ips() + # add image metadata + image_meta_props = image_meta(system_metadata) + usage_info["image_meta"] = image_meta_props + usage_info.update(kw) return usage_info |