本文整理汇总了Python中pyvcloud.system_test_framework.environment.Environment.get_test_external_network方法的典型用法代码示例。如果您正苦于以下问题:Python Environment.get_test_external_network方法的具体用法?Python Environment.get_test_external_network怎么用?Python Environment.get_test_external_network使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyvcloud.system_test_framework.environment.Environment
的用法示例。
在下文中一共展示了Environment.get_test_external_network方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_0000_setup
# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_test_external_network [as 别名]
def test_0000_setup(self):
"""Setup the gateway required for the other tests in this module.
Create a gateway as per the configuration stated
above.
This test passes if the gateway is created successfully.
"""
TestGateway._client = Environment.get_sys_admin_client()
TestGateway._vdc = Environment.get_test_vdc(TestGateway._client)
TestGateway._org_client = Environment.get_client_in_default_org(
CommonRoles.ORGANIZATION_ADMINISTRATOR)
TestGateway._config = Environment.get_config()
TestGateway._api_version = TestGateway._config['vcd']['api_version']
external_network = Environment.get_test_external_network(
TestGateway._client)
ext_net_resource = external_network.get_resource()
ip_scopes = ext_net_resource.xpath(
'vcloud:Configuration/vcloud:IpScopes/vcloud:IpScope',
namespaces=NSMAP)
first_ipscope = ip_scopes[0]
gateway_ip = first_ipscope.Gateway.text
prefix_len = netmask_to_cidr_prefix_len(gateway_ip,
first_ipscope.Netmask.text)
subnet_addr = gateway_ip + '/' + str(prefix_len)
ext_net_to_participated_subnet_with_ip_settings = {
ext_net_resource.get('name'): {
subnet_addr: self._ip_address_for_config_ip_setting
}
}
ext_net_to_subnet_with_ip_range = {
ext_net_resource.get('name'): {
subnet_addr: [self._ip_address_for_ip_range]
}
}
ext_net_to_rate_limit = {ext_net_resource.get('name'): {100: 100}}
if float(TestGateway._api_version) <= float(
ApiVersion.VERSION_30.value):
TestGateway._gateway = \
TestGateway._vdc.create_gateway_api_version_30(
self._name, [ext_net_resource.get('name')], 'compact',
None,
True, ext_net_resource.get('name'), gateway_ip, True,
False,
False, False, True,
ext_net_to_participated_subnet_with_ip_settings, True,
ext_net_to_subnet_with_ip_range, ext_net_to_rate_limit)
elif float(TestGateway._api_version) == float(
ApiVersion.VERSION_31.value):
TestGateway._gateway = \
TestGateway._vdc.create_gateway_api_version_31(
self._name, [ext_net_resource.get('name')], 'compact',
None, True, ext_net_resource.get('name'), gateway_ip,
True, False, False, False, True,
ext_net_to_participated_subnet_with_ip_settings, True,
ext_net_to_subnet_with_ip_range, ext_net_to_rate_limit)
elif float(TestGateway._api_version) >= float(
ApiVersion.VERSION_32.value):
TestGateway._gateway = \
TestGateway._vdc.create_gateway_api_version_32(
self._name, [ext_net_resource.get('name')], 'compact',
None, True, ext_net_resource.get('name'), gateway_ip,
True, False, False, False, True,
ext_net_to_participated_subnet_with_ip_settings, True,
ext_net_to_subnet_with_ip_range, ext_net_to_rate_limit)
result = TestGateway._client.get_task_monitor().wait_for_success(
task=TestGateway._gateway.Tasks.Task)
self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)
TestGateway._extension = Extension(TestGateway._client)
TestGateway._extension.get_resource()
link = find_link(TestGateway._extension.resource, RelationType.DOWN,
EntityType.SYSTEM_SETTINGS.value)
settings = TestGateway._client.get_resource(link.href)
syslog_server_settings = settings.GeneralSettings.SyslogServerSettings
if hasattr(syslog_server_settings,
'{' + NSMAP['vcloud'] + '}SyslogServerIp1'):
return
syslog_server_settings.append(
E.SyslogServerIp1(TestGateway._syslog_server_ip1))
TestGateway._client.put_resource(link.href, settings,
EntityType.SYSTEM_SETTINGS.value)
TestGateway._extension.reload()
settings = TestGateway._client.get_resource(link.href)
self.assertTrue(
hasattr(syslog_server_settings, '{' + NSMAP['vcloud'] +
'}SyslogServerIp1'))