本文整理汇总了Python中pyvcloud.system_test_framework.environment.Environment.get_default_logger方法的典型用法代码示例。如果您正苦于以下问题:Python Environment.get_default_logger方法的具体用法?Python Environment.get_default_logger怎么用?Python Environment.get_default_logger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyvcloud.system_test_framework.environment.Environment
的用法示例。
在下文中一共展示了Environment.get_default_logger方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: wrapped_f
# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_default_logger [as 别名]
def wrapped_f(self):
is_execute_func = True
for func in args:
if not func(self):
is_execute_func = False
break
if is_execute_func:
function(self)
else:
Environment.get_default_logger().debug(
'Skipping ' + function.__name__ +
' due to depandancy failure.')
示例2: test_0000_setup
# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_default_logger [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
示例3: _template_upload_helper
# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_default_logger [as 别名]
def _template_upload_helper(self, org, catalog_name, template_name,
template_file_name):
"""Helper method to upload a template to a catalog in vCD.
This method creates the catalog item and uploads the template file
into the spool area(transfer folder) but it doesn't wait for the
import of the template as catalog item to finish.
:param pyvcloud.vcd.org.Org org: the organization which contains the
catalog to which the templates will be uploaded to.
:param str catalog_name: name of the catalog to which the template will
be uploaded to.
:param str template_name: name of the catalog item which represents the
uploaded template
:param str template_file_name: name of the local template file which
will be uploaded.
:raises: EntityNotFoundException: if the catalog is not found.
:raises: InternalServerException: if template already exists in vCD.
"""
bytes_uploaded = -1
logger = Environment.get_default_logger()
logger.debug('Uploading template : ' + template_name)
bytes_uploaded = org.upload_ovf(
catalog_name=catalog_name,
file_name=template_file_name,
item_name=template_name)
self.assertNotEqual(bytes_uploaded, -1)
示例4: test_0070_update_catalog
# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_default_logger [as 别名]
def test_0070_update_catalog(self):
"""Test the method org.update_catalog().
Update the name and description of the catalog created in
test_0000_setup. Revert the changes madeto the catalog after we verify
that the operation is successful.
This test passes if the catalog updation operation succeeds without
raising any errors.
"""
logger = Environment.get_default_logger()
org = Environment.get_test_org(TestCatalog._client)
catalog_name = TestCatalog._test_catalog_name
catalog_description = TestCatalog._test_catalog_description
new_name = TestCatalog._test_catalog_updated_name
new_description = TestCatalog._test_catalog_updated_description
logger.debug('Changing catalog:' + catalog_name + ' \'name\' to ' +
new_name + ', and \'description\' to ' + new_description)
updated_catalog_resource = org.update_catalog(catalog_name, new_name,
new_description)
self.assertEqual(updated_catalog_resource.get('name'), new_name)
self.assertEqual(updated_catalog_resource.Description.text,
new_description)
logger.debug('Changing catalog:' + new_name + ' \'name\' back to ' +
catalog_name + ',and \'description\' back to ' +
catalog_description)
org.reload()
org.update_catalog(new_name, catalog_name, catalog_description)
示例5: setUp
# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_default_logger [as 别名]
def setUp(self):
"""Load configuration and create a click runner to invoke CLI."""
self._config = Environment.get_config()
self._logger = Environment.get_default_logger()
self._runner = CliRunner()
self._login()
示例6: test_0010_vm_setup
# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_default_logger [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)
示例7: test_0070_vm_snapshot_operations
# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_default_logger [as 别名]
def test_0070_vm_snapshot_operations(self):
"""Test the method related to snapshot operations in vm.py.
This test passes if all the snapshot operations are successful.
"""
logger = Environment.get_default_logger()
vm_name = TestVM._test_vapp_first_vm_name
vm = VM(TestVM._client, href=TestVM._test_vapp_first_vm_href)
# VM.snapshot_create()
logger.debug('Creating snapshot of vm ' + vm_name)
task = vm.snapshot_create(memory=False, quiesce=False)
result = TestVM._client.get_task_monitor().wait_for_success(task=task)
self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)
# VM.snapshot_revert_to_current
logger.debug('Reverting vm ' + vm_name + ' to it\'s snapshot.')
vm.reload()
task = vm.snapshot_revert_to_current()
result = TestVM._client.get_task_monitor().wait_for_success(task=task)
self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)
# VM.snapshot_remove_all()
logger.debug('Removing all snapshots of vm ' + vm_name)
vm.reload()
task = vm.snapshot_remove_all()
result = TestVM._client.get_task_monitor().wait_for_success(task=task)
self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)
示例8: test_0061_detach_port_group
# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_default_logger [as 别名]
def test_0061_detach_port_group(self):
"""Detach a portgroup from an external network
This test passes if the portgroup from another vCenter is removed
from external network successfully.
"""
if TestExtNet._vc2_host_ip is None or TestExtNet._vc2_host_ip == '':
return
logger = Environment.get_default_logger()
platform = Platform(TestExtNet._sys_admin_client)
vc_name = TestExtNet._config['vc2']['vcenter_host_name']
port_group_helper = PortgroupHelper(TestExtNet._sys_admin_client)
pg_name = port_group_helper.get_ext_net_portgroup_name(vc_name,
self._name)
ext_net = self._get_ext_net(platform).detach_port_group(vc_name,
pg_name)
task = ext_net['{' + NSMAP['vcloud'] + '}Tasks'].Task[0]
TestExtNet._sys_admin_client.get_task_monitor().wait_for_success(
task=task)
logger.debug(
'Detach a portgroup from an external network' + TestExtNet._name)
ext_net = platform.get_external_network(self._name)
self.assertIsNotNone(ext_net)
vc_record = platform.get_vcenter(vc_name)
vc_href = vc_record.get('href')
vim_port_group_ref = ext_net.VimPortGroupRef
vc_href_found = False
if vim_port_group_ref.VimServerRef.get('href') == vc_href:
vc_href_found = True
self.assertFalse(vc_href_found)
示例9: test_0055_delete_ip_range
# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_default_logger [as 别名]
def test_0055_delete_ip_range(self):
"""Test the method externalNetwork.delete_ip_range()
Delete ip range of a subnet in external network
This test passes if the ip range for a subnet is
deleted successfully.
"""
logger = Environment.get_default_logger()
platform = Platform(TestExtNet._sys_admin_client)
ext_net = self._get_ext_net(platform).delete_ip_range(
TestExtNet._gateway2,
[TestExtNet._ip_range4])
task = ext_net['{' + NSMAP['vcloud'] + '}Tasks'].Task[0]
TestExtNet._sys_admin_client.get_task_monitor().wait_for_success(
task=task)
logger.debug(
'Deleted ip-range of a subnet in external network'
+ TestExtNet._name + '.')
ext_net = platform.get_external_network(self._name)
self.assertIsNotNone(ext_net)
config = ext_net['{' + NSMAP['vcloud'] + '}Configuration']
ip_scope = config.IpScopes.IpScope
for scope in ip_scope:
if scope.Gateway == TestExtNet._gateway2:
ip_scope = scope
break
self.assertIsNotNone(ip_scope)
self.assertFalse(self.__validate_ip_range(ip_scope,
TestExtNet._ip_range4))
示例10: test_0020_add_subnet
# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_default_logger [as 别名]
def test_0020_add_subnet(self):
"""Test the method externalNetwork.add_subnet()
Add subnet to the existing external network
This test passes if subnet is added successfully.
"""
logger = Environment.get_default_logger()
platform = Platform(TestExtNet._sys_admin_client)
ext_net_resource = platform.get_external_network(self._name)
extnet_obj = ExternalNetwork(TestExtNet._sys_admin_client,
resource=ext_net_resource)
ext_net = extnet_obj.add_subnet(self._name,
TestExtNet._gateway2,
TestExtNet._netmask,
[TestExtNet._ip_range2],
TestExtNet._dns1,
TestExtNet._dns2,
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(
'Added subnet to external network ' + TestExtNet._name + '.')
ext_net = platform.get_external_network(self._name)
self.assertIsNotNone(ext_net)
config = ext_net['{' + NSMAP['vcloud'] + '}Configuration']
new_subnet = config.IpScopes.IpScope[-1]
self.assertEqual(TestExtNet._gateway2, new_subnet.Gateway.text)
self.assertEqual(TestExtNet._netmask, new_subnet.Netmask.text)
示例11: test_0030_enable_subnet
# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_default_logger [as 别名]
def test_0030_enable_subnet(self):
"""Test the method externalNetwork.enable_subnet()
Enable subnet of external network
This test passes if subnet is enabled successfully.
"""
logger = Environment.get_default_logger()
platform = Platform(TestExtNet._sys_admin_client)
ext_net = self._get_ext_net(platform).enable_subnet(
TestExtNet._gateway2, True)
task = ext_net['{' + NSMAP['vcloud'] + '}Tasks'].Task[0]
TestExtNet._sys_admin_client.get_task_monitor().wait_for_success(
task=task)
logger.debug(
'Enabled subnet of external network ' + TestExtNet._name + '.')
ext_net = platform.get_external_network(self._name)
self.assertIsNotNone(ext_net)
config = ext_net['{' + NSMAP['vcloud'] + '}Configuration']
ip_scope = config.IpScopes.IpScope
for scope in ip_scope:
if scope.Gateway == TestExtNet._gateway2:
ip_scope = scope
break
self.assertIsNotNone(ip_scope)
self.assertEqual(ip_scope.IsEnabled, True)
示例12: test_007_register_service_right
# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_default_logger [as 别名]
def test_007_register_service_right(self):
"""Test the method APIExtension.add_service_right().
This test passes if the right-name returned after execution of the
method matches the expected right-name.
"""
logger = Environment.get_default_logger()
api_extension = APIExtension(TestApiExtension._client)
# Create a new right for CSE RBAC
logger.debug('Registering service right(name:' +
TestApiExtension._right_name + ', description:' +
TestApiExtension._description + ', category:' +
TestApiExtension._category + ').')
register_right = api_extension.add_service_right(
right_name=TestApiExtension._right_name,
service_name=TestApiExtension._service_name,
namespace=TestApiExtension._service1_namespace,
description=TestApiExtension._description,
category=TestApiExtension._category,
bundle_key=TestApiExtension._bundle_key)
expected_right_name = '{' + TestApiExtension._service1_namespace +\
'}:' + TestApiExtension._right_name
registered_right_name = register_right.get('name')
self.assertEqual(expected_right_name, registered_right_name)
示例13: test_0080_update_service
# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_default_logger [as 别名]
def test_0080_update_service(self):
"""Test the method APIExtension.update_extension().
This test passes if the routing key and exchange after execution of the
method matches the respective test strings.
"""
logger = Environment.get_default_logger()
api_extension = APIExtension(TestApiExtension._client)
ext_name = TestApiExtension._service_name
ext_namespace = TestApiExtension._service1_namespace
logger.debug('Updating service (name:' +
ext_name + ', namespace:' +
ext_namespace + ').')
test_routing_key = 'testroutingkey'
test_exchange = 'testexchange'
href = api_extension.update_extension(
name=ext_name,
namespace=ext_namespace,
routing_key=test_routing_key,
exchange=test_exchange)
self.assertEqual(href, TestApiExtension._service1_href)
ext_info = api_extension.get_extension_info(ext_name,
namespace=ext_namespace)
self.assertEqual(ext_info['routingKey'], test_routing_key)
self.assertEqual(ext_info['exchange'], test_exchange)
示例14: test_0040_enable_disable_vdc
# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_default_logger [as 别名]
def test_0040_enable_disable_vdc(self):
"""Test the method VDC.enable_vdc().
First disable the vdc, try to re-disable it (which should fail). Next,
enable the vdc back, and then try to re-enable the vdc (which should
fail).
This test passes if the state of vdc matches our expectation after each
operation.
"""
logger = Environment.get_default_logger()
vdc = VDC(TestOrgVDC._client, href=TestOrgVDC._new_vdc_href)
# vdc should be in enabled state after the previous tests.
vdc.enable_vdc(enable=False)
logger.debug('Disabled vdc ' + TestOrgVDC._new_vdc_name + '.')
try:
logger.debug('Trying to again disable vdc ' +
TestOrgVDC._new_vdc_name + '.')
vdc.enable_vdc(enable=False)
self.fail('Should not be able to disable vdc ' +
TestOrgVDC._new_vdc_href)
except OperationNotSupportedException as e:
pass
vdc.enable_vdc(enable=True)
logger.debug('Enabled vdc ' + TestOrgVDC._new_vdc_name + '.')
try:
logger.debug('Trying to again enable vdc ' +
TestOrgVDC._new_vdc_name + '.')
vdc.enable_vdc(enable=True)
self.fail('Should not be able to enable vdc ' +
TestOrgVDC._new_vdc_href)
except OperationNotSupportedException as e:
pass
示例15: test_0060_enable_disable_service
# 需要导入模块: from pyvcloud.system_test_framework.environment import Environment [as 别名]
# 或者: from pyvcloud.system_test_framework.environment.Environment import get_default_logger [as 别名]
def test_0060_enable_disable_service(self):
"""Test the method APIExtension.enable_extension().
This test passes if the href returned after each execution of the
method matches the service href.
"""
logger = Environment.get_default_logger()
api_extension = APIExtension(TestApiExtension._client)
logger.debug('Disabling service (name:' +
TestApiExtension._service_name + ', namespace:' +
TestApiExtension._service1_namespace + ').')
href = api_extension.enable_extension(
name=TestApiExtension._service_name,
namespace=TestApiExtension._service1_namespace,
enabled=False)
self.assertEqual(href, TestApiExtension._service1_href)
logger.debug('Re-enabling service (name:' +
TestApiExtension._service_name + ', namespace:' +
TestApiExtension._service1_namespace + ').')
href = api_extension.enable_extension(
name=TestApiExtension._service_name,
namespace=TestApiExtension._service1_namespace,
enabled=True)
self.assertEqual(href, TestApiExtension._service1_href)