本文整理汇总了Python中pyvcloud.vcd.gateway.Gateway.add_external_network方法的典型用法代码示例。如果您正苦于以下问题:Python Gateway.add_external_network方法的具体用法?Python Gateway.add_external_network怎么用?Python Gateway.add_external_network使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyvcloud.vcd.gateway.Gateway
的用法示例。
在下文中一共展示了Gateway.add_external_network方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_0020_add_external_network
# 需要导入模块: from pyvcloud.vcd.gateway import Gateway [as 别名]
# 或者: from pyvcloud.vcd.gateway.Gateway import add_external_network [as 别名]
def test_0020_add_external_network(self):
"""Add an exernal netowrk to the gateway.
Invoke the add_external_network function of gateway.
"""
gateway_obj = Gateway(TestGateway._client, self._name,
TestGateway._gateway.get('href'))
extNw2 = self._create_external_network()
ip_scopes = extNw2.xpath(
'vcloud:Configuration/vcloud:IpScopes/vcloud:IpScope',
namespaces=NSMAP)
first_ipscope = ip_scopes[0]
gateway_ip = first_ipscope.Gateway.text
prefixlen = netmask_to_cidr_prefix_len(gateway_ip,
first_ipscope.Netmask.text)
subnet_addr = gateway_ip + '/' + str(prefixlen)
task = gateway_obj.add_external_network(
extNw2.get('name'), [(subnet_addr, 'Auto')])
result = TestGateway._client.get_task_monitor().wait_for_success(
task=task)
self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)