diff options
author | Dan Smith <danms@us.ibm.com> | 2013-02-09 10:32:49 -0500 |
---|---|---|
committer | Dan Smith <danms@us.ibm.com> | 2013-02-12 09:30:44 -0500 |
commit | 91db10a0fd43c30ed088082583b7d43667339ac5 (patch) | |
tree | 6455f99a96a0f94eb401859a81fa835b1ec99438 /nova/tests/conductor | |
parent | e7bc52d3f2ed783864984e021eb9d676a55943c7 (diff) | |
download | nova-91db10a0fd43c30ed088082583b7d43667339ac5.tar.gz nova-91db10a0fd43c30ed088082583b7d43667339ac5.tar.xz nova-91db10a0fd43c30ed088082583b7d43667339ac5.zip |
Make the metadata paths use conductor
This patch makes the metadata service use conductor instead of hitting the
database directly.
It adds a get_ec2_ids() method to conductor, which encapsulates a bunch of
very small id translation database queries. It also does the AZ lookup
via conductor.
Fixes bug 1120402
Change-Id: Iceef753b1451ff53e29dfbf97a696b952b47d5a3
Diffstat (limited to 'nova/tests/conductor')
-rw-r--r-- | nova/tests/conductor/test_conductor.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/nova/tests/conductor/test_conductor.py b/nova/tests/conductor/test_conductor.py index 5c9ce9e5f..41554e79a 100644 --- a/nova/tests/conductor/test_conductor.py +++ b/nova/tests/conductor/test_conductor.py @@ -16,6 +16,7 @@ import mox +from nova.api.ec2 import ec2utils from nova.compute import instance_types from nova.compute import utils as compute_utils from nova.compute import vm_states @@ -241,6 +242,15 @@ class _BaseTestCase(object): aggregate, 'fake') + def test_aggregate_metadata_get_by_host(self): + self.mox.StubOutWithMock(db, 'aggregate_metadata_get_by_host') + db.aggregate_metadata_get_by_host(self.context, 'host', + 'key').AndReturn('result') + self.mox.ReplayAll() + result = self.conductor.aggregate_metadata_get_by_host(self.context, + 'host', 'key') + self.assertEqual(result, 'result') + def test_bw_usage_update(self): self.mox.StubOutWithMock(db, 'bw_usage_update') self.mox.StubOutWithMock(db, 'bw_usage_get') @@ -537,6 +547,39 @@ class _BaseTestCase(object): self.mox.ReplayAll() self.conductor.quota_rollback(self.context, 'reservations') + def test_get_ec2_ids(self): + expected = { + 'instance-id': 'ec2-inst-id', + 'ami-id': 'ec2-ami-id', + 'kernel-id': 'ami-kernel-ec2-kernelid', + 'ramdisk-id': 'ami-ramdisk-ec2-ramdiskid', + } + inst = { + 'uuid': 'fake-uuid', + 'kernel_id': 'ec2-kernelid', + 'ramdisk_id': 'ec2-ramdiskid', + 'image_ref': 'fake-image', + } + self.mox.StubOutWithMock(ec2utils, 'id_to_ec2_inst_id') + self.mox.StubOutWithMock(ec2utils, 'glance_id_to_ec2_id') + self.mox.StubOutWithMock(ec2utils, 'image_type') + + ec2utils.id_to_ec2_inst_id(inst['uuid']).AndReturn( + expected['instance-id']) + ec2utils.glance_id_to_ec2_id(self.context, + inst['image_ref']).AndReturn( + expected['ami-id']) + for image_type in ['kernel', 'ramdisk']: + image_id = inst['%s_id' % image_type] + ec2utils.image_type(image_type).AndReturn('ami-' + image_type) + ec2utils.glance_id_to_ec2_id(self.context, image_id, + 'ami-' + image_type).AndReturn( + 'ami-%s-ec2-%sid' % (image_type, image_type)) + + self.mox.ReplayAll() + result = self.conductor.get_ec2_ids(self.context, inst) + self.assertEqual(result, expected) + class ConductorTestCase(_BaseTestCase, test.TestCase): """Conductor Manager Tests.""" |