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

Python block_device.volume_in_mapping函数代码示例

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

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



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

示例1: test_spawn_attach_volume_vmdk

 def test_spawn_attach_volume_vmdk(self):
     self._create_instance_in_the_db()
     self.type_data = db.flavor_get_by_name(None, 'm1.large')
     self.mox.StubOutWithMock(block_device, 'volume_in_mapping')
     self.mox.StubOutWithMock(v_driver, 'block_device_info_get_mapping')
     ebs_root = 'fake_root'
     block_device.volume_in_mapping(mox.IgnoreArg(),
             mox.IgnoreArg()).AndReturn(ebs_root)
     connection_info = self._test_vmdk_connection_info('vmdk')
     root_disk = [{'connection_info': connection_info}]
     v_driver.block_device_info_get_mapping(
             mox.IgnoreArg()).AndReturn(root_disk)
     mount_point = '/dev/vdc'
     self.mox.StubOutWithMock(volumeops.VMwareVolumeOps,
                              '_get_res_pool_of_vm')
     volumeops.VMwareVolumeOps._get_res_pool_of_vm(
              mox.IgnoreArg()).AndReturn('fake_res_pool')
     self.mox.StubOutWithMock(volumeops.VMwareVolumeOps,
                              '_relocate_vmdk_volume')
     volumeops.VMwareVolumeOps._relocate_vmdk_volume(mox.IgnoreArg(),
              'fake_res_pool', mox.IgnoreArg())
     self.mox.StubOutWithMock(volumeops.VMwareVolumeOps,
                              'attach_volume')
     volumeops.VMwareVolumeOps.attach_volume(connection_info,
             self.instance, mox.IgnoreArg())
     self.mox.ReplayAll()
     self.conn.spawn(self.context, self.instance, self.image,
                     injected_files=[], admin_password=None,
                     network_info=self.network_info,
                     block_device_info=None)
开发者ID:qingw,项目名称:nova,代码行数:30,代码来源:test_vmwareapi.py


示例2: test_spawn_attach_volume_vmdk

 def test_spawn_attach_volume_vmdk(self):
     self._create_instance_in_the_db()
     self.type_data = db.flavor_get_by_name(None, "m1.large")
     self.mox.StubOutWithMock(block_device, "volume_in_mapping")
     self.mox.StubOutWithMock(v_driver, "block_device_info_get_mapping")
     ebs_root = "fake_root"
     block_device.volume_in_mapping(mox.IgnoreArg(), mox.IgnoreArg()).AndReturn(ebs_root)
     connection_info = self._test_vmdk_connection_info("vmdk")
     root_disk = [{"connection_info": connection_info}]
     v_driver.block_device_info_get_mapping(mox.IgnoreArg()).AndReturn(root_disk)
     mount_point = "/dev/vdc"
     self.mox.StubOutWithMock(volumeops.VMwareVolumeOps, "_get_volume_uuid")
     volumeops.VMwareVolumeOps._get_volume_uuid(mox.IgnoreArg(), "volume-fake-id").AndReturn("fake_disk_uuid")
     self.mox.StubOutWithMock(vm_util, "get_vmdk_backed_disk_device")
     vm_util.get_vmdk_backed_disk_device(mox.IgnoreArg(), "fake_disk_uuid").AndReturn("fake_device")
     self.mox.StubOutWithMock(volumeops.VMwareVolumeOps, "_consolidate_vmdk_volume")
     volumeops.VMwareVolumeOps._consolidate_vmdk_volume(
         self.instance, mox.IgnoreArg(), "fake_device", mox.IgnoreArg()
     )
     self.mox.StubOutWithMock(volumeops.VMwareVolumeOps, "attach_volume")
     volumeops.VMwareVolumeOps.attach_volume(connection_info, self.instance, mox.IgnoreArg())
     self.mox.ReplayAll()
     self.conn.spawn(
         self.context,
         self.instance,
         self.image,
         injected_files=[],
         admin_password=None,
         network_info=self.network_info,
         block_device_info=None,
     )
开发者ID:slagle,项目名称:nova,代码行数:31,代码来源:test_vmwareapi.py


示例3: ebs_root_in_block_devices

 def ebs_root_in_block_devices(self, block_device_info):
     if block_device_info:
         root_device = block_device_info.get('root_device_name')
         if not root_device:
             root_device = self._default_root_device
         return block_device.volume_in_mapping(root_device,
                                               block_device_info)
开发者ID:tealover,项目名称:compute-hyperv,代码行数:7,代码来源:volumeops.py


示例4: is_boot_from_volume

    def is_boot_from_volume(self, block_device_info):
        if block_device_info:
            root_device = block_device_info.get('root_device_name')
            if not root_device:
                root_device = self._DEFAULT_ROOT_DEVICE

            return block_device.volume_in_mapping(root_device,
                                                  block_device_info)
开发者ID:alexpilotti,项目名称:compute-hyperv,代码行数:8,代码来源:block_device_manager.py


示例5: has_default_ephemeral

