本文整理汇总了Python中pyvcloud.vcloudair.VCA.get_gateways方法的典型用法代码示例。如果您正苦于以下问题:Python VCA.get_gateways方法的具体用法?Python VCA.get_gateways怎么用?Python VCA.get_gateways使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyvcloud.vcloudair.VCA
的用法示例。
在下文中一共展示了VCA.get_gateways方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from pyvcloud.vcloudair import VCA [as 别名]
# 或者: from pyvcloud.vcloudair.VCA import get_gateways [as 别名]
#.........这里部分代码省略.........
sections)[0])
os = (operatingSystemSection.
get_Description().get_valueOf_())
ips = []
networks = []
cds = []
_url = '{http://www.vmware.com/vcloud/v1.5}ipAddress'
for item in items:
if item.Connection:
for c in item.Connection:
networks.append(c.valueOf_)
if c.anyAttributes_.get(
_url):
ips.append(c.anyAttributes_.get(
_url))
elif (item.HostResource and
item.ResourceSubType and
item.ResourceSubType.valueOf_ ==
'vmware.cdrom.iso'):
if len(item.HostResource[0].valueOf_) > 0:
cds.append(item.HostResource[0].valueOf_)
table.append([vm.name, entity.name, vm_status,
utils.beautified(ips),
utils.beautified(networks),
cpu_capacity,
str(memory_capacity),
utils.beautified(cds),
os, owner])
sorted_table = sorted(table, key=operator.itemgetter(0),
reverse=False)
return sorted_table
def select_default_gateway(self):
gateways = self.vca.get_gateways(self.vdc_name)
if len(gateways) > 0:
self.gateway = gateways[0].get_name()
else:
self.gateway = None
def gateways_to_table(self, gateways):
table = []
for gateway in gateways:
interfaces = gateway.get_interfaces('uplink')
ext_interface_table = []
for interface in interfaces:
ext_interface_table.append(interface.get_Name())
interfaces = gateway.get_interfaces('internal')
interface_table = []
for interface in interfaces:
interface_table.append(interface.get_Name())
public_ips = gateway.get_public_ips()
public_ips_value = public_ips
if len(public_ips) > 2:
public_ips_value = (
"vca gateway info - to list IPs (%d)"
% (len(public_ips)))
table.append([
gateway.get_name(),
utils.beautified(str(public_ips_value)),
'On' if gateway.is_dhcp_enabled() else 'Off',
'On' if gateway.is_fw_enabled() else 'Off',
'On' if gateway.is_nat_enabled() else 'Off',
'On' if gateway.is_vpn_enabled() else 'Off',
utils.beautified(interface_table),
gateway.get_syslog_conf(),
utils.beautified(ext_interface_table),
示例2: diff
# 需要导入模块: from pyvcloud.vcloudair import VCA [as 别名]
# 或者: from pyvcloud.vcloudair.VCA import get_gateways [as 别名]
# next login, with token, org and org_url, no password, it will retrieve the organization
result = vca.login_to_instance(
instance=instance, password=None, token=vca.vcloud_session.token, org_url=vca.vcloud_session.org_url
)
# this tests the vca token
result = vca.login(token=vca.token)
network = vca.get_network(vdc_name, network_name)
# vapp = vca.get_vapp(vca.get_vdc(vdc_name), vapp_name)
# internal_ip = vapp.get_vms_network_info()[0][0]['ip']
internal_ip = "192.168.109.3"
gateway = vca.get_gateways(vdc_name)[0]
used_ips = gateway.get_public_ips()
task = gateway.allocate_public_ip()
task_result = vca.block_until_completed(task)
gateway = vca.get_gateways(vdc_name)[0]
public_ip = diff(gateway.get_public_ips(), used_ips)[0]
gateway.add_nat_rule("DNAT", public_ip, 22, internal_ip, 22, "Tcp")
gateway.add_nat_rule("DNAT", public_ip, 80, internal_ip, 80, "Tcp")
gateway.add_nat_rule("DNAT", public_ip, 443, internal_ip, 443, "Tcp")
gateway.add_nat_rule("SNAT", internal_ip, -1, public_ip, -1, "Tcp")
task = gateway.save_services_configuration()
task_result = vca.block_until_completed(task)
gateway = vca.get_gateways(vdc_name)[0]
gateway.add_fw_rule(True, "anythinggoes", "allow", "Any", "Any", "any", "Any", "any", True)
task = gateway.save_services_configuration()