本文整理汇总了Python中pyvcloud.vcd.org.Org.get_vdc方法的典型用法代码示例。如果您正苦于以下问题:Python Org.get_vdc方法的具体用法?Python Org.get_vdc怎么用?Python Org.get_vdc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyvcloud.vcd.org.Org
的用法示例。
在下文中一共展示了Org.get_vdc方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: read
# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import get_vdc [as 别名]
def read(self, request):
logging.info("__INIT__read[VappVm]")
res = vapp_vm_pb2.ReadVappVmResult()
res.present = False
org_resource = self.client.get_org()
org = Org(self.client, resource=org_resource)
try:
vdc_resource = org.get_vdc(request.target_vdc)
vdc = VDC(
self.client, name=request.target_vdc, resource=vdc_resource)
vapp_resource = vdc.get_vapp(request.target_vapp)
vapp = VApp(
self.client, name=request.target_vapp, resource=vapp_resource)
read_vapp_vm_resp = vapp.get_vm(request.target_vm_name)
vm = VM(client=self.client, href=None, resource=read_vapp_vm_resp)
res.present = True
except Exception as e:
errmsg = '__ERROR_read[VappVm] failed for VappVm {0}. __ErrorMessage__ {1}'
logging.warn(errmsg.format(request.target_vm_name, str(e)))
return res
logging.info("__DONE__read[VappVm]")
return res
示例2: test_0002_add_vm
# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import get_vdc [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
示例3: test_1002_deploy_vm
# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import get_vdc [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_001_instantiate_vapp
# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import get_vdc [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
示例5: update
# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import get_vdc [as 别名]
def update(self):
logging.info("__INIT__update[Vdc]")
res = vdc_pb2.UpdateVdcResult()
res.updated = False
context = self.context
logged_in_org = self.client.get_org()
org = Org(self.client, resource=logged_in_org)
#Vdc details
name = self.name
is_enabled = self.is_enabled
try:
vdc_resource = org.get_vdc(name)
vdc = VDC(self.client, name=name, resource=vdc_resource)
result = vdc.enable_vdc(is_enabled)
res.updated = True
except Exception as e:
error_message = '__ERROR_update[Vdc] failed for Vdc {0}. __ErrorMessage__ {1}'.format(
self.name, str(e))
logging.warn(error_message)
context.set_code(grpc.StatusCode.INVALID_ARGUMENT)
context.set_details(error_message)
return res
logging.info("__DONE__update[Vdc]")
return res
示例6: test_03_get_vdc_access
# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import get_vdc [as 别名]
def test_03_get_vdc_access(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)
control_access = vdc.get_access_settings()
assert len(control_access.AccessSettings.AccessSetting) == 2
示例7: test_060_attach_disk_to_vm_in_vapp
# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import get_vdc [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
示例8: test_1006_snapshot_create
# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import get_vdc [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
示例9: test_001_list_edge_gateways
# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import get_vdc [as 别名]
def test_001_list_edge_gateways(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, resource=v)
edge_gateways = vdc.list_edge_gateways()
assert len(edge_gateways) > 0
示例10: test_100_instantiate_vapp_identical
# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import get_vdc [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']
示例11: create_disk
# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import get_vdc [as 别名]
def create_disk(client):
logging.info('INIT create_disk')
logged_in_org = client.get_org()
org = Org(client, resource=logged_in_org)
v = org.get_vdc('OVD2')
if v is None:
raise errors.VDCNotFoundError(vappInfo.vdc)
vdc = VDC(client, href=v.get('href'))
#task=vdc.delete_disk('disk01')
result = vdc.add_disk('disk02', "100")
logging.info('DONE create_disk %s', result)
task = client.get_task_monitor().wait_for_status(
task=result.Tasks.Task[0],
timeout=60,
poll_frequency=2,
fail_on_status=None,
expected_target_statuses=[
TaskStatus.SUCCESS, TaskStatus.ABORTED, TaskStatus.ERROR,
TaskStatus.CANCELED
],
callback=task_callback)
st = task.get('status')
if st == TaskStatus.SUCCESS.value:
logging.info("__LOG__ created DISK")
#cresult.created = True
else:
raise errors.VCDDiskCreationError(
etree.tostring(task, pretty_print=True))
示例12: test_0002_modify_memory
# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import get_vdc [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']
示例13: delete_vm
# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import get_vdc [as 别名]
def delete_vm(client):
print("================= Vdc delete request ===================")
vdc_name = "pcp_vdc_02"
target_vm_name = "pcp_vm"
org_resource = client.get_org()
org = Org(client, resource=org_resource)
print("Org name: ", org.get_name())
print("Vdc name: ", vdc_name)
vdc_resource = org.get_vdc(vdc_name)
vdc = VDC(client, name=vdc_name, resource=vdc_resource)
vapp_resource = vdc.get_vapp(vapp_name)
vapp = VApp(client, name=vapp_name, resource=vapp_resource)
delete_vapp_vm_resp = vapp.delete_vms(target_vm_name)
task = client.get_task_monitor().wait_for_status(
task=delete_vapp_vm_resp,
timeout=60,
poll_frequency=2,
fail_on_statuses=None,
expected_target_statuses=[
TaskStatus.SUCCESS, TaskStatus.ABORTED, TaskStatus.ERROR,
TaskStatus.CANCELED
],
callback=None)
st = task.get('status')
if st == TaskStatus.SUCCESS.value:
message = 'delete vdc status : {0} '.format(st)
logging.info(message)
else:
raise errors.VCDVdcDeleteError(etree.tostring(task, pretty_print=True))
示例14: test_080_update_disk
# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import get_vdc [as 别名]
def test_080_update_disk(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)
result = vdc.update_disk(
name=self.config['vcd']['idisk_name'],
new_name=self.config['vcd']['idisk_new_name'],
new_size=self.config['vcd']['idisk_new_size'],
new_description=self.config['vcd']['idisk_new_description'],
new_storage_profile_name=self.config['vcd']['idisk_new_sp_name'],
new_iops=self.config['vcd']['idisk_new_iops'])
task = self.client.get_task_monitor().wait_for_status(
task=result,
timeout=30,
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
示例15: test_06_unshare_vdc_access
# 需要导入模块: from pyvcloud.vcd.org import Org [as 别名]
# 或者: from pyvcloud.vcd.org.Org import get_vdc [as 别名]
def test_06_unshare_vdc_access(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)
control_access = vdc.unshare_from_org_members()
assert control_access.IsSharedToEveryone.text == 'false'