本文整理汇总了Python中pyvcloud.system_test_framework.environment.Environment.get_sys_admin_client方法的典型用法代码示例。如果您正苦于以下问题:Python Environment.get_sys_admin_client方法的具体用法?Python Environment.get_sys_admin_client怎么用?Python Environment.get_sys_admin_client使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyvcloud.system_test_framework.environment.Environment
的用法示例。
在下文中一共展示了Environment.get_sys_admin_client方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_0000_setup
# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_sys_admin_client [as 别名]
def test_0000_setup(self):
"""Add Firewall Rules in the gateway.
Invokes the add_firewall_rule of the gateway.
"""
TestFirewallRules._org_client = Environment.get_client_in_default_org(
TestFirewallRules._test_runner_role)
TestFirewallRules._system_client = Environment.get_sys_admin_client()
TestFirewallRules._config = Environment.get_config()
gateway = Environment.get_test_gateway(TestFirewallRules._org_client)
TestFirewallRules._gateway_obj = Gateway(
TestFirewallRules._org_client,
TestFirewallRules._name,
href=gateway.get('href'))
TestFirewallRules._external_network = Environment. \
get_test_external_network(TestFirewallRules._system_client)
TestFirewallRules._gateway_obj.add_firewall_rule(
TestFirewallRules._firewall_rule_name)
firewall_rules_resource = \
TestFirewallRules._gateway_obj.get_firewall_rules()
# Verify
matchFound = False
for firewallRule in firewall_rules_resource.firewallRules.firewallRule:
if firewallRule['name'] == TestFirewallRules._firewall_rule_name:
TestFirewallRules._rule_id = firewallRule.id
matchFound = True
break
self.assertTrue(matchFound)
示例2: test_0000_setup
# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_sys_admin_client [as 别名]
def test_0000_setup(self):
"""Add the sub allocated ip pools to gateway.
This sub allocated ip pools required by the Nat Rule
Invokes the add_sub_allocated_ip_pools of the gateway.
"""
TestNatRule._client = Environment.get_sys_admin_client()
TestNatRule._config = Environment.get_config()
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_range = \
config['gateway_sub_allocated_ip_range']
ip_range_list = [gateway_sub_allocated_ip_range]
task = gateway_obj.add_sub_allocated_ip_pools(ext_network,
ip_range_list)
result = TestNatRule._client.get_task_monitor().wait_for_success(
task=task)
self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)
gateway_obj = Gateway(TestNatRule._client,
TestNatRule._name,
href=gateway.get('href'))
subnet_participation = self.__get_subnet_participation(
gateway_obj.get_resource(), ext_network)
ip_ranges = gateway_obj.get_sub_allocate_ip_ranges_element(
subnet_participation)
self.__validate_ip_range(ip_ranges, gateway_sub_allocated_ip_range)
示例3: test_0010_find_existing_with_admin
# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_sys_admin_client [as 别名]
def test_0010_find_existing_with_admin(self):
"""Find entities with admin account with optional filter parameters."""
self._client = Environment.get_sys_admin_client()
resource_type_cc = 'organization'
# Fetch all orgs.
q1 = self._client.get_typed_query(
resource_type_cc,
query_result_format=QueryResultFormat.ID_RECORDS,
qfilter=None)
q1_records = list(q1.execute())
self.assertTrue(
len(q1_records) > 0,
msg="Find at least one organization")
name0 = q1_records[0].get('name')
# Find the org again using an equality filter.
eq_filter = ('name', name0)
q2 = self._client.get_typed_query(
resource_type_cc,
query_result_format=QueryResultFormat.ID_RECORDS,
equality_filter=eq_filter)
q2_records = list(q2.execute())
self.assertEqual(
1, len(q2_records),
msg="Find org with equality filter")
# Find the org again using a query filter string
q3 = self._client.get_typed_query(
resource_type_cc,
query_result_format=QueryResultFormat.ID_RECORDS,
qfilter="name=={0}".format(name0))
q3_records = list(q3.execute())
self.assertEqual(1, len(q3_records),
msg="Find org with query filter")
示例4: test_0000_setup
# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_sys_admin_client [as 别名]
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
示例5: test_0000_setup
# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_sys_admin_client [as 别名]
def test_0000_setup(self):
TestVappFirewall._client = Environment.get_sys_admin_client()
vapp = Environment.get_test_vapp_with_network(TestVappFirewall._client)
vapp.reload()
TestVappFirewall._network_name = \
Environment.get_default_orgvdc_network_name()
task = vapp.connect_org_vdc_network(
TestVappFirewall._network_name,
fence_mode=FenceMode.NAT_ROUTED.value)
result = TestVappFirewall._client.get_task_monitor().wait_for_success(
task)
self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)
示例6: test_0000_setup
# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_sys_admin_client [as 别名]
def test_0000_setup(self):
TestCaCertificates._client = Environment.get_sys_admin_client()
TestCaCertificates._config = Environment.get_config()
TestCaCertificates._org = Environment.get_test_org(
TestCaCertificates._client)
test_gateway = Environment.get_test_gateway(TestCaCertificates._client)
gateway_obj1 = Gateway(TestCaCertificates._client, GatewayConstants.name,
href=test_gateway.get('href'))
TestCaCertificates.gateway_obj = gateway_obj1
TestCaCertificates._runner = CliRunner()
default_org = self._config['vcd']['default_org_name']
self._login()
TestCaCertificates._runner.invoke(org, ['use', default_org])
示例7: test_0000_setup
# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_sys_admin_client [as 别名]
def test_0000_setup(self):
# TODO(): need more pipeline work before this test can actually be run
TestVC._client = Environment.get_sys_admin_client()
TestVC._config = Environment.get_config()
TestVC._vcenter_host_name = self._config['vc']['vcenter_host_name']
TestVC._vcenter_invalid = 'xyz'
TestVC._vcServerName = self._config['vc']['vcServerName']
TestVC._vcServerHost = self._config['vc']['vcServerHost']
TestVC._vcAdminUser = self._config['vc']['vcAdminUser']
TestVC._vcAdminPwd = self._config['vc']['vcAdminPwd']
TestVC._NSXServerName = self._config['vc']['NSXServerName']
TestVC._NSXHost = self._config['vc']['NSXHost']
TestVC._NSXAdminUser = self._config['vc']['NSXAdminUser']
TestVC._NSXAdminPwd = self._config['vc']['NSXAdminPwd']
TestVC._isEnabled = False
示例8: test_0050_check_all_resource_types
# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_sys_admin_client [as 别名]
def test_0050_check_all_resource_types(self):
"""Verify that we can search on any resource type without error."""
self._client = Environment.get_sys_admin_client()
api_version = float(self._client.get_api_version())
# only admin version visible to sys admin in /api/query
allowed_exceptions = [
ResourceType.ALLOCATED_EXTERNAL_ADDRESS,
ResourceType.CATALOG_ITEM,
ResourceType.DISK,
ResourceType.GROUP,
ResourceType.ORG_NETWORK,
ResourceType.ORG_VDC_STORAGE_PROFILE,
ResourceType.USER,
ResourceType.VAPP_NETWORK,
ResourceType.VM_DISK_RELATION]
if api_version < 30.0:
# links added in api v30.0
allowed_exceptions.append(ResourceType.CATALOG)
allowed_exceptions.append(ResourceType.MEDIA)
allowed_exceptions.append(ResourceType.ORG_VDC)
allowed_exceptions.append(ResourceType.VAPP)
allowed_exceptions.append(ResourceType.VAPP_TEMPLATE)
allowed_exceptions.append(ResourceType.VM)
else:
# features deprecated in api v30.0
allowed_exceptions.append(
ResourceType.ADMIN_ORG_NETWORK)
allowed_exceptions.append(
ResourceType.ADMIN_ALLOCATED_EXTERNAL_ADDRESS)
if api_version < 31.0:
# feature introduced in api v31.0
allowed_exceptions.append(ResourceType.NSXT_MANAGER)
resource_types = [r.value for r in ResourceType
if r not in allowed_exceptions]
# All typed queries apart from the allowed_exceptions shouldn't fail.
for resource_type in resource_types:
q1 = self._client.get_typed_query(
resource_type,
query_result_format=QueryResultFormat.ID_RECORDS)
q1_records = list(q1.execute())
self.assertTrue(
len(q1_records) >= 0,
"Should get a list, even if empty")
示例9: test_0041_detach_port_group
# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_sys_admin_client [as 别名]
def test_0041_detach_port_group(self):
"""Detach port group from an external network.
Invoke the command 'external detach-port-group' in network.
"""
if ExtNetTest._vc2_host_ip is None or ExtNetTest._vc2_host_ip == '':
return
ExtNetTest._client = Environment.get_sys_admin_client()
port_group_helper = PortgroupHelper(ExtNetTest._client)
vc_name = self._config['vc2']['vcenter_host_name']
pg_name = port_group_helper. \
get_ext_net_used_portgroup_name(vc_name, self._name)
result = self._runner.invoke(
external,
args=[
'detach-port-group', self._name, '--vc', vc_name,
'--port-group', pg_name
])
self.assertEqual(0, result.exit_code)
示例10: test_0100_add_dhcp_pool
# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_sys_admin_client [as 别名]
def test_0100_add_dhcp_pool(self):
"""Add DHCP pool in the gateway.
Invokes the add_dhcp_pool of the gateway.
"""
gateway_obj = Gateway(
TestGateway._client, self._name,
Environment.get_test_gateway(Environment.get_sys_admin_client())
.get('href'))
gateway_obj.add_dhcp_pool(TestGateway._pool_ip_range)
dhcp_resource = gateway_obj.get_dhcp()
# Verify
matchFound = False
for ipPool in dhcp_resource.ipPools.ipPool:
if ipPool.ipRange.text == TestGateway._pool_ip_range:
matchFound = True
break
self.assertTrue(matchFound)
示例11: test_0000_setup
# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_sys_admin_client [as 别名]
def test_0000_setup(self):
"""Setup the vms required for the other tests in this module.
Create a vApp with just one vm as per the configuration stated above.
This test passes if the vApp and vm hrefs are not None.
"""
logger = Environment.get_default_logger()
TestVM._client = Environment.get_client_in_default_org(
TestVM._test_runner_role)
TestVM._sys_admin_client = Environment.get_sys_admin_client()
vdc = Environment.get_test_vdc(TestVM._client)
TestVM._media_resource = Environment.get_test_media_resource()
logger.debug('Creating vApp ' + TestVM._test_vapp_name + '.')
TestVM._test_vapp_href = create_customized_vapp_from_template(
client=TestVM._client,
vdc=vdc,
name=TestVM._test_vapp_name,
catalog_name=Environment.get_default_catalog_name(),
template_name=Environment.get_default_template_name(),
memory_size=TestVM._test_vapp_first_vm_memory_size,
num_cpu=TestVM._test_vapp_first_vm_num_cpu,
disk_size=TestVM._test_vapp_first_vm_first_disk_size,
vm_name=TestVM._test_vapp_first_vm_name,
nw_adapter_type=TestVM._test_vapp_first_vm_network_adapter_type)
self.assertIsNotNone(TestVM._test_vapp_href)
vapp = VApp(TestVM._client, href=TestVM._test_vapp_href)
vm_resource = vapp.get_vm(TestVM._test_vapp_first_vm_name)
TestVM._test_vapp_first_vm_href = vm_resource.get('href')
self.assertIsNotNone(TestVM._test_vapp_first_vm_href)
logger.debug('Creating empty vApp.')
TestVM._empty_vapp_href = \
create_empty_vapp(client=TestVM._client,
vdc=vdc,
name=TestVM._empty_vapp_name,
description=TestVM._empty_vapp_description)
TestVM._empty_vapp_owner_name = Environment. \
get_username_for_role_in_test_org(TestVM._test_runner_role)
示例12: test_cleanup
# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_sys_admin_client [as 别名]
def test_cleanup(self):
"""Get the test Org and delete it."""
client = None
try:
logger = Environment.get_default_logger()
client = Environment.get_sys_admin_client()
test_org = Environment.get_test_org(client)
logger.debug('Deleting test org: {0}'.format(test_org.get_name()))
sys_admin_resource = client.get_admin()
system = System(client, admin_resource=sys_admin_resource)
task = system.delete_org(test_org.get_name(), True, True)
# Track the task to completion.
result = client.get_task_monitor().wait_for_success(task)
self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)
finally:
if client is not None:
client.logout()
示例13: test_0000_setup
# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_sys_admin_client [as 别名]
def test_0000_setup(self):
"""Add one orgvdc, one gateways and one routed orgvdc networks.
"""
TestIpSecVpn._client = Environment.get_sys_admin_client()
TestIpSecVpn._logger = Environment.get_default_logger()
TestIpSecVpn._config = Environment.get_config()
TestIpSecVpn._org = Environment.get_test_org(TestIpSecVpn._client)
TestIpSecVpn._pvdc_name = Environment.get_test_pvdc_name()
TestIpSecVpn._ext_config = TestIpSecVpn._config['external_network']
TestIpSecVpn._ext_net_name = TestIpSecVpn._ext_config['name']
# Create another vdc, gateway and routed network
self.__create_ovdc()
self.__create_advanced_gateway()
self.__create_routed_ovdc_network()
test_gateway = Environment.get_test_gateway(TestIpSecVpn._client)
gateway_obj1 = Gateway(TestIpSecVpn._client, GatewayConstants.name,
href=test_gateway.get('href'))
gateway_obj2 = TestIpSecVpn._gateway_obj
TestIpSecVpn._local_ip = self.__get_ip_address(
gateway=gateway_obj1, ext_net_name=TestIpSecVpn._ext_net_name)
TestIpSecVpn._peer_ip = self.__get_ip_address(
gateway=gateway_obj2, ext_net_name=TestIpSecVpn._ext_net_name)
TestIpSecVpn._runner = CliRunner()
default_org = self._config['vcd']['default_org_name']
self._login()
TestIpSecVpn._runner.invoke(org, ['use', default_org])
result = TestIpSecVpn._runner.invoke(
gateway,
args=[
'services', 'ipsec-vpn', 'create', TestIpSecVpn._name,
'--name', TestIpSecVpn._ipsec_vpn_name,
'--local-id', TestIpSecVpn._local_id,
'--peer-id', TestIpSecVpn._peer_id,
'--local-ip', TestIpSecVpn._local_ip,
'--peer-ip', TestIpSecVpn._peer_ip,
'--local-subnet', TestIpSecVpn._local_subnet,
'--peer-subnet', TestIpSecVpn._peer_subnet,
'--pre-shared-key', TestIpSecVpn._psk, '--enable'])
self.assertEqual(0, result.exit_code)
示例14: test_0000_setup
# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_sys_admin_client [as 别名]
def test_0000_setup(self):
"""Setup the org vdc required for the other tests in this module.
Create one org vdc as per the configuration stated above. Test the
method Org.create_org_vdc().
This test passes if the vdc href is not None.
"""
logger = Environment.get_default_logger()
TestOrgVDC._client = Environment.get_sys_admin_client()
org = Environment.get_test_org(TestOrgVDC._client)
vdc_name = TestOrgVDC._new_vdc_name
pvdc_name = Environment.get_test_pvdc_name()
storage_profiles = [{
'name': '*',
'enabled': True,
'units': 'MB',
'limit': 0,
'default': True
}]
vdc_resource = org.create_org_vdc(
vdc_name,
pvdc_name,
storage_profiles=storage_profiles,
uses_fast_provisioning=True,
is_thin_provision=True)
TestOrgVDC._client.get_task_monitor().wait_for_success(
task=vdc_resource.Tasks.Task[0])
logger.debug('Created ovdc ' + vdc_name + '.')
# The following contraption is required to get the non admin href of
# the ovdc. vdc_resource contains the admin version of the href since
# we created the ovdc as a sys admin.
org.reload()
for vdc in org.list_vdcs():
if vdc.get('name').lower() == vdc_name.lower():
TestOrgVDC._new_vdc_href = vdc.get('href')
self.assertIsNotNone(TestOrgVDC._new_vdc_href)
示例15: test_0000_setup
# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_sys_admin_client [as 别名]
def test_0000_setup(self):
"""
Create one external network as per the configuration stated aboveself.
Choose first unused port group which is not a VxLAN. Unused port groups
have network names set to '--'. VxLAN port groups have name starting
with 'vxw-'.
Test the method Platform.create_external_network().
This test passes if external network is created successfully.
"""
logger = Environment.get_default_logger()
TestExtNet._sys_admin_client = Environment.get_sys_admin_client()
TestExtNet._config = Environment.get_config()
TestExtNet._common_ext_net_name = TestExtNet._config[
'external_network']['name']
platform = Platform(TestExtNet._sys_admin_client)
vc_name = TestExtNet._config['vc']['vcenter_host_name']
TestExtNet._vc2_host_ip = TestExtNet._config['vc2']['vcenter_host_ip']
portgrouphelper = PortgroupHelper(TestExtNet._sys_admin_client)
pg_name = portgrouphelper.get_available_portgroup_name(
vc_name, TestExtNet._portgroupType)
ext_net = platform.create_external_network(
name=TestExtNet._name,
vim_server_name=vc_name,
port_group_names=[pg_name],
gateway_ip=TestExtNet._gateway,
netmask=TestExtNet._netmask,
ip_ranges=[TestExtNet._ip_range],
description=TestExtNet._description,
primary_dns_ip=TestExtNet._dns1,
secondary_dns_ip=TestExtNet._dns2,
dns_suffix=TestExtNet._dns_suffix)
task = ext_net['{' + NSMAP['vcloud'] + '}Tasks'].Task[0]
TestExtNet._sys_admin_client.get_task_monitor().wait_for_success(
task=task)
logger.debug('Created external network ' + TestExtNet._name + '.')