本文整理汇总了Python中pyvcloud.system_test_framework.environment.Environment.get_client_in_default_org方法的典型用法代码示例。如果您正苦于以下问题:Python Environment.get_client_in_default_org方法的具体用法?Python Environment.get_client_in_default_org怎么用?Python Environment.get_client_in_default_org使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyvcloud.system_test_framework.environment.Environment
的用法示例。
在下文中一共展示了Environment.get_client_in_default_org方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_0000_setup
# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_client_in_default_org [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_0010_vm_setup
# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_client_in_default_org [as 别名]
def test_0010_vm_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()
TestPVDC._org_client = Environment.get_client_in_default_org(
TestPVDC._test_runner_role)
vdc = Environment.get_test_vdc(TestPVDC._org_client)
logger.debug('Creating vApp ' + TestPVDC._test_vapp_name + '.')
TestPVDC._test_vapp_href = create_customized_vapp_from_template(
client=TestPVDC._org_client,
vdc=vdc,
name=TestPVDC._test_vapp_name,
catalog_name=Environment.get_default_catalog_name(),
template_name=Environment.get_default_template_name(),
memory_size=TestPVDC._test_vapp_first_vm_memory_size,
num_cpu=TestPVDC._test_vapp_first_vm_num_cpu,
disk_size=TestPVDC._test_vapp_first_vm_first_disk_size,
vm_name=TestPVDC._test_vapp_first_vm_name,
nw_adapter_type=TestPVDC._test_vapp_first_vm_network_adapter_type)
self.assertIsNotNone(TestPVDC._test_vapp_href)
vapp = VApp(TestPVDC._org_client, href=TestPVDC._test_vapp_href)
vm_resource = vapp.get_vm(TestPVDC._test_vapp_first_vm_name)
TestPVDC._test_vapp_first_vm_href = vm_resource.get('href')
self.assertIsNotNone(TestPVDC._test_vapp_first_vm_href)
示例3: test_0020_find_existing_entities_with_org_user
# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_client_in_default_org [as 别名]
def test_0020_find_existing_entities_with_org_user(self):
"""Find entities with low-privilege org user."""
self._client = Environment.get_client_in_default_org(
CommonRoles.VAPP_USER)
q1 = self._client.get_typed_query(
ResourceType.CATALOG.value,
query_result_format=QueryResultFormat.ID_RECORDS)
q1_records = list(q1.execute())
self.assertTrue(len(q1_records) > 0,
msg="Find at least one catalog item")
示例4: test_0040_find_unsupported_type
# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_client_in_default_org [as 别名]
def test_0040_find_unsupported_type(self):
"""Verify we raise appropriate exception if user can't see entities."""
self._client = Environment.get_client_in_default_org(
CommonRoles.VAPP_USER)
for format in self._result_formats:
try:
q1 = self._client.get_typed_query(
ResourceType.ORGANIZATION.value,
query_result_format=QueryResultFormat.ID_RECORDS)
q1.execute()
self.fail('User (vApp user) should not be able to fetch any '
'orgs.')
except OperationNotSupportedException as e:
pass
示例5: test_0000_setup
# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_client_in_default_org [as 别名]
def test_0000_setup(self):
"""Setup the networks required for the other tests in this module.
Create an isolated org vdc network as per the configuration stated
above.
This test passes if the isolated orgvdc network is created
successfully.
"""
logger = Environment.get_default_logger()
TestNetwork._client = Environment.get_client_in_default_org(
TestNetwork._test_runner_role)
TestNetwork._system_client = Environment.get_sys_admin_client()
TestNetwork._vapp_author_client = \
Environment.get_client_in_default_org(CommonRoles.VAPP_AUTHOR)
vdc = Environment.get_test_vdc(TestNetwork._client)
logger.debug('Creating isolated orgvdc network : ' +
TestNetwork._isolated_orgvdc_network_name)
result = vdc.create_isolated_vdc_network(
network_name=TestNetwork._isolated_orgvdc_network_name,
network_cidr=TestNetwork._isolated_orgvdc_network_gateway_ip)
TestNetwork._client.get_task_monitor().wait_for_success(
task=result.Tasks.Task[0])
示例6: test_0000_setup
# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_client_in_default_org [as 别名]
def test_0000_setup(self):
"""Load configuration and create a click runner to invoke CLI."""
VmTest._config = Environment.get_config()
VmTest._logger = Environment.get_default_logger()
VmTest._client = Environment.get_client_in_default_org(
CommonRoles.ORGANIZATION_ADMINISTRATOR)
VmTest._media_resource = Environment.get_test_media_resource()
VmTest._runner = CliRunner()
default_org = VmTest._config['vcd']['default_org_name']
VmTest._login(self)
VmTest._runner.invoke(org, ['use', default_org])
VmTest._test_vdc = Environment.get_test_vdc(VmTest._client)
VmTest._test_vapp = Environment.get_test_vapp_with_network(
VmTest._client)
VmTest._test_vm = VM(
VmTest._client,
href=VmTest._test_vapp.get_vm(VAppConstants.vm1_name).get('href'))
示例7: test_0030_find_non_existing
# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_client_in_default_org [as 别名]
def test_0030_find_non_existing(self):
"""Verify we return nothing if no entities exist."""
self._client = Environment.get_client_in_default_org(
CommonRoles.VAPP_USER)
for format in self._result_formats:
q1 = self._client.get_typed_query(
ResourceType.CATALOG.value,
query_result_format=QueryResultFormat.ID_RECORDS,
qfilter='name==invalid_catalog_name')
count = 0
for item in q1.execute():
count += 1
self.assertEqual(0, count, "Should not find invalid catalog via "
"generator.")
# Try a list.
q1_records = list(q1.execute())
self.assertEqual(0, len(q1_records),
"Should not find invalid catalog via list.")
示例8: test_0000_setup
# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_client_in_default_org [as 别名]
def test_0000_setup(self):
"""Setup the vApps required for the other tests in this module.
Create two vApps as per the configuration stated above.
This test passes if the two vApp hrefs are not None.
"""
logger = Environment.get_default_logger()
TestVApp._client = Environment.get_client_in_default_org(
TestVApp._test_runner_role)
TestVApp._sys_admin_client = Environment.get_sys_admin_client()
vdc = Environment.get_test_vdc(TestVApp._client)
logger.debug('Creating empty vApp.')
TestVApp._empty_vapp_href = \
create_empty_vapp(client=TestVApp._client,
vdc=vdc,
name=TestVApp._empty_vapp_name,
description=TestVApp._empty_vapp_description)
TestVApp._empty_vapp_owner_name = Environment.\
get_username_for_role_in_test_org(TestVApp._test_runner_role)
logger.debug('Creating customized vApp.')
TestVApp._customized_vapp_href = create_customized_vapp_from_template(
client=TestVApp._client,
vdc=vdc,
name=TestVApp._customized_vapp_name,
catalog_name=Environment.get_default_catalog_name(),
template_name=Environment.get_default_template_name(),
description=TestVApp._customized_vapp_description,
memory_size=TestVApp._customized_vapp_memory_size,
num_cpu=TestVApp._customized_vapp_num_cpu,
disk_size=TestVApp._customized_vapp_disk_size,
vm_name=TestVApp._customized_vapp_vm_name,
vm_hostname=TestVApp._customized_vapp_vm_hostname,
nw_adapter_type=TestVApp._customized_vapp_vm_network_adapter_type)
TestVApp._customized_vapp_owner_name = Environment.\
get_username_for_role_in_test_org(TestVApp._test_runner_role)
self.assertIsNotNone(TestVApp._empty_vapp_href)
self.assertIsNotNone(TestVApp._customized_vapp_href)
示例9: test_0080_change_catalog_ownership
# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_client_in_default_org [as 别名]
def test_0080_change_catalog_ownership(self):
"""Test the method org.change_catalog_owner().
Change the ownership of the catalog to org administrator and back to
the original owner.
This test passes if the catalog owner change operation succeeds without
raising any errors. And the new owner is able to access the catalog.
"""
logger = Environment.get_default_logger()
org_admin_client = Environment.get_client_in_default_org(
CommonRoles.ORGANIZATION_ADMINISTRATOR)
org = Environment.get_test_org(org_admin_client)
catalog_name = TestCatalog._test_catalog_name
original_owner_username = \
Environment.get_username_for_role_in_test_org(
TestCatalog._test_runner_role)
org_admin_username = Environment.get_username_for_role_in_test_org(
CommonRoles.ORGANIZATION_ADMINISTRATOR)
try:
logger.debug('Changing owner of catalog:' + catalog_name +
' to ' + org_admin_username)
org.change_catalog_owner(catalog_name, org_admin_username)
catalog_admin_resource = org.get_catalog(catalog_name,
is_admin_operation=True)
self.assertEqual(catalog_admin_resource.Owner.User.get('name'),
org_admin_username)
logger.debug('Changing owner of catalog ' + catalog_name +
' back to ' + original_owner_username)
org.change_catalog_owner(catalog_name, original_owner_username)
catalog_admin_resource = org.get_catalog(catalog_name,
is_admin_operation=True)
self.assertEqual(catalog_admin_resource.Owner.User.get('name'),
original_owner_username)
finally:
org_admin_client.logout()
示例10: test_0000_setup
# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_client_in_default_org [as 别名]
def test_0000_setup(self):
"""Load configuration and create a click runner to invoke CLI."""
VAppTest._config = Environment.get_config()
VAppTest._logger = Environment.get_default_logger()
VAppTest._client = Environment.get_client_in_default_org(
CommonRoles.ORGANIZATION_ADMINISTRATOR)
VAppTest._runner = CliRunner()
default_org = VAppTest._config['vcd']['default_org_name']
VAppTest._default_org = default_org
VAppTest._login(self)
VAppTest._runner.invoke(org, ['use', default_org])
VAppTest._test_vdc = Environment.get_test_vdc(VAppTest._client)
VAppTest._test_vapp = create_vapp_from_template(
VAppTest._client,
VAppTest._test_vdc,
VAppTest._test_vapp_name,
VAppTest._config['vcd']['default_catalog_name'],
VAppTest._config['vcd']['default_template_file_name'],
power_on=False,
deploy=False)
VAppTest._catalog_name = VAppTest._config['vcd'][
'default_catalog_name']
示例11: test_0000_setup
# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_client_in_default_org [as 别名]
def test_0000_setup(self):
"""Setup a catalog for the tests in this module.
Create a catalog. Test org.create_catalog() function.
This test passes if the catalog is created successfully.
"""
logger = Environment.get_default_logger()
TestCatalog._client = Environment.get_client_in_default_org(
TestCatalog._test_runner_role)
org = Environment.get_test_org(TestCatalog._client)
try:
catalog_resource = org.get_catalog(TestCatalog._test_catalog_name)
logger.debug('Reusing test catalog.')
except EntityNotFoundException as e:
catalog_resource = org.create_catalog(
TestCatalog._test_catalog_name,
TestCatalog._test_catalog_description)
TestCatalog._client.get_task_monitor().wait_for_success(
task=catalog_resource.Tasks.Task[0])
TestCatalog._test_catalog_href = catalog_resource.get('href')
self.assertIsNotNone(TestCatalog._test_catalog_href)
示例12: test_0090_change_vapp_owner
# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_client_in_default_org [as 别名]
def test_0090_change_vapp_owner(self):
"""Test the method vapp.change_owner().
This test passes if the owner of the vApp is successfuly changed to the
desired user.
"""
try:
logger = Environment.get_default_logger()
org_admin_client = Environment.get_client_in_default_org(
CommonRoles.ORGANIZATION_ADMINISTRATOR)
vapp_name = TestVApp._empty_vapp_name
vapp = Environment.get_vapp_in_test_vdc(
client=org_admin_client, vapp_name=vapp_name)
vapp_user_name = Environment.get_username_for_role_in_test_org(
CommonRoles.VAPP_USER)
vapp_user_href = Environment.get_user_href_in_test_org(
vapp_user_name)
logger.debug('Changing owner of vApp ' + vapp_name + ' to ' +
vapp_user_name)
vapp.change_owner(vapp_user_href)
vapp.reload()
self.assertEqual(vapp.get_resource().Owner.User.get('name'),
vapp_user_name)
logger.debug('Changing owner of vApp ' + vapp_name + ' back to ' +
TestVApp._empty_vapp_owner_name)
original_owner_href = Environment.get_user_href_in_test_org(
TestVApp._empty_vapp_owner_name)
vapp.change_owner(original_owner_href)
vapp.reload()
self.assertEqual(vapp.get_resource().Owner.User.get('name'),
TestVApp._empty_vapp_owner_name)
finally:
org_admin_client.logout()
示例13: test_9998_teardown
# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_client_in_default_org [as 别名]
def test_9998_teardown(self):
"""Test the method delete_catalog_item() and delete_catalog().
Invoke the methods for templates and catalogs created by setup. This
test should be run as org admin, since a failure in any of the previous
tests might leave the catalog stranded with an user other than the one
who created the catalog in first place.
This test passes if none of the delete operations generate any
exceptions.
"""
try:
org_admin_client = Environment.get_client_in_default_org(
CommonRoles.ORGANIZATION_ADMINISTRATOR)
org = Environment.get_test_org(org_admin_client)
logger = Environment.get_default_logger()
catalog_name = TestCatalog._test_catalog_name
items_to_delete = [
TestCatalog._test_template_name,
TestCatalog._test_template_with_chunk_size_name
]
for item in items_to_delete:
logger.debug('Deleting catalog item : ' + item)
try:
org.delete_catalog_item(catalog_name, item)
except EntityNotFoundException as e:
logger.debug('Catalog item:' + item + ' not found!')
try:
logger.debug('Deleting catalog : ' + catalog_name)
org.delete_catalog(catalog_name)
except EntityNotFoundException as e:
logger.debug('Catalog :' + catalog_name + ' not found!')
finally:
org_admin_client.logout()
示例14: test_0060_check_result_formats
# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_client_in_default_org [as 别名]
def test_0060_check_result_formats(self):
"""Verify we get expected results for all result formats."""
self._client = Environment.get_client_in_default_org(
CommonRoles.ORGANIZATION_ADMINISTRATOR)
for format in self._result_formats:
# Ensure format works with generator.
q1 = self._client.get_typed_query(
ResourceType.USER.value,
query_result_format=format)
count = 0
for result in q1.execute():
count += 1
self.assertTrue(
count >= 4,
"Expect at least 4 users from generator: {0}".format(format))
# Ensure format works with list built over generator.
q2 = self._client.get_typed_query(
ResourceType.USER.value,
query_result_format=format)
q2_result = list(q2.execute())
self.assertTrue(
len(q2_result) >= 4,
"Expect at least 4 users from list: {0}".format(format))
示例15: test_0060_vdc_metadata
# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_client_in_default_org [as 别名]
def test_0060_vdc_metadata(self):
"""Test the methods related to metadata manipulation in vdc.py.
This test passes if all the metadata operations are successful.
"""
vapp_author_client = None
sys_admin_client = None
try:
logger = Environment.get_default_logger()
vapp_author_client = Environment.get_client_in_default_org(
CommonRoles.VAPP_AUTHOR)
vdc_vapp_author_view = VDC(client=vapp_author_client,
href=TestOrgVDC._new_vdc_href)
sys_admin_client = Environment.get_sys_admin_client()
vdc_sys_admin_view = VDC(client=sys_admin_client,
href=TestOrgVDC._new_vdc_href)
# try to add new metadata as vapp author
try:
logger.debug(f'Adding metadata [key={TestOrgVDC._metadata_key}'
', value={TestOrgVDC._metadata_value}]) as vApp '
'author')
vdc_vapp_author_view.set_metadata(
key=TestOrgVDC._metadata_key,
value=TestOrgVDC._metadata_value)
self.assertFail('vApp author shouldn\'t have been able to '
'add new metadta entry.')
except OperationNotSupportedException as e:
pass
# add new metadata as sys admin
logger.debug(f'Adding metadata [key={TestOrgVDC._metadata_key},'
'value={TestOrgVDC._metadata_value}]) as Sys admin.')
task = vdc_sys_admin_view.set_metadata(
key=TestOrgVDC._metadata_key,
value=TestOrgVDC._metadata_value)
result = sys_admin_client.get_task_monitor().wait_for_success(task)
self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)
# retrieve metadata as vapp author
logger.debug(f'Retriving metadata with key='
'{TestOrgVDC._metadata_key} as vApp author.')
metadata_value = vdc_vapp_author_view.get_metadata_value(
key=TestOrgVDC._metadata_key)
self.assertEqual(extract_metadata_value(metadata_value),
TestOrgVDC._metadata_value)
# try to retrieve non existent metadata entry
try:
logger.debug(f'Retriving metadata with invalid key='
'{TestOrgVDC._non_existent_metadata_key} as vApp '
'author')
metadata_value = vdc_vapp_author_view.get_metadata_value(
key=TestOrgVDC._non_existent_metadata_key)
self.assertFail('Shouldn\'t have been able to retrieve metadta'
' entry with bad key.')
except AccessForbiddenException as e:
pass
# try to update metadata value as vapp author
try:
logger.debug(f'Trying to update metadata with key='
'{TestOrgVDC._metadata_key} to value='
'{TestOrgVDC._metadata_new_value} as vApp '
'author.')
vdc_vapp_author_view.set_metadata(
key=TestOrgVDC._metadata_key,
value=TestOrgVDC._metadata_new_value)
self.assertFail('Shouldn\'t have been able to update metadta'
' entry as vApp author.')
except OperationNotSupportedException as e:
pass
# update metadata value as sys admin
logger.debug(f'Updtaing metadata with key='
'{TestOrgVDC._metadata_key} to value='
'{TestOrgVDC._metadata_new_value} as Sys Admin.')
task = vdc_sys_admin_view.set_metadata(
key=TestOrgVDC._metadata_key,
value=TestOrgVDC._metadata_new_value)
sys_admin_client.get_task_monitor().wait_for_success(task)
metadata_value = vdc_sys_admin_view.get_metadata_value(
key=TestOrgVDC._metadata_key)
self.assertEqual(extract_metadata_value(metadata_value),
TestOrgVDC._metadata_new_value)
# try to remove metadata as vapp author
try:
logger.debug(f'Trying to remove metadata with key='
'{TestOrgVDC._metadata_key} as vApp author.')
task = vdc_vapp_author_view.remove_metadata(
key=TestOrgVDC._metadata_key)
self.assertFail('Shouldn\'t have been able to remove metadta '
'entry as vApp author.')
except OperationNotSupportedException as e:
pass
# remove metadata entry as sys admin
#.........这里部分代码省略.........