本文整理汇总了Python中pyvcloud.vcd.vdc.VDC.get_resource方法的典型用法代码示例。如果您正苦于以下问题:Python VDC.get_resource方法的具体用法?Python VDC.get_resource怎么用?Python VDC.get_resource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyvcloud.vcd.vdc.VDC
的用法示例。
在下文中一共展示了VDC.get_resource方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_0002_modify_memory
# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import get_resource [as 别名]
def test_0002_modify_memory(self):
logged_in_org = self.client.get_org()
org = Org(self.client, resource=logged_in_org)
vdc_resource = org.get_vdc(self.config['vcd']['vdc'])
vdc = VDC(self.client, resource=vdc_resource)
assert self.config['vcd']['vdc'] == vdc.get_resource().get('name')
vapp_resource = vdc.get_vapp(self.config['vcd']['vapp'])
vapp = VApp(self.client, resource=vapp_resource)
vm_resource = vapp.get_vm(self.config['vcd']['vm'])
vm = VM(self.client, resource=vm_resource)
task = vm.modify_memory(self.config['vcd']['memory'])
task = self.client.get_task_monitor().wait_for_status(
task=task,
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
vm.reload()
assert vm.get_memory() == self.config['vcd']['memory']
示例2: test_060_attach_disk_to_vm_in_vapp
# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import get_resource [as 别名]
def test_060_attach_disk_to_vm_in_vapp(self):
logged_in_org = self.client.get_org()
org = Org(self.client, resource=logged_in_org)
vdc_resource = org.get_vdc(self.config['vcd']['vdc'])
vdc = VDC(self.client, resource=vdc_resource)
assert self.config['vcd']['vdc'] == vdc.get_resource().get('name')
vapp_resource = vdc.get_vapp(self.config['vcd']['vapp'])
assert self.config['vcd']['vapp'] == vapp_resource.get('name')
vapp = VApp(self.client, resource=vapp_resource)
disk = vdc.get_disk(self.config['vcd']['idisk_name'])
result = vapp.attach_disk_to_vm(disk_href=disk.get('href'),
vm_name=self.config['vcd']['vm'])
task = self.client.get_task_monitor().wait_for_status(
task=result,
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
示例3: test_1002_deploy_vm
# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import get_resource [as 别名]
def test_1002_deploy_vm(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')
vapp_resource = vdc.get_vapp(self.config['vcd']['vapp'])
assert vapp_resource.get('name') == self.config['vcd']['vapp']
vapp = VApp(self.client, resource=vapp_resource)
vm_resource = vapp.get_vm(self.config['vcd']['vm'])
vm = VM(self.client, resource=vm_resource)
result = vm.deploy()
# result = vm.shutdown()
task = self.client.get_task_monitor().wait_for_status(
task=result,
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
示例4: test_1006_snapshot_create
# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import get_resource [as 别名]
def test_1006_snapshot_create(self):
logged_in_org = self.client.get_org()
org = Org(self.client, resource=logged_in_org)
vdc_resource = org.get_vdc(self.config['vcd']['vdc'])
vdc = VDC(self.client, resource=vdc_resource)
assert self.config['vcd']['vdc'] == vdc.get_resource().get('name')
vapp_resource = vdc.get_vapp(self.config['vcd']['vapp'])
assert vapp_resource.get('name') == self.config['vcd']['vapp']
vapp = VApp(self.client, resource=vapp_resource)
vm_resource = vapp.get_vm(self.config['vcd']['vm'])
assert vm_resource.get('name') == self.config['vcd']['vm']
vm = VM(self.client, resource=vm_resource)
task = vm.snapshot_create(memory=False, quiesce=False)
task = self.client.get_task_monitor().wait_for_status(
task=task,
timeout=120,
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
示例5: test_001_instantiate_vapp
# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import get_resource [as 别名]
def test_001_instantiate_vapp(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='net2',
fence_mode='natRouted',
deploy=False,
power_on=False)
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
示例6: test_100_instantiate_vapp_identical
# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import get_resource [as 别名]
def test_100_instantiate_vapp_identical(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,
identical=True)
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.reload()
vapp_resource = vdc.get_vapp(self.config['vcd']['vapp'])
vm = vapp_resource.xpath(
'//vcloud:VApp/vcloud:Children/vcloud:Vm', namespaces=NSMAP)
assert len(vm) > 0
assert vm[0].get('name') == self.config['vcd']['vm']
示例7: test_0002_add_vm
# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import get_resource [as 别名]
def test_0002_add_vm(self):
logged_in_org = self.client.get_org()
org = Org(self.client, resource=logged_in_org)
vdc_resource = org.get_vdc(self.config['vcd']['vdc'])
vdc = VDC(self.client, href=vdc_resource.get('href'))
assert self.config['vcd']['vdc'] == vdc.get_resource().get('name')
vapp_resource = vdc.get_vapp(self.config['vcd']['vapp'])
assert vapp_resource.get('name') == self.config['vcd']['vapp']
vapp = VApp(self.client, resource=vapp_resource)
catalog_item = org.get_catalog_item(self.config['vcd']['catalog'],
self.config['vcd']['template'])
source_vapp_resource = self.client.get_resource(
catalog_item.Entity.get('href'))
spec = {'source_vm_name': self.config['vcd']['vm'],
'vapp': source_vapp_resource}
spec['target_vm_name'] = self.config['vcd']['hostname']
spec['hostname'] = self.config['vcd']['hostname']
spec['network'] = self.config['vcd']['network']
spec['ip_allocation_mode'] = self.config['vcd']['ip_allocation_mode']
spec['storage_profile'] = vdc.get_storage_profile(
self.config['vcd']['storage_profile'])
vms = [spec]
result = vapp.add_vms(vms)
task = self.client.get_task_monitor().wait_for_status(
task=result,
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
示例8: test_get_vdc
# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import get_resource [as 别名]
def test_get_vdc(self):
org_to_use = self.client.get_org_by_name(
self.config['vcd']['org_to_use'])
org = Org(self.client, href=org_to_use.get('href'))
resource = org.get_vdc(self.config['vcd']['new_vdc'])
assert resource is not None
vdc = VDC(self.client, resource=resource)
assert self.config['vcd']['new_vdc'] == vdc.get_resource().get('name')
示例9: test_0007_delete
# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import get_resource [as 别名]
def test_0007_delete(self):
logged_in_org = self.client.get_org()
org = Org(self.client, resource=logged_in_org)
vdc_resource = org.get_vdc(self.config['vcd']['vdc'])
vdc = VDC(self.client, resource=vdc_resource)
assert self.config['vcd']['vdc'] == vdc.get_resource().get('name')
vapp_resource = vdc.get_vapp(self.config['vcd']['vapp'])
vapp = VApp(self.client, resource=vapp_resource)
task = vapp.delete_vms([self.config['vcd']['vm']])
task = self.client.get_task_monitor().wait_for_status(task)
assert task.get('status') == TaskStatus.SUCCESS.value
示例10: test_110_instantiate_vapp_custom_disk_size
# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import get_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()
示例11: test_1000_delete_vapp
# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import get_resource [as 别名]
def test_1000_delete_vapp(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.delete_vapp(self.config['vcd']['vapp'], force=True)
task = self.client.get_task_monitor().wait_for_status(
task=result,
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