本文整理汇总了Python中pyvcloud.vcd.vdc.VDC类的典型用法代码示例。如果您正苦于以下问题:Python VDC类的具体用法?Python VDC怎么用?Python VDC使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VDC类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: update
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
开发者ID:gefeng24,项目名称:terraform-provider-vcloud-director,代码行数:27,代码来源:vdc.py
示例2: read
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
开发者ID:gefeng24,项目名称:terraform-provider-vcloud-director,代码行数:27,代码来源:vapp_vm.py
示例3: test_001_list_edge_gateways
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
开发者ID:vmware,项目名称:pyvcloud,代码行数:7,代码来源:vcd_edge_gateway.py
示例4: test_080_update_disk
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
开发者ID:rdbwebster,项目名称:pyvcloud,代码行数:26,代码来源:vcd_disk.py
示例5: create_disk
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))
开发者ID:gefeng24,项目名称:terraform-provider-vcloud-director,代码行数:32,代码来源:test_org.py
示例6: __create_advanced_gateway
def __create_advanced_gateway(self):
"""Creates a gateway."""
ext_config = TestIpSecVpn._config['external_network']
vdc_reource = TestIpSecVpn._vdc_resource
api_version = TestIpSecVpn._config['vcd']['api_version']
vdc = VDC(TestIpSecVpn._client, resource=vdc_reource)
gateway = vdc.get_gateway(TestIpSecVpn._gateway_name)
if self.__does_exist_gateway(TestIpSecVpn._gateway_name):
return
if float(api_version) <= float(
ApiVersion.VERSION_30.value):
gateway = vdc.create_gateway_api_version_30(
TestIpSecVpn._gateway_name, [ext_config['name']])
elif float(api_version) == float(ApiVersion.VERSION_31.value):
gateway = vdc.create_gateway_api_version_31(
TestIpSecVpn._gateway_name,
[ext_config['name']],
should_create_as_advanced=True)
elif float(api_version) >= float(ApiVersion.VERSION_32.value):
gateway = vdc.create_gateway_api_version_32(
TestIpSecVpn._gateway_name, [ext_config['name']],
should_create_as_advanced=True)
TestIpSecVpn._client.get_task_monitor(). \
wait_for_success(task=gateway.Tasks.Task[0])
TestIpSecVpn._gateway_href = gateway.get('href')
TestIpSecVpn._gateway_obj = Gateway(TestIpSecVpn._client,
href=TestIpSecVpn._gateway_href)
TestIpSecVpn._gateway_resource = TestIpSecVpn. \
_gateway_obj.get_resource()
开发者ID:vmware,项目名称:vca-cli,代码行数:32,代码来源:ipsec_vpn_tests.py
示例7: test_03_get_vdc_access
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
开发者ID:vmware,项目名称:pyvcloud,代码行数:7,代码来源:vcd_vdc.py
示例8: test_06_unshare_vdc_access
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'
开发者ID:vmware,项目名称:pyvcloud,代码行数:7,代码来源:vcd_vdc.py
示例9: list_disks
def list_disks(ctx):
try:
restore_session(ctx, vdc_required=True)
client = ctx.obj['client']
vdc_href = ctx.obj['profiles'].get('vdc_href')
vdc = VDC(client, href=vdc_href)
disks = vdc.get_disks()
result = []
for disk in disks:
attached_vms = ''
if hasattr(disk, 'attached_vms') and \
hasattr(disk.attached_vms, 'VmReference'):
attached_vms = disk.attached_vms.VmReference.get('name')
result.append({
'name':
disk.get('name'),
'id':
extract_id(disk.get('id')),
'owner':
disk.Owner.User.get('name'),
'size':
humanfriendly.format_size(int(disk.get('size'))),
'size_bytes':
disk.get('size'),
'status':
VCLOUD_STATUS_MAP.get(int(disk.get('status'))),
'vms_attached':
attached_vms
})
stdout(result, ctx, show_id=True)
except Exception as e:
stderr(e, ctx)
开发者ID:vmware,项目名称:vca-cli,代码行数:32,代码来源:disk.py
示例10: create_routed_ovdc_network
def create_routed_ovdc_network(cls):
"""Creates a routed org vdc network.
The name of the created org vdc network is specified in the
ovdc_network_constant file, skips creating one, if such a network already
exists.
:raises: Exception: if the class variable _ovdc_href is not populated.
"""
cls._basic_check()
if cls._ovdc_href is None:
raise Exception('OrgVDC ' +
cls._config['vcd']['default_ovdc_name'] +
' doesn\'t exist.')
vdc = VDC(cls._sys_admin_client, href=cls._ovdc_href)
expected_net_name = OvdcNetConstants.routed_net_name
records_list = vdc.list_orgvdc_network_records()
for network_record in records_list:
if network_record['name'].lower() == expected_net_name.lower():
cls._logger.debug('Reusing existing direct org-vdc network ' +
expected_net_name)
return
result = vdc.create_routed_vdc_network(
network_name=OvdcNetConstants.routed_net_name,
gateway_name=GatewayConstants.name,
network_cidr=OvdcNetConstants.routed_orgvdc_network_gateway_ip,
description='org vdc network description')
cls._sys_admin_client.get_task_monitor() \
.wait_for_success(task=result.Tasks.Task[0])
开发者ID:vmware,项目名称:pyvcloud,代码行数:34,代码来源:environment.py
示例11: capture_vapp
def capture_vapp(self):
params = self.params
vapp_name = params.get('vapp_name')
vdc_name = params.get('vdc_name')
catalog_name = params.get('catalog_name')
item_name = params.get('item_name')
desc = params.get('description')
customize_on_instantiate = params.get('customize_on_instantiate')
overwrite = params.get('overwrite')
client = self.client
response = dict()
response['changed'] = False
v = self.org.get_vdc(vdc_name)
vdc = VDC(client, href=v.get('href'))
vapp = vdc.get_vapp(vapp_name)
catalog = self.org.get_catalog(catalog_name)
self.org.capture_vapp(
catalog_resource=catalog,
vapp_href=vapp.get('href'),
catalog_item_name=item_name,
description=desc,
customize_on_instantiate=customize_on_instantiate,
overwrite=overwrite)
self.ova_check_resolved()
response['msg'] = "Catalog Item {} has been captured".format(item_name)
response['changed'] = True
return response
开发者ID:equinix-ms,项目名称:ansible-module-vcloud-director,代码行数:29,代码来源:vcd_catalog_item.py
示例12: test_0002_modify_memory
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']
开发者ID:vmware,项目名称:pyvcloud,代码行数:25,代码来源:vcd_vm.py
示例13: test_0002_add_vm
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
开发者ID:rdbwebster,项目名称:pyvcloud,代码行数:35,代码来源:vcd_vapp_vm.py
示例14: create_isolated_network
def create_isolated_network(ctx, name, gateway_ip, netmask, description,
primary_dns_ip, secondary_dns_ip, dns_suffix,
ip_range_start, ip_range_end, is_dhcp_enabled,
default_lease_time, max_lease_time,
dhcp_ip_range_start, dhcp_ip_range_end, is_shared):
try:
restore_session(ctx, vdc_required=True)
client = ctx.obj['client']
in_use_vdc_href = ctx.obj['profiles'].get('vdc_href')
vdc = VDC(client, href=in_use_vdc_href)
prefix_len = netmask_to_cidr_prefix_len(gateway_ip, netmask)
network_cidr = gateway_ip + '/' + str(prefix_len)
result = vdc.create_isolated_vdc_network(
network_name=name,
network_cidr=network_cidr,
description=description,
primary_dns_ip=primary_dns_ip,
secondary_dns_ip=secondary_dns_ip,
dns_suffix=dns_suffix,
ip_range_start=ip_range_start,
ip_range_end=ip_range_end,
is_dhcp_enabled=is_dhcp_enabled,
default_lease_time=default_lease_time,
max_lease_time=max_lease_time,
dhcp_ip_range_start=dhcp_ip_range_start,
dhcp_ip_range_end=dhcp_ip_range_end,
is_shared=is_shared)
stdout(result.Tasks.Task[0], ctx)
except Exception as e:
stderr(e, ctx)
开发者ID:vmware,项目名称:vca-cli,代码行数:32,代码来源:network.py
示例15: delete_vm
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))
开发者ID:gefeng24,项目名称:terraform-provider-vcloud-director,代码行数:33,代码来源:test_vapp_vm.py
示例16: capture
def capture(ctx, name, catalog, template, customizable, description):
try:
restore_session(ctx, vdc_required=True)
client = ctx.obj['client']
in_use_org_href = ctx.obj['profiles'].get('org_href')
org = Org(client, in_use_org_href)
catalog_resource = org.get_catalog(catalog)
vdc_href = ctx.obj['profiles'].get('vdc_href')
vdc = VDC(client, href=vdc_href)
vapp_resource = vdc.get_vapp(name)
overwrite = False
if template is None:
template = vapp_resource.get('name')
else:
overwrite = True
task = org.capture_vapp(
catalog_resource,
vapp_href=vapp_resource.get('href'),
catalog_item_name=template,
description=description,
customize_on_instantiate=customizable == 'customizable',
overwrite=overwrite)
stdout(task, ctx)
except Exception as e:
stderr(e, ctx)
开发者ID:vmware,项目名称:vca-cli,代码行数:25,代码来源:vapp.py
示例17: create
def create(ctx, name, description, catalog, template, network, memory, cpu,
disk_size, ip_allocation_mode, vm_name, hostname, storage_profile,
accept_all_eulas):
try:
restore_session(ctx, vdc_required=True)
client = ctx.obj['client']
vdc_href = ctx.obj['profiles'].get('vdc_href')
vdc = VDC(client, href=vdc_href)
if catalog is None and template is None:
vapp_resource = vdc.create_vapp(
name,
description=description,
network=network,
accept_all_eulas=accept_all_eulas)
else:
vapp_resource = vdc.instantiate_vapp(
name,
catalog,
template,
description=description,
network=network,
memory=memory,
cpu=cpu,
disk_size=disk_size,
deploy=True,
power_on=True,
accept_all_eulas=accept_all_eulas,
cust_script=None,
ip_allocation_mode=ip_allocation_mode,
vm_name=vm_name,
hostname=hostname,
storage_profile=storage_profile)
stdout(vapp_resource.Tasks.Task[0], ctx)
except Exception as e:
stderr(e, ctx)
开发者ID:vmware,项目名称:vca-cli,代码行数:35,代码来源:vapp.py
示例18: test_1002_deploy_vm
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
开发者ID:vmware,项目名称:pyvcloud,代码行数:25,代码来源:vcd_vm.py
示例19: test_060_attach_disk_to_vm_in_vapp
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
开发者ID:rdbwebster,项目名称:pyvcloud,代码行数:27,代码来源:vcd_disk.py
示例20: test_1006_snapshot_create
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
开发者ID:vmware,项目名称:pyvcloud,代码行数:25,代码来源:vcd_vm.py
注:本文中的pyvcloud.vcd.vdc.VDC类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论