• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python block_device.get_root_bdm函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中nova.block_device.get_root_bdm函数的典型用法代码示例。如果您正苦于以下问题:Python get_root_bdm函数的具体用法?Python get_root_bdm怎么用?Python get_root_bdm使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_root_bdm函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_get_root_bdm

 def test_get_root_bdm(self):
     root_bdm = {'device_name': 'vda', 'boot_index': 0}
     bdms = [root_bdm,
             {'device_name': 'vdb', 'boot_index': 1},
             {'device_name': 'vdc', 'boot_index': -1},
             {'device_name': 'vdd'}]
     self.assertEqual(root_bdm, block_device.get_root_bdm(bdms))
     self.assertEqual(root_bdm, block_device.get_root_bdm([bdms[0]]))
     self.assertIsNone(block_device.get_root_bdm(bdms[1:]))
     self.assertIsNone(block_device.get_root_bdm(bdms[2:]))
     self.assertIsNone(block_device.get_root_bdm(bdms[3:]))
     self.assertIsNone(block_device.get_root_bdm([]))
开发者ID:aaaaatoz,项目名称:nova,代码行数:12,代码来源:test_block_device.py


示例2: test_get_root_bdm

 def test_get_root_bdm(self):
     root_bdm = {"device_name": "vda", "boot_index": 0}
     bdms = [
         root_bdm,
         {"device_name": "vdb", "boot_index": 1},
         {"device_name": "vdc", "boot_index": -1},
         {"device_name": "vdd"},
     ]
     self.assertEqual(root_bdm, block_device.get_root_bdm(bdms))
     self.assertEqual(root_bdm, block_device.get_root_bdm([bdms[0]]))
     self.assertIsNone(block_device.get_root_bdm(bdms[1:]))
     self.assertIsNone(block_device.get_root_bdm(bdms[2:]))
     self.assertIsNone(block_device.get_root_bdm(bdms[3:]))
     self.assertIsNone(block_device.get_root_bdm([]))
开发者ID:rrader,项目名称:nova,代码行数:14,代码来源:test_block_device.py


示例3: get_disk_mapping

def get_disk_mapping(virt_type, instance,
                     disk_bus, cdrom_bus,
                     block_device_info=None,
                     image_meta=None, rescue=False):
    """Determine how to map default disks to the virtual machine.

       This is about figuring out whether the default 'disk',
       'disk.local', 'disk.swap' and 'disk.config' images have
       been overridden by the block device mapping.

       Returns the guest disk mapping for the devices.
    """

    inst_type = flavors.extract_flavor(instance)

    mapping = {}

    pre_assigned_device_names = \
    [block_device.strip_dev(get_device_name(bdm)) for bdm in itertools.chain(
        driver.block_device_info_get_ephemerals(block_device_info),
        [driver.block_device_info_get_swap(block_device_info)],
        driver.block_device_info_get_mapping(block_device_info))
     if get_device_name(bdm)]

    if rescue:
        rescue_info = get_next_disk_info(mapping,
                                         disk_bus, boot_index=1)
        mapping['disk.rescue'] = rescue_info
        mapping['root'] = rescue_info

        os_info = get_next_disk_info(mapping,
                                     disk_bus)
        mapping['disk'] = os_info

        return mapping

    # NOTE (ndipanov): root_bdm can be None when we boot from image
    # as there is no driver represenation of local targeted images
    # and they will not be in block_device_info list.
    root_bdm = block_device.get_root_bdm(
        driver.block_device_info_get_mapping(block_device_info))

    root_device_name = block_device.strip_dev(
        driver.block_device_info_get_root(block_device_info))
    root_info = get_root_info(virt_type, image_meta, root_bdm,
                              disk_bus, cdrom_bus, root_device_name)

    mapping['root'] = root_info
    # NOTE (ndipanov): This implicitly relies on image->local BDMs not
    #                  being considered in the driver layer - so missing
    #                  bdm with boot_index 0 means - use image, unless it was
    #                  overridden. This can happen when using legacy syntax and
    #                  no root_device_name is set on the instance.
    if not root_bdm and not block_device.volume_in_mapping(root_info['dev'],
                                                           block_device_info):
        mapping['disk'] = root_info

    default_eph = has_default_ephemeral(instance, disk_bus, block_device_info,
                                        mapping)
    if default_eph:
        mapping['disk.local'] = default_eph

    for idx, eph in enumerate(driver.block_device_info_get_ephemerals(
            block_device_info)):
        eph_info = get_info_from_bdm(
            virt_type, eph, mapping, disk_bus,
            assigned_devices=pre_assigned_device_names)
        mapping[get_eph_disk(idx)] = eph_info
        update_bdm(eph, eph_info)

    swap = driver.block_device_info_get_swap(block_device_info)
    if swap and swap.get('swap_size', 0) > 0:
        swap_info = get_info_from_bdm(virt_type, swap, mapping, disk_bus)
        mapping['disk.swap'] = swap_info
        update_bdm(swap, swap_info)
    elif inst_type['swap'] > 0:
        swap_info = get_next_disk_info(mapping,
                                       disk_bus)
        if not block_device.volume_in_mapping(swap_info['dev'],
                                              block_device_info):
            mapping['disk.swap'] = swap_info

    block_device_mapping = driver.block_device_info_get_mapping(
        block_device_info)

    for vol in block_device_mapping:
        vol_info = get_info_from_bdm(
            virt_type, vol, mapping,
            assigned_devices=pre_assigned_device_names)
        mapping[block_device.prepend_dev(vol_info['dev'])] = vol_info
        update_bdm(vol, vol_info)

    if configdrive.required_by(instance):
        device_type = get_config_drive_type()
        disk_bus = get_disk_bus_for_device_type(virt_type,
                                                image_meta,
                                                device_type)
        config_info = get_next_disk_info(mapping,
                                         disk_bus,
                                         device_type,
#.........这里部分代码省略.........
开发者ID:AsherBond,项目名称:nova,代码行数:101,代码来源:blockinfo.py



注:本文中的nova.block_device.get_root_bdm函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python block_device.instance_block_mapping函数代码示例发布时间:2022-05-27
下一篇:
Python block_device.get_device_letter函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap