本文整理汇总了Python中pyvcloud.vcd.gateway.Gateway类的典型用法代码示例。如果您正苦于以下问题:Python Gateway类的具体用法?Python Gateway怎么用?Python Gateway使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Gateway类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_0098_teardown
def test_0098_teardown(self):
"""Remove the sub allocated ip pools of gateway.
Invokes the remove_sub_allocated_ip_pools of the gateway.
"""
gateway = Environment. \
get_test_gateway(TestNatRule._client)
gateway_obj = Gateway(TestNatRule._client,
TestNatRule._name,
href=gateway.get('href'))
ip_allocations = gateway_obj.list_configure_ip_settings()
ip_allocation = ip_allocations[0]
ext_network = ip_allocation.get('external_network')
config = TestNatRule._config['external_network']
gateway_sub_allocated_ip_range1 = \
config['gateway_sub_allocated_ip_range']
task = gateway_obj.remove_sub_allocated_ip_pools(ext_network,
[gateway_sub_allocated_ip_range1])
result = TestNatRule._client.get_task_monitor().wait_for_success(
task=task)
self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)
gateway = Environment. \
get_test_gateway(TestNatRule._client)
gateway_obj = Gateway(TestNatRule._client,
TestNatRule._name,
href=gateway.get('href'))
subnet_participation = self.__get_subnet_participation(
gateway_obj.get_resource(), ext_network)
"""removed the IpRanges form subnet_participation."""
self.assertFalse(hasattr(subnet_participation, 'IpRanges'))
示例2: test_0000_setup
def test_0000_setup(self):
self._config = Environment.get_config()
TestFirewallRule._logger = Environment.get_default_logger()
TestFirewallRule._client = Environment.get_sys_admin_client()
TestFirewallRule._runner = CliRunner()
default_org = self._config['vcd']['default_org_name']
TestFirewallRule._ext_nw = self._config['external_network']['name']
self._login()
TestFirewallRule._runner.invoke(org, ['use', default_org])
result = TestFirewallRule._runner.invoke(
gateway,
args=[
'services', 'firewall', 'create', TestFirewallRule.__name,
'--name', TestFirewallRule.__firewall_rule_name, '--action',
'accept', '--type', 'User', '--enabled', '--logging-enabled'
])
self.assertEqual(0, result.exit_code)
gateway_res = Environment.get_test_gateway(TestFirewallRule._client)
gateway_obj = Gateway(
TestFirewallRule._client, href=gateway_res.get('href'))
firewall_rules = gateway_obj.get_firewall_rules()
for rule in firewall_rules.firewallRules.firewallRule:
if rule.name == TestFirewallRule.__firewall_rule_name:
TestFirewallRule._rule_id = rule.id
break
示例3: test_0030_update_static_routes
def test_0030_update_static_routes(self):
"""Update a static route.
Invokes the update_static_route of the StaticRoute.
"""
static_object = StaticRoute(
TestStaticRoute._client,
TestStaticRoute._name,
TestStaticRoute._network_id)
static_object.update_static_route(
next_hop=TestStaticRoute._new_next_hop,
mtu=TestStaticRoute._new_mtu,
description=TestStaticRoute._new_desc)
gateway = Environment. \
get_test_gateway(TestStaticRoute._client)
gateway_obj = Gateway(TestStaticRoute._client,
TestStaticRoute._name,
href=gateway.get('href'))
static_route = gateway_obj.get_static_routes()
# Verify
match_found = False
for route in static_route.staticRoutes.route:
if route.nextHop == TestStaticRoute._new_next_hop and \
route.mtu == TestStaticRoute._new_mtu and \
route.description == TestStaticRoute._new_desc:
match_found = True
break
self.assertTrue(match_found)
示例4: test_0055_edit_rate_limit
def test_0055_edit_rate_limit(self):
"""Edits existing rate limit of gateway.
Invokes the edit_rate_limits of the gateway.
"""
gateway_obj = Gateway(TestGateway._client, self._name,
TestGateway._gateway.get('href'))
ip_allocations = gateway_obj.list_configure_ip_settings()
ip_allocation = ip_allocations[0]
ext_network = ip_allocation.get('external_network')
config = dict()
config[ext_network] = [self._rate_limit_start, self._rate_limit_end]
task = gateway_obj.edit_rate_limits(config)
result = TestGateway._client.get_task_monitor().wait_for_success(
task=task)
self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)
gateway_obj = Gateway(TestGateway._client, self._name,
TestGateway._gateway.get('href'))
for gateway_inf in \
gateway_obj.get_resource()\
.Configuration.GatewayInterfaces.GatewayInterface:
if gateway_inf.Name == ext_network:
self.assertEqual(self._rate_limit_start,
gateway_inf.InRateLimit.text)
self.assertEqual(self._rate_limit_end,
gateway_inf.OutRateLimit.text)
示例5: test_0030_update_nat_rule
def test_0030_update_nat_rule(self):
"""Update a Nat Rule.
Invokes the update_nat_rule of the NatRule.
"""
gateway = Environment. \
get_test_gateway(TestNatRule._client)
gateway_obj = Gateway(TestNatRule._client,
TestNatRule._name,
href=gateway.get('href'))
nat_rule = gateway_obj.get_nat_rules()
rule_id = self.__get_snat_rule_id(nat_rule)
nat_obj = NatRule(TestNatRule._client, self._name, rule_id)
nat_obj.update_nat_rule(
original_address=TestNatRule._new_snat_orig_addr,
translated_address=TestNatRule._new_snat_trans_addr,
description=TestNatRule._new_snat_desc)
#Verify
nat_rule = gateway_obj.get_nat_rules()
match_found = False
for natRule in nat_rule.natRules.natRule:
if natRule.originalAddress == TestNatRule._new_snat_orig_addr and \
natRule.translatedAddress == TestNatRule._new_snat_trans_addr and \
natRule.description == TestNatRule._new_snat_desc:
match_found = True
self.assertTrue(match_found)
示例6: test_0050_remove_sub_allocated_ip_pools
def test_0050_remove_sub_allocated_ip_pools(self):
"""Remove the sub allocated ip pools of gateway.
Invokes the remove_sub_allocated_ip_pools of the gateway.
"""
gateway_obj = Gateway(TestGateway._client, self._name,
TestGateway._gateway.get('href'))
ip_allocations = gateway_obj.list_configure_ip_settings()
ip_allocation = ip_allocations[0]
ext_network = ip_allocation.get('external_network')
config = TestGateway._config['external_network']
gateway_sub_allocated_ip_range1 = \
config['new_gateway_sub_allocated_ip_range']
task = gateway_obj.remove_sub_allocated_ip_pools(
ext_network, [gateway_sub_allocated_ip_range1])
result = TestGateway._client.get_task_monitor().wait_for_success(
task=task)
self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)
gateway_obj = Gateway(TestGateway._client, self._name,
TestGateway._gateway.get('href'))
subnet_participation = self.__get_subnet_participation(
gateway_obj.get_resource(), ext_network)
"""removed the IpRanges form subnet_participation."""
is_ip_range_found = False
if hasattr(subnet_participation, 'IpRanges'):
for ip_range in subnet_participation.IpRanges.IpRange:
if gateway_sub_allocated_ip_range1 == \
ip_range.StartAddress.text+'-'+ip_range.EndAddress\
.text:
is_ip_range_found = True
break
self.assertFalse(is_ip_range_found)
示例7: test_0085_list_configure_default_gateway
def test_0085_list_configure_default_gateway(self):
"""list configured default gateway.
Invoke the list_configure_default_gateway function of gateway.
"""
gateway_obj = Gateway(TestGateway._client, self._name,
TestGateway._gateway.get('href'))
default_gateways = gateway_obj.list_configure_default_gateway()
self.assertTrue(len(default_gateways) > 0)
示例8: __remove_sub_allocate_ip_pool
def __remove_sub_allocate_ip_pool(self):
gateway = Environment. \
get_test_gateway(TestExtNet._sys_admin_client)
gateway_obj = Gateway(TestExtNet._sys_admin_client,
href=gateway.get('href'))
ext_net = TestExtNet._config['external_network']['name']
task = gateway_obj.remove_sub_allocated_ip_pools(
ext_net, [TestExtNet._gateway_sub_allocate_ip_pool_range])
TestExtNet._sys_admin_client.get_task_monitor(). \
wait_for_success(task=task)
示例9: test_0060_list_syslog_settings
def test_0060_list_syslog_settings(self):
"""List Tenant syslog server of the gateway.
Invoke the list_syslog_server_ip function of gateway.
"""
for client in (TestGateway._client, TestGateway._org_client):
gateway_obj = Gateway(client, self._name,
TestGateway._gateway.get('href'))
tenant_syslog_server = gateway_obj.list_syslog_server_ip()
self.assertGreaterEqual(len(tenant_syslog_server), 1)
示例10: test_0004_list_external_network_ip_allocations
def test_0004_list_external_network_ip_allocations(self):
"""List external network ip allocations.
Invoke the list_external_network_ip_allocations of the gateway.
"""
for client in (TestGateway._client, TestGateway._org_client):
gateway_obj = Gateway(client, self._name,
TestGateway._gateway.get('href'))
ip_allocations = gateway_obj.list_external_network_ip_allocations()
self.assertTrue(bool(ip_allocations))
示例11: test_0065_list_rate_limit
def test_0065_list_rate_limit(self):
"""List rate limit of the gateway.
Invoke the list_rate_limits function of gateway.
"""
for client in (TestGateway._client, TestGateway._org_client):
gateway_obj = Gateway(client, self._name,
TestGateway._gateway.get('href'))
rate_limit = gateway_obj.list_rate_limits()
self.assertTrue(len(rate_limit) > 0)
示例12: test_0002_enable_dr
def test_0002_enable_dr(self):
"""Enable the Distributed routing.
Invoke the enable_distributed_routing method for the gateway.
"""
gateway_obj = Gateway(TestGateway._client, self._name,
TestGateway._gateway.get('href'))
task = gateway_obj.enable_distributed_routing(True)
result = TestGateway._client.get_task_monitor().wait_for_success(
task=task)
self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)
示例13: test_0006_sync_syslog_settings
def test_0006_sync_syslog_settings(self):
"""Sync syslog settings of the gateway.
Invoke the sync_syslog_settings function of gateway.
"""
for client in (TestGateway._client, TestGateway._org_client):
gateway_obj = Gateway(client, self._name,
TestGateway._gateway.get('href'))
task = gateway_obj.sync_syslog_settings()
result = TestGateway._client.get_task_monitor().wait_for_success(
task=task)
self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)
示例14: test_0005_redeploy
def test_0005_redeploy(self):
"""Redeploy the gateway.
Invoke the redeploy function of gateway.
"""
for client in (TestGateway._client, TestGateway._org_client):
gateway_obj = Gateway(client, self._name,
TestGateway._gateway.get('href'))
task = gateway_obj.redeploy()
result = TestGateway._client.get_task_monitor().wait_for_success(
task=task)
self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)
示例15: test_0003_modify_form_factor
def test_0003_modify_form_factor(self):
"""Modify form factor.
Invoke the modify_form_factor method for the gateway.
"""
gateway_obj = Gateway(TestGateway._client, self._name,
TestGateway._gateway.get('href'))
task = gateway_obj.modify_form_factor(
GatewayBackingConfigType.FULL.value)
result = TestGateway._client.get_task_monitor().wait_for_success(
task=task)
self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)