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

Python vm_mode.get_from_instance函数代码示例

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

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



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

示例1: test_determine_vm_mode_returns_hvm

    def test_determine_vm_mode_returns_hvm(self):
        self.mox.StubOutWithMock(vm_mode, "get_from_instance")

        fake_instance = "instance"
        vm_mode.get_from_instance(fake_instance).AndReturn(vm_mode.HVM)

        self.mox.ReplayAll()
        self.assertEquals(vm_mode.HVM, self._vmops._determine_vm_mode(fake_instance, None, None))
        self.mox.VerifyAll()
开发者ID:ChaosCloud,项目名称:nova,代码行数:9,代码来源:test_vmops.py


示例2: test_determine_vm_mode_returns_is_not_pv_no_root_disk

    def test_determine_vm_mode_returns_is_not_pv_no_root_disk(self):
        self.mox.StubOutWithMock(vm_mode, "get_from_instance")
        self.mox.StubOutWithMock(vm_utils, "determine_is_pv")

        fake_instance = {"os_type": "foo"}
        fake_vdis = {"iso": {"ref": "fake"}}
        fake_disk_type = "disk"
        vm_mode.get_from_instance(fake_instance).AndReturn(None)

        self.mox.ReplayAll()
        self.assertEquals(vm_mode.HVM, self._vmops._determine_vm_mode(fake_instance, fake_vdis, fake_disk_type))
        self.mox.VerifyAll()
开发者ID:ChaosCloud,项目名称:nova,代码行数:12,代码来源:test_vmops.py


示例3: get_disk_bus_for_device_type

def get_disk_bus_for_device_type(virt_type,
                                 image_meta,
                                 device_type="disk",
                                 instance=None):
    """Determine the best disk bus to use for a device type.

       Considering the currently configured virtualization
       type, return the optimal disk_bus to use for a given
       device type. For example, for a disk on KVM it will
       return 'virtio', while for a CDROM it will return 'ide'
       on x86_64 and 'scsi' on ppc64.

       Returns the disk_bus, or returns None if the device
       type is not supported for this virtualization
    """

    # Prefer a disk bus set against the image first of all
    key = "hw_" + device_type + "_bus"
    disk_bus = image_meta.get('properties', {}).get(key)
    if disk_bus is not None:
        if not is_disk_bus_valid_for_virt(virt_type, disk_bus):
            raise exception.UnsupportedHardware(model=disk_bus,
                                                virt=virt_type)
        return disk_bus

    # Otherwise pick a hypervisor default disk bus
    if virt_type == "uml":
        if device_type == "disk":
            return "uml"
    elif virt_type == "lxc":
        return "lxc"
    elif virt_type == "xen":
        guest_vm_mode = None
        if instance:
            guest_vm_mode = vm_mode.get_from_instance(instance)
        if guest_vm_mode == vm_mode.HVM:
            return "ide"
        else:
            return "xen"
    elif virt_type in ("qemu", "kvm"):
        if device_type == "cdrom":
            guestarch = libvirt_utils.get_arch(image_meta)
            if guestarch in (arch.PPC, arch.PPC64, arch.S390, arch.S390X):
                return "scsi"
            else:
                return "ide"
        elif device_type == "disk":
            return "virtio"
        elif device_type == "floppy":
            return "fdc"
    elif virt_type == "parallels":
        if device_type == "cdrom":
            return "ide"
        elif device_type in ("disk", "fs"):
            return "sata"
    else:
        # If virt-type not in list then it is unsupported
        raise exception.UnsupportedVirtType(virt=virt_type)

    return None
开发者ID:anantk,项目名称:nova,代码行数:60,代码来源:blockinfo.py


示例4: test_determine_vm_mode_returns_is_not_pv

    def test_determine_vm_mode_returns_is_not_pv(self):
        self.mox.StubOutWithMock(vm_mode, 'get_from_instance')
        self.mox.StubOutWithMock(vm_utils, 'determine_is_pv')

        fake_instance = {"os_type": "foo"}
        fake_vdis = {'root': {"ref": 'fake'}}
        fake_disk_type = "disk"
        vm_mode.get_from_instance(fake_instance).AndReturn(None)
        vm_utils.determine_is_pv(self._session, "fake", fake_disk_type,
            "foo").AndReturn(False)

        self.mox.ReplayAll()
        self.assertEquals(vm_mode.HVM,
            self._vmops._determine_vm_mode(fake_instance, fake_vdis,
                                     fake_disk_type))
        self.mox.VerifyAll()
开发者ID:DavidYan,项目名称:nova,代码行数:16,代码来源:test_vmops.py


示例5: test_good

 def test_good(self):
     inst = dict(vm_mode="hvm")
     mode = vm_mode.get_from_instance(inst)
     self.assertEqual(mode, "hvm")
开发者ID:OpenAcademy-OpenStack,项目名称:nova-scheduler,代码行数:4,代码来源:test_vmmode.py


示例6: test_legacy_pv

 def test_legacy_pv(self):
     inst = dict(vm_mode="pv")
     mode = vm_mode.get_from_instance(inst)
     self.assertEqual(mode, "xen")
开发者ID:OpenAcademy-OpenStack,项目名称:nova-scheduler,代码行数:4,代码来源:test_vmmode.py


示例7: test_good

 def test_good(self):
     inst = self._fake_object(dict(vm_mode="hvm"))
     mode = vm_mode.get_from_instance(inst)
     self.assertEqual(mode, "hvm")
开发者ID:375670450,项目名称:nova,代码行数:4,代码来源:test_vmmode.py


示例8: test_good

 def test_good(self):
     inst = ComputeVMModeTest.testinstance("hvm")
     mode = vm_mode.get_from_instance(inst)
     self.assertEqual(mode, "hvm")
开发者ID:nati,项目名称:nova,代码行数:4,代码来源:test_vmmode.py


示例9: test_legacy_pv

 def test_legacy_pv(self):
     inst = ComputeVMModeTest.testinstance("pv")
     mode = vm_mode.get_from_instance(inst)
     self.assertEqual(mode, "xen")
开发者ID:nati,项目名称:nova,代码行数:4,代码来源:test_vmmode.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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