def has_default_ephemeral(instance, disk_bus, block_device_info, mapping):
    ephemerals = driver.block_device_info_get_ephemerals(block_device_info)
    if instance['ephemeral_gb'] <= 0 or ephemerals:
        return None
    else:
        info = get_next_disk_info(mapping, disk_bus)
        if block_device.volume_in_mapping(info['dev'], block_device_info):
            return None
        return info
开发者ID:AsherBond,项目名称:nova,代码行数:9,代码来源:blockinfo.py


示例6: test_spawn_attach_volume_iscsi

 def test_spawn_attach_volume_iscsi(self):
     self._create_instance_in_the_db()
     self.type_data = db.flavor_get_by_name(None, "m1.large")
     self.mox.StubOutWithMock(block_device, "volume_in_mapping")
     self.mox.StubOutWithMock(v_driver, "block_device_info_get_mapping")
     ebs_root = "fake_root"
     block_device.volume_in_mapping(mox.IgnoreArg(), mox.IgnoreArg()).AndReturn(ebs_root)
     connection_info = self._test_vmdk_connection_info("iscsi")
     root_disk = [{"connection_info": connection_info}]
     v_driver.block_device_info_get_mapping(mox.IgnoreArg()).AndReturn(root_disk)
     self.mox.StubOutWithMock(volumeops.VMwareVolumeOps, "attach_volume")
     volumeops.VMwareVolumeOps.attach_volume(connection_info, self.instance, mox.IgnoreArg())
     self.mox.ReplayAll()
     self.conn.spawn(
         self.context,
         self.instance,
         self.image,
         injected_files=[],
         admin_password=None,
         network_info=self.network_info,
         block_device_info=None,
     )
开发者ID:slagle,项目名称:nova,代码行数:22,代码来源:test_vmwareapi.py


示例7: _assert_volume_in_mapping

 def _assert_volume_in_mapping(device_name, true_or_false):
     in_mapping = block_device.volume_in_mapping(
             device_name, block_device_info)
     self.assertEqual(in_mapping, true_or_false)
开发者ID:aaaaatoz,项目名称:nova,代码行数:4,代码来源:test_block_device.py


示例8: 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


示例9: 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 overriden by the block device mapping.

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

    inst_type = flavors.extract_flavor(instance)

    mapping = {}

    if virt_type == "lxc":
        # NOTE(zul): This information is not used by the libvirt driver
        # however we need to populate mapping so the image can be
        # created when the instance is started. This can
        # be removed when we convert LXC to use block devices.
        root_disk_bus = disk_bus
        root_device_type = 'disk'

        root_info = get_next_disk_info(mapping,
                                       root_disk_bus,
                                       root_device_type)
        mapping['root'] = root_info
        mapping['disk'] = root_info

        return mapping

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

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

        return mapping

    if image_meta and image_meta.get('disk_format') == 'iso':
        root_disk_bus = cdrom_bus
        root_device_type = 'cdrom'
    else:
        root_disk_bus = disk_bus
        root_device_type = 'disk'

    root_device_name = driver.block_device_info_get_root(block_device_info)
    if root_device_name is not None:
        root_device = block_device.strip_dev(root_device_name)
        root_info = {'bus': get_disk_bus_for_disk_dev(virt_type,
                                                      root_device),
                     'dev': root_device,
                     'type': root_device_type}
    else:
        root_info = get_next_disk_info(mapping,
                                       root_disk_bus,
                                       root_device_type)
    mapping['root'] = root_info
    if not block_device.volume_in_mapping(root_info['dev'],
                                          block_device_info):
        mapping['disk'] = root_info

    eph_info = get_next_disk_info(mapping,
                                  disk_bus)
    ephemeral_device = False
    if not (block_device.volume_in_mapping(eph_info['dev'],
                                           block_device_info) or
            0 in [eph['num'] for eph in
                  driver.block_device_info_get_ephemerals(
                block_device_info)]):
        if instance['ephemeral_gb'] > 0:
            ephemeral_device = True

    if ephemeral_device:
        mapping['disk.local'] = eph_info

    for eph in driver.block_device_info_get_ephemerals(
            block_device_info):
        disk_dev = block_device.strip_dev(eph['device_name'])
        disk_bus = get_disk_bus_for_disk_dev(virt_type, disk_dev)

        mapping[get_eph_disk(eph)] = {'bus': disk_bus,
                                      'dev': disk_dev,
                                      'type': 'disk'}

    swap = driver.block_device_info_get_swap(block_device_info)
    if driver.swap_is_usable(swap):
        disk_dev = block_device.strip_dev(swap['device_name'])
        disk_bus = get_disk_bus_for_disk_dev(virt_type, disk_dev)

        mapping['disk.swap'] = {'bus': disk_bus,
                                'dev': disk_dev,
                                'type': 'disk'}
    elif inst_type['swap'] > 0:
#.........这里部分代码省略.........
开发者ID:iBeacons,项目名称:nova,代码行数:101,代码来源:blockinfo.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python messaging._BroadcastMessage函数代码示例发布时间:2022-05-27
下一篇:
Python block_device.strip_prefix函数代码示例发布时间: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