Fix Image RootDeviceType detection for bdm v2
Change-Id: Ia94a3188ddb1340514aa1fe6695ac8173439a185
This commit is contained in:
parent
1c30d32264
commit
f388b531a3
@ -441,7 +441,8 @@ def _format_image(context, image, os_image, images_dict, ids_dict,
|
|||||||
for bdm in properties.get('block_device_mapping', []):
|
for bdm in properties.get('block_device_mapping', []):
|
||||||
if (('snapshot_id' in bdm or 'volume_id' in bdm) and
|
if (('snapshot_id' in bdm or 'volume_id' in bdm) and
|
||||||
not bdm.get('no_device') and
|
not bdm.get('no_device') and
|
||||||
(root_device_name ==
|
(bdm.get('boot_index') == 0 or
|
||||||
|
root_device_name ==
|
||||||
instance_api._block_device_strip_dev(
|
instance_api._block_device_strip_dev(
|
||||||
bdm.get('device_name')))):
|
bdm.get('device_name')))):
|
||||||
root_device_type = 'ebs'
|
root_device_type = 'ebs'
|
||||||
|
@ -23,8 +23,6 @@ CONF = config.CONF
|
|||||||
|
|
||||||
class ImageTest(base.EC2TestCase):
|
class ImageTest(base.EC2TestCase):
|
||||||
|
|
||||||
@testtools.skipUnless(CONF.aws.run_incompatible_tests,
|
|
||||||
"Openstack doesn't report right RootDeviceType")
|
|
||||||
@testtools.skipUnless(CONF.aws.ebs_image_id, "EBS image id is not defined")
|
@testtools.skipUnless(CONF.aws.ebs_image_id, "EBS image id is not defined")
|
||||||
def test_check_ebs_image_type(self):
|
def test_check_ebs_image_type(self):
|
||||||
image_id = CONF.aws.ebs_image_id
|
image_id = CONF.aws.ebs_image_id
|
||||||
|
@ -435,6 +435,20 @@ class ImagePrivateTestCase(test_base.BaseTestCase):
|
|||||||
self.assertEqual('None (fake_name)', image['imageLocation'])
|
self.assertEqual('None (fake_name)', image['imageLocation'])
|
||||||
self.assertEqual('fake_name', image['name'])
|
self.assertEqual('fake_name', image['name'])
|
||||||
|
|
||||||
|
os_image['properties'] = {
|
||||||
|
'bdm_v2': True,
|
||||||
|
'root_device_name': '/dev/vda',
|
||||||
|
'block_device_mapping': [
|
||||||
|
{'boot_index': 0,
|
||||||
|
'snapshot_id': fakes.ID_OS_SNAPSHOT_2}]}
|
||||||
|
|
||||||
|
image = image_api._format_image(
|
||||||
|
'fake_context', fakes.DB_IMAGE_1, fakes.OSImage(os_image),
|
||||||
|
None, image_ids,
|
||||||
|
snapshot_ids={fakes.ID_OS_SNAPSHOT_2: fakes.ID_EC2_SNAPSHOT_2})
|
||||||
|
|
||||||
|
self.assertEqual('ebs', image['rootDeviceType'])
|
||||||
|
|
||||||
def test_cloud_format_mappings(self):
|
def test_cloud_format_mappings(self):
|
||||||
properties = {
|
properties = {
|
||||||
'mappings': [
|
'mappings': [
|
||||||
|
Loading…
Reference in New Issue
Block a user