From 4cdc30796c7c76068898cd9e9280e8d7a11a57cb Mon Sep 17 00:00:00 2001 From: Alex Meade Date: Thu, 5 Jul 2012 14:27:33 -0400 Subject: Add checks for retrieving deleted instance metadata for notification events. This enables metadata for a deleted instance to be reported in usage notifications. However, deleted metadata for a nondeleted instance will not be shown. Fixes bug 1021430. Change-Id: I7ce5c720c7705be34724679bb4ff99fb8ba37a27 --- nova/compute/utils.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'nova/compute') diff --git a/nova/compute/utils.py b/nova/compute/utils.py index f0bfe7646..81726105c 100644 --- a/nova/compute/utils.py +++ b/nova/compute/utils.py @@ -23,6 +23,7 @@ from nova.network import model as network_model from nova import notifications from nova.notifier import api as notifier_api from nova.openstack.common import log +from nova import utils FLAGS = flags.FLAGS @@ -55,8 +56,13 @@ def notify_usage_exists(context, instance_ref, current_period=False, if system_metadata is None: try: - system_metadata = db.instance_system_metadata_get( - context, instance_ref.uuid) + 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 = {} -- cgit