• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python environment.Environment类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: test_0140_upgrade_virtual_hardware

    def test_0140_upgrade_virtual_hardware(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('Un-deploying vApp ' + vapp_name)
        task = vapp.undeploy()
        result = TestVApp._sys_admin_client.get_task_monitor(
        ).wait_for_success(task)
        self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)

        logger.debug('Upgrading virtual hardware of vApp ' + vapp_name)
        no_of_vm_upgraded = vapp.upgrade_virtual_hardware()
        self.assertEqual(no_of_vm_upgraded, len(vapp.get_all_vms()))
开发者ID:vmware,项目名称:pyvcloud,代码行数:15,代码来源:vapp_tests.py


示例17: test_0000_setup

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


示例18: test_9998_teardown

    def test_9998_teardown(self):
        """Test the method vdc.delete_isolated_orgvdc_network().

        Invoke the method for the orgvdc network created by setup.

        This test passes if the task for deleting the network succeeds.
        """
        logger = Environment.get_default_logger()
        vdc = Environment.get_test_vdc(TestNetwork._client)

        logger.debug('Deleting isolated orgvdc network : ' +
                     TestNetwork._isolated_orgvdc_network_name)
        result = vdc.delete_isolated_orgvdc_network(
            name=TestNetwork._isolated_orgvdc_network_name, force=True)
        TestNetwork._client.get_task_monitor().wait_for_success(task=result)
开发者ID:vmware,项目名称:pyvcloud,代码行数:15,代码来源:network_tests.py


示例19: test_0040_enable_disable_vdc

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


示例20: test_0098_teardown

    def test_0098_teardown(self):
        """Delete a DHCP Pool from gateway.

        It will trigger the cli command services dhcp-pool delete
        """
        self._config = Environment.get_config()
        TestDhcpPool._logger = Environment.get_default_logger()
        TestDhcpPool._runner = CliRunner()
        default_org = self._config['vcd']['default_org_name']
        TestDhcpPool._runner.invoke(org, ['use', default_org])
        result = TestDhcpPool._runner.invoke(
            gateway,
            args=[
                'services', 'dhcp-pool', 'delete', TestDhcpPool._gateway_name,
                TestDhcpPool._pool_id])
        self.assertEqual(0, result.exit_code)
开发者ID:vmware,项目名称:vca-cli,代码行数:16,代码来源:dhcp_pool_test.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python gateway.Gateway类代码示例发布时间:2022-05-27
下一篇:
Python pyvcloud.Log类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap