本文整理汇总了Python中nova.block_device.mappings_prepend_dev函数的典型用法代码示例。如果您正苦于以下问题:Python mappings_prepend_dev函数的具体用法?Python mappings_prepend_dev怎么用?Python mappings_prepend_dev使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mappings_prepend_dev函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_mapping_prepend_dev
def test_mapping_prepend_dev(self):
mappings = [
{'virtual': 'ami',
'device': 'sda1'},
{'virtual': 'root',
'device': '/dev/sda1'},
{'virtual': 'swap',
'device': 'sdb1'},
{'virtual': 'swap',
'device': '/dev/sdb2'},
{'virtual': 'ephemeral0',
'device': 'sdc1'},
{'virtual': 'ephemeral1',
'device': '/dev/sdc1'}]
expected_result = [
{'virtual': 'ami',
'device': 'sda1'},
{'virtual': 'root',
'device': '/dev/sda1'},
{'virtual': 'swap',
'device': '/dev/sdb1'},
{'virtual': 'swap',
'device': '/dev/sdb2'},
{'virtual': 'ephemeral0',
'device': '/dev/sdc1'},
{'virtual': 'ephemeral1',
'device': '/dev/sdc1'}]
self.assertDictListMatch(block_device.mappings_prepend_dev(mappings),
expected_result)
示例2: _update_image_block_device_mapping
def _update_image_block_device_mapping(self, elevated_context,
instance_type, instance_uuid,
mappings):
"""tell vm driver to create ephemeral/swap device at boot time by
updating BlockDeviceMapping
"""
for bdm in block_device.mappings_prepend_dev(mappings):
LOG.debug(_("bdm %s"), bdm, instance_uuid=instance_uuid)
virtual_name = bdm['virtual']
if virtual_name == 'ami' or virtual_name == 'root':
continue
if not block_device.is_swap_or_ephemeral(virtual_name):
continue
size = self._volume_size(instance_type, virtual_name)
if size == 0:
continue
values = {
'instance_uuid': instance_uuid,
'device_name': bdm['device'],
'virtual_name': virtual_name,
'volume_size': size}
self.db.block_device_mapping_update_or_create(elevated_context,
values)
示例3: test_mapping_prepend_dev
def test_mapping_prepend_dev(self):
mappings = [
{"virtual": "ami", "device": "sda1"},
{"virtual": "root", "device": "/dev/sda1"},
{"virtual": "swap", "device": "sdb1"},
{"virtual": "swap", "device": "/dev/sdb2"},
{"virtual": "ephemeral0", "device": "sdc1"},
{"virtual": "ephemeral1", "device": "/dev/sdc1"},
]
expected_result = [
{"virtual": "ami", "device": "sda1"},
{"virtual": "root", "device": "/dev/sda1"},
{"virtual": "swap", "device": "/dev/sdb1"},
{"virtual": "swap", "device": "/dev/sdb2"},
{"virtual": "ephemeral0", "device": "/dev/sdc1"},
{"virtual": "ephemeral1", "device": "/dev/sdc1"},
]
self.assertDictListMatch(block_device.mappings_prepend_dev(mappings), expected_result)
示例4: test_mappings_prepend_dev
def test_mappings_prepend_dev(self):
mapping = [
{'virtual': 'ami', 'device': '/dev/sda'},
{'virtual': 'root', 'device': 'sda'},
{'virtual': 'ephemeral0', 'device': 'sdb'},
{'virtual': 'swap', 'device': 'sdc'},
{'virtual': 'ephemeral1', 'device': 'sdd'},
{'virtual': 'ephemeral2', 'device': 'sde'}]
expected = [
{'virtual': 'ami', 'device': '/dev/sda'},
{'virtual': 'root', 'device': 'sda'},
{'virtual': 'ephemeral0', 'device': '/dev/sdb'},
{'virtual': 'swap', 'device': '/dev/sdc'},
{'virtual': 'ephemeral1', 'device': '/dev/sdd'},
{'virtual': 'ephemeral2', 'device': '/dev/sde'}]
prepended = block_device.mappings_prepend_dev(mapping)
self.assertEqual(prepended.sort(), expected.sort())
示例5: test_mappings_prepend_dev
def test_mappings_prepend_dev(self):
mapping = [
{"virtual": "ami", "device": "/dev/sda"},
{"virtual": "root", "device": "sda"},
{"virtual": "ephemeral0", "device": "sdb"},
{"virtual": "swap", "device": "sdc"},
{"virtual": "ephemeral1", "device": "sdd"},
{"virtual": "ephemeral2", "device": "sde"},
]
expected = [
{"virtual": "ami", "device": "/dev/sda"},
{"virtual": "root", "device": "sda"},
{"virtual": "ephemeral0", "device": "/dev/sdb"},
{"virtual": "swap", "device": "/dev/sdc"},
{"virtual": "ephemeral1", "device": "/dev/sdd"},
{"virtual": "ephemeral2", "device": "/dev/sde"},
]
prepended = block_device.mappings_prepend_dev(mapping)
self.assertEqual(prepended.sort(), expected.sort())