本文整理汇总了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()