当前位置: 首页>>代码示例>>Python>>正文


Python environment.Environment类代码示例

本文整理汇总了Python中pyvcloud.system_test_framework.environment.Environment的典型用法代码示例。如果您正苦于以下问题:Python Environment类的具体用法?Python Environment怎么用?Python Environment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Environment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

    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()
开发者ID:vmware,项目名称:vca-cli,代码行数:7,代码来源:extnet_tests.py

示例2: test_0010_vm_setup

    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)
开发者ID:vmware,项目名称:pyvcloud,代码行数:32,代码来源:pvdc_tests.py

示例3: test_0000_setup

    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)
开发者ID:vmware,项目名称:pyvcloud,代码行数:35,代码来源:nat_rule_tests.py

示例4: test_0070_update_catalog

    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)
开发者ID:vmware,项目名称:pyvcloud,代码行数:32,代码来源:catalog_tests.py

示例5: test_0060_vapp_network_connection

    def test_0060_vapp_network_connection(self):
        """Test vapp.connect/disconnect_org_vdc_network().

        This test passes if the connect and disconnect to orgvdc network
        operations are successful.
        """
        logger = Environment.get_default_logger()

        network_name = Environment.get_default_orgvdc_network_name()

        vapp_name = TestVApp._customized_vapp_name
        vapp = Environment.get_vapp_in_test_vdc(
            client=TestVApp._client, vapp_name=vapp_name)

        logger.debug('Connecting vApp ' + vapp_name + ' to orgvdc network ' +
                     network_name)
        task = vapp.connect_org_vdc_network(network_name)
        result = TestVApp._client.get_task_monitor().wait_for_success(task)
        self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)

        logger.debug('Disconnecting vApp ' + vapp_name +
                     ' to orgvdc network ' + network_name)
        vapp.reload()
        task = vapp.disconnect_org_vdc_network(network_name)
        result = TestVApp._client.get_task_monitor().wait_for_success(task)
        self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)
开发者ID:vmware,项目名称:pyvcloud,代码行数:26,代码来源:vapp_tests.py

示例6: test_0000_setup

    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)
开发者ID:vmware,项目名称:pyvcloud,代码行数:30,代码来源:firewall_rule_tests.py

示例7: 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
开发者ID:vmware,项目名称:vca-cli,代码行数:26,代码来源:firewall_rule_tests.py

示例8: setUp

    def setUp(self):
        self._config = Environment.get_config()
        self._host = self._config['vcd']['host']
        self._org = self._config['vcd']['sys_org_name']
        self._user = self._config['vcd']['sys_admin_username']
        self._pass = self._config['vcd']['sys_admin_pass']

        self._logger = Environment.get_default_logger()
开发者ID:vmware,项目名称:pyvcloud,代码行数:8,代码来源:client_tests.py

示例9: test_0055_exit_maintenance_mode

 def test_0055_exit_maintenance_mode(self):
     logger = Environment.get_default_logger()
     vapp_name = TestVApp._customized_vapp_name
     vapp = Environment.get_vapp_in_test_vdc(
         client=TestVApp._sys_admin_client, vapp_name=vapp_name)
     logger.debug('Exiting maintenance mode of vApp ' + vapp_name)
     vapp.reload()
     result = vapp.exit_maintenance_mode()
     self.assertEqual(result, None)
开发者ID:vmware,项目名称:pyvcloud,代码行数:9,代码来源:vapp_tests.py

示例10: test_0053_discard_suspended_state_vapp

 def test_0053_discard_suspended_state_vapp(self):
     logger = Environment.get_default_logger()
     vapp_name = TestVApp._customized_vapp_name
     vapp = Environment.get_vapp_in_test_vdc(
         client=TestVApp._sys_admin_client, vapp_name=vapp_name)
     logger.debug('Discarding suspended state of vApp ' + vapp_name)
     vapp.reload()
     task = vapp.discard_suspended_state_vapp()
     result = TestVApp._client.get_task_monitor().wait_for_success(task)
     self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)
开发者ID:vmware,项目名称:pyvcloud,代码行数:10,代码来源:vapp_tests.py

示例11: setUp

    def setUp(self):
        """Load configuration and create a click runner to invoke CLI."""
        self._config = Environment.get_config()
        self._host = self._config['vcd']['host']
        self._org = self._config['vcd']['sys_org_name']
        self._admin_user = self._config['vcd']['sys_admin_username']
        self._admin_pass = self._config['vcd']['sys_admin_pass']
        self._logger = Environment.get_default_logger()

        self._runner = CliRunner()
开发者ID:vmware,项目名称:vca-cli,代码行数:10,代码来源:login_and_vcd_tests.py

示例12: wrapped_f

 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.')
开发者ID:vmware,项目名称:pyvcloud,代码行数:12,代码来源:depends.py

示例13: test_0000_setup

 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)
开发者ID:vmware,项目名称:pyvcloud,代码行数:12,代码来源:vapp_firewall_tests.py

示例14: test_0000_setup

 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])
开发者ID:vmware,项目名称:vca-cli,代码行数:13,代码来源:ca_certificate_tests.py

示例15: test_0100_vapp_metadata

    def test_0100_vapp_metadata(self):
        """Test the methods related to metadata manipulation in vapp.py.

        This test passes if all the metadata operations are successful.
        """
        logger = Environment.get_default_logger()
        vapp_name = TestVApp._empty_vapp_name
        vapp = Environment.get_vapp_in_test_vdc(
            client=TestVApp._client, vapp_name=vapp_name)

        # add new metadata
        logger.debug(f'Adding metadata [key={TestVApp._metadata_key},'
                     'value={TestVApp._metadata_value}]) to vApp:'
                     '{vapp_name}')
        task = vapp.set_metadata(
            domain=MetadataDomain.GENERAL.value,
            visibility=MetadataVisibility.READ_WRITE,
            key=TestVApp._metadata_key,
            value=TestVApp._metadata_value)
        result = TestVApp._client.get_task_monitor().wait_for_success(task)
        self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)

        # retrieve metadata
        logger.debug(f'Retriving metadata with key='
                     '{TestVApp._metadata_key} from vApp:{vapp_name}.')
        entries = metadata_to_dict(vapp.get_metadata())
        self.assertTrue(
            TestVApp._metadata_key in entries, f'Should have '
            'been able to retrieve metadata entry with '
            'key={TestVApp._metadata_key}.')

        # update metadata value as org admin
        logger.debug(f'Updtaing metadata on vApp:{vapp_name} with key='
                     '{TestVApp._metadata_key} to value='
                     '{TestVApp._metadata_new_value}.')
        task = vapp.set_metadata(
            domain=MetadataDomain.GENERAL.value,
            visibility=MetadataVisibility.READ_WRITE,
            key=TestVApp._metadata_key,
            value=TestVApp._metadata_new_value)
        TestVApp._client.get_task_monitor().wait_for_success(task)
        entries = metadata_to_dict(vapp.get_metadata())
        self.assertEqual(TestVApp._metadata_new_value,
                         entries[TestVApp._metadata_key])

        # remove metadata entry
        logger.debug(f'Removing metadata with '
                     'key={TestVApp._metadata_key} from vApp:{vapp_name}.')
        task = vapp.remove_metadata(key=TestVApp._metadata_key)
        result = TestVApp._client.get_task_monitor().wait_for_success(task)
        self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)
开发者ID:vmware,项目名称:pyvcloud,代码行数:51,代码来源:vapp_tests.py


注:本文中的pyvcloud.system_test_framework.environment.Environment类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。