Remove unused root_metadata method of BlockDeviceMappingList
root_metadata method is no longer used, since I067f66356a5ebd738add1591a0069d8049f35c24 changed the only place which used it to do not do that. The additional reasons to remove it are: - it shouldn't be used with an instance bmds, because it's preferred to get metadata from instance system metadata (see commit message of I067f66356a5ebd738add1591a0069d8049f35c24); - it doesn't look to work well with an arbitrary bdm list. Related-Bug: #1439819 Change-Id: Id8c46cd5c20cbde2e9bf42a8af65f843895e19ed
This commit is contained in:
@@ -299,26 +299,6 @@ class BlockDeviceMappingList(base.ObjectListBase, base.NovaObject):
|
||||
except StopIteration:
|
||||
return
|
||||
|
||||
def root_metadata(self, context, image_api, volume_api):
|
||||
root_bdm = self.root_bdm()
|
||||
if not root_bdm:
|
||||
return {}
|
||||
|
||||
if root_bdm.is_volume:
|
||||
try:
|
||||
volume = volume_api.get(context, root_bdm.volume_id)
|
||||
return volume.get('volume_image_metadata', {})
|
||||
except Exception:
|
||||
raise exception.InvalidBDMVolume(id=root_bdm.id)
|
||||
elif root_bdm.is_image:
|
||||
try:
|
||||
image_meta = image_api.show(context, root_bdm.image_id)
|
||||
return image_meta.get('properties', {})
|
||||
except Exception:
|
||||
raise exception.InvalidBDMImage(id=root_bdm.id)
|
||||
else:
|
||||
return {}
|
||||
|
||||
|
||||
def block_device_make_list(context, db_list, **extra_args):
|
||||
return base.obj_make_list(context,
|
||||
|
@@ -347,47 +347,6 @@ class _TestBlockDeviceMappingListObject(object):
|
||||
self.context, 'fake_instance_uuid'))
|
||||
self.assertEqual(0, len(bdm_list))
|
||||
|
||||
def test_root_volume_metadata(self):
|
||||
fake_volume = {
|
||||
'volume_image_metadata': {'vol_test_key': 'vol_test_value'}}
|
||||
|
||||
class FakeVolumeApi(object):
|
||||
def get(*args, **kwargs):
|
||||
return fake_volume
|
||||
|
||||
block_device_mapping = block_device_obj.block_device_make_list(None, [
|
||||
fake_block_device.FakeDbBlockDeviceDict(
|
||||
{'id': 1,
|
||||
'boot_index': 0,
|
||||
'source_type': 'volume',
|
||||
'destination_type': 'volume',
|
||||
'volume_id': 'fake_volume_id',
|
||||
'delete_on_termination': False})])
|
||||
|
||||
volume_meta = block_device_mapping.root_metadata(
|
||||
self.context, None, FakeVolumeApi())
|
||||
self.assertEqual(fake_volume['volume_image_metadata'], volume_meta)
|
||||
|
||||
def test_root_image_metadata(self):
|
||||
fake_image = {'properties': {'img_test_key': 'img_test_value'}}
|
||||
|
||||
class FakeImageApi(object):
|
||||
def show(*args, **kwargs):
|
||||
return fake_image
|
||||
|
||||
block_device_mapping = block_device_obj.block_device_make_list(None, [
|
||||
fake_block_device.FakeDbBlockDeviceDict(
|
||||
{'id': 1,
|
||||
'boot_index': 0,
|
||||
'source_type': 'image',
|
||||
'destination_type': 'local',
|
||||
'image_id': "fake-image",
|
||||
'delete_on_termination': True})])
|
||||
|
||||
image_meta = block_device_mapping.root_metadata(
|
||||
self.context, FakeImageApi(), None)
|
||||
self.assertEqual(fake_image['properties'], image_meta)
|
||||
|
||||
|
||||
class TestBlockDeviceMappingListObject(test_objects._LocalTest,
|
||||
_TestBlockDeviceMappingListObject):
|
||||
|
Reference in New Issue
Block a user