From e034a126dade15f05014f6a9eb85562f59714f63 Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Wed, 2 Jan 2013 13:07:04 -0800 Subject: Remove system_metadata db calls from compute manager The compute/manager makes several unnecessary db calls to fetch the instance system_metadata, which is available in the instance object itself now. This patch replaces those uses, avoiding the need to farm them out to conductor. Related to bp/no-db-compute Related to bp/no-db-compute-manager Change-Id: I26ff77be17eb538a4fcd238ffe52f8bde4fbe3e0 --- nova/tests/compute/test_compute_utils.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'nova/tests') diff --git a/nova/tests/compute/test_compute_utils.py b/nova/tests/compute/test_compute_utils.py index b3f7ea3df..5acc1cc53 100644 --- a/nova/tests/compute/test_compute_utils.py +++ b/nova/tests/compute/test_compute_utils.py @@ -260,6 +260,7 @@ class UsageInfoTestCase(test.TestCase): 'other_data': 'meow'} db.instance_system_metadata_update(self.context, instance['uuid'], sys_metadata, False) + instance = db.instance_get(self.context, instance_id) compute_utils.notify_usage_exists(self.context, instance) self.assertEquals(len(test_notifier.NOTIFICATIONS), 1) msg = test_notifier.NOTIFICATIONS[0] @@ -378,3 +379,14 @@ class UsageInfoTestCase(test.TestCase): 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) + + +class MetadataToDictTestCase(test.TestCase): + def test_metadata_to_dict(self): + self.assertEqual(compute_utils.metadata_to_dict( + [{'key': 'foo1', 'value': 'bar'}, + {'key': 'foo2', 'value': 'baz'}]), + {'foo1': 'bar', 'foo2': 'baz'}) + + def test_metadata_to_dict_empty(self): + self.assertEqual(compute_utils.metadata_to_dict([]), {}) -- cgit