本文整理汇总了Python中pyvcloud.vcd.vdc.VDC.create_isolated_vdc_network方法的典型用法代码示例。如果您正苦于以下问题:Python VDC.create_isolated_vdc_network方法的具体用法?Python VDC.create_isolated_vdc_network怎么用?Python VDC.create_isolated_vdc_network使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyvcloud.vcd.vdc.VDC
的用法示例。
在下文中一共展示了VDC.create_isolated_vdc_network方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_ovdc_network
# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import create_isolated_vdc_network [as 别名]
def create_ovdc_network(cls):
"""Creates an isolated org vdc network.
The name of the created org vdc network is specified in the
configuration 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 = cls._config['vcd']['default_ovdc_network_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 org-vdc network ' +
expected_net_name)
return
cls._logger.debug('Creating org-vdc network ' + expected_net_name)
result = vdc.create_isolated_vdc_network(
network_name=expected_net_name,
network_cidr=cls._config['vcd']
['default_ovdc_network_network_cidr'])
cls._sys_admin_client.get_task_monitor()\
.wait_for_success(task=result.Tasks.Task[0])
示例2: create_isolated_network
# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import create_isolated_vdc_network [as 别名]
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)
示例3: test_020_create_isolated_orgvdc_network
# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import create_isolated_vdc_network [as 别名]
def test_020_create_isolated_orgvdc_network(self):
org_record = self.client.get_org_by_name(
self.config['vcd']['org_name'])
org = Org(self.client, href=org_record.get('href'))
vdc_resource = org.get_vdc(self.config['vcd']['vdc_name'])
vdc = VDC(self.client, href=vdc_resource.get('href'))
result = vdc.create_isolated_vdc_network(
network_name=self.config['vcd']['vdc_isolated_network_name'],
gateway_ip=self.config['vcd']['isolated_network_gateway_ip'],
netmask=self.config['vcd']['isolated_network_gateway_netmask'],
description='Dummy description')
task = self.client.get_task_monitor().wait_for_success(
task=result.Tasks.Task[0])
assert task.get('status') == TaskStatus.SUCCESS.value
示例4: print
# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import create_isolated_vdc_network [as 别名]
# Check for desired networks and create them if they don't exist.
# (We might add other kinds of networks later.)
if cfg.networks.get("isolated"):
print("Checking isolated networks...")
for network in cfg.networks['isolated']:
isolated_network_list = vdc.list_orgvdc_network_resources(
name=network['network_name'], type=FenceMode.ISOLATED.value)
if len(isolated_network_list) > 0:
print("Isolated network exists: {0}".format(
network['network_name']))
else:
# Create the network in the vDC.
print("Network does not exist, creating: {0}".format(
network['network_name']))
network_resource = vdc.create_isolated_vdc_network(**network)
handle_task(client, network_resource.Tasks.Task[0])
print("Network created")
# Ensure the network is visible in the VDC.
network_exists = False
while not network_exists:
new_network_list = vdc.list_orgvdc_network_resources(
name=network['network_name'],
type=FenceMode.ISOLATED.value)
if len(new_network_list) > 0:
print("Isolated network is visible in VDC: {0}".format(
network['network_name']))
network_exists = True
else:
print("Isolated network is not visible yet: {0}".format(