当前位置: 首页>>代码示例>>Python>>正文


Python VDC.resource方法代码示例

本文整理汇总了Python中pyvcloud.vcd.vdc.VDC.resource方法的典型用法代码示例。如果您正苦于以下问题:Python VDC.resource方法的具体用法?Python VDC.resource怎么用?Python VDC.resource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyvcloud.vcd.vdc.VDC的用法示例。


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

示例1: test_110_instantiate_vapp_custom_disk_size

# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import resource [as 别名]
    def test_110_instantiate_vapp_custom_disk_size(self):
        logged_in_org = self.client.get_org()
        org = Org(self.client, resource=logged_in_org)
        v = org.get_vdc(self.config['vcd']['vdc'])
        vdc = VDC(self.client, href=v.get('href'))
        assert self.config['vcd']['vdc'] == vdc.get_resource().get('name')
        result = vdc.instantiate_vapp(
            self.config['vcd']['vapp'],
            self.config['vcd']['catalog'],
            self.config['vcd']['template'],
            network=self.config['vcd']['network'],
            fence_mode='bridged',
            deploy=True,
            power_on=False,
            disk_size=self.config['vcd']['disk_size_new'])
        task = self.client.get_task_monitor().wait_for_status(
            task=result.Tasks.Task[0],
            timeout=60,
            poll_frequency=2,
            fail_on_statuses=None,
            expected_target_statuses=[
                TaskStatus.SUCCESS, TaskStatus.ABORTED, TaskStatus.ERROR,
                TaskStatus.CANCELED
            ],
            callback=None)
        assert task.get('status') == TaskStatus.SUCCESS.value
        vdc.resource = vdc.client.get_resource(vdc.href)
        vapp_resource = vdc.get_vapp(self.config['vcd']['vapp'])
        vms = vapp_resource.xpath(
            '//vcloud:VApp/vcloud:Children/vcloud:Vm', namespaces=NSMAP)
        assert len(vms) > 0

        items = vms[0].xpath(
            '//ovf:VirtualHardwareSection/ovf:Item',
            namespaces={
                'ovf': NSMAP['ovf']
            })
        assert len(items) > 0

        found_disk = False
        for item in items:
            if item['{' + NSMAP['rasd'] + '}ResourceType'] == 17:  # NOQA
                found_disk = True
                assert item['{' + NSMAP['rasd'] + '}VirtualQuantity'] == \
                    (self.config['vcd']['disk_size_new'] * 1024 * 1024)
                break

        # this check makes sure that the vm isn't disk-less
        assert found_disk

        # cleanup
        self.test_100_delete_vapp()
开发者ID:vmware,项目名称:pyvcloud,代码行数:54,代码来源:vcd_vapp.py


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