From e105c53e67febefc0ae7e78baf53020d2b29c298 Mon Sep 17 00:00:00 2001 From: Josh Kearney Date: Mon, 14 Nov 2011 15:30:14 -0600 Subject: Log the URL to an image_ref and not just the ID. Change-Id: Iaae6b969d9ef3cd0f50dd3297d4b0bb51f61f5c9 --- nova/tests/test_compute.py | 9 ++++++--- nova/tests/test_compute_utils.py | 3 ++- nova/utils.py | 5 ++++- 3 files changed, 12 insertions(+), 5 deletions(-) (limited to 'nova') diff --git a/nova/tests/test_compute.py b/nova/tests/test_compute.py index f95d6cad3..b641e8e71 100644 --- a/nova/tests/test_compute.py +++ b/nova/tests/test_compute.py @@ -426,7 +426,8 @@ class ComputeTestCase(BaseTestCase): self.assertTrue('created_at' in payload) self.assertTrue('launched_at' in payload) self.assertTrue(payload['launched_at']) - self.assertEquals(payload['image_ref'], '1') + image_ref_url = "%s/images/1" % utils.generate_glance_url() + self.assertEquals(payload['image_ref_url'], image_ref_url) self.compute.terminate_instance(self.context, instance_id) def test_terminate_usage_notification(self): @@ -455,7 +456,8 @@ class ComputeTestCase(BaseTestCase): self.assertTrue('display_name' in payload) self.assertTrue('created_at' in payload) self.assertTrue('launched_at' in payload) - self.assertEquals(payload['image_ref'], '1') + image_ref_url = "%s/images/1" % utils.generate_glance_url() + self.assertEquals(payload['image_ref_url'], image_ref_url) def test_run_instance_existing(self): """Ensure failure when running an instance that already exists""" @@ -582,7 +584,8 @@ class ComputeTestCase(BaseTestCase): self.assertTrue('display_name' in payload) self.assertTrue('created_at' in payload) self.assertTrue('launched_at' in payload) - self.assertEquals(payload['image_ref'], '1') + image_ref_url = "%s/images/1" % utils.generate_glance_url() + self.assertEquals(payload['image_ref_url'], image_ref_url) self.compute.terminate_instance(context, instance_id) def test_resize_instance(self): diff --git a/nova/tests/test_compute_utils.py b/nova/tests/test_compute_utils.py index 12b98aa0b..a9c149108 100644 --- a/nova/tests/test_compute_utils.py +++ b/nova/tests/test_compute_utils.py @@ -91,5 +91,6 @@ class UsageInfoTestCase(test.TestCase): 'audit_period_ending'): self.assertTrue(attr in payload, msg="Key %s not in payload" % attr) - self.assertEquals(payload['image_ref'], '1') + image_ref_url = "%s/images/1" % utils.generate_glance_url() + self.assertEquals(payload['image_ref_url'], image_ref_url) self.compute.terminate_instance(self.context, instance_id) diff --git a/nova/utils.py b/nova/utils.py index ad0d5725d..7723837c9 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -337,6 +337,9 @@ def current_audit_period(unit=None): def usage_from_instance(instance_ref, **kw): + image_ref_url = "%s/images/%s" % (generate_glance_url(), + instance_ref['image_ref']) + usage_info = dict( tenant_id=instance_ref['project_id'], user_id=instance_ref['user_id'], @@ -347,7 +350,7 @@ def usage_from_instance(instance_ref, **kw): created_at=str(instance_ref['created_at']), launched_at=str(instance_ref['launched_at']) \ if instance_ref['launched_at'] else '', - image_ref=instance_ref['image_ref'], + image_ref_url=image_ref_url, state=instance_ref['vm_state'], state_description=instance_ref['task_state'] \ if instance_ref['task_state'] else '', -- cgit