How to use the pyvcloud.system_test_framework.environment.Environment.get_sys_admin_client function in pyvcloud

To help you get started, we’ve selected a few pyvcloud examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vmware / vcd-cli / system_tests / vapp_network_nat_tests.py View on Github external
def test_0000_setup(self):
        self._config = Environment.get_config()
        TestVappNat._logger = Environment.get_default_logger()
        TestVappNat._client = Environment.get_sys_admin_client()
        TestVappNat._runner = CliRunner()
        default_org = self._config['vcd']['default_org_name']
        self._login()
        TestVappNat._runner.invoke(org, ['use', default_org])

        vapp = Environment.get_test_vapp_with_network(TestVappNat._client)
        vapp.reload()
        task = vapp.connect_vapp_network_to_ovdc_network(
            network_name=TestVappNat._vapp_network_name,
            orgvdc_network_name=TestVappNat._org_vdc_network_name)
        result = TestVappNat._client.get_task_monitor().wait_for_success(task)
        self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)

        vm_resource = vapp.get_vm(TestVappNat._vm_name)
        vm = VM(TestVappNat._client, resource=vm_resource)
        task = vm.add_nic(NetworkAdapterType.E1000.value, True, True,
github vmware / vcd-cli / system_tests / ipsec_vpn_tests.py View on Github external
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(
github vmware / pyvcloud / system_tests / dhcp_tests.py View on Github external
def test_0000_setup(self):
        """Add DHCP pool in the gateway.

        Invokes the add_dhcp_pool of the gateway.
        """
        TestDhcp._client = Environment.get_sys_admin_client()
        TestDhcp._config = Environment.get_config()
        gateway = Environment. \
            get_test_gateway(TestDhcp._client)
        gateway_obj = Gateway(TestDhcp._client,
                              TestDhcp._name,
                              href=gateway.get('href'))
        gateway_obj.add_dhcp_pool(TestDhcp._pool_ip_range)
        dhcp_resource = gateway_obj.get_dhcp()
        # Verify
        matchFound = False
        for ipPool in dhcp_resource.ipPools.ipPool:
            if ipPool.ipRange.text == TestDhcp._pool_ip_range:
                matchFound = True
                break
        self.assertTrue(matchFound)
github vmware / pyvcloud / system_tests / search_tests.py View on Github external
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
github vmware / vcd-cli / system_tests / gateway_tests.py View on Github external
def test_0000_setup(self):
        """Load configuration and create a click runner to invoke CLI."""
        self._config = Environment.get_config()
        GatewayTest._logger = Environment.get_default_logger()

        GatewayTest._runner = CliRunner()
        default_org = self._config['vcd']['default_org_name']
        self._login()
        GatewayTest._runner.invoke(org, ['use', default_org])
        GatewayTest._api_version = self._config['vcd']['api_version']
        GatewayTest._ext_network_name = self._get_first_external_network()

        self.client = Environment.get_sys_admin_client()
        platform = Platform(self.client)
        ext_net_resource = platform.get_external_network(
            GatewayTest._ext_network_name)

        self.assertTrue(len(ext_net_resource) > 0)

        ip_scopes = ext_net_resource.xpath(
            'vcloud:Configuration/vcloud:IpScopes/vcloud:IpScope',
            namespaces=NSMAP)
        first_ipscope = ip_scopes[0]
        GatewayTest._gateway_ip = first_ipscope.Gateway.text
        prefix_len = netmask_to_cidr_prefix_len(GatewayTest._gateway_ip,
                                                first_ipscope.Netmask.text)
        GatewayTest._subnet_addr = GatewayTest._gateway_ip + '/' + str(
            prefix_len)
github vmware / pyvcloud / system_tests / search_tests.py View on Github external
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,
github vmware / pyvcloud / system_tests / extnet_tests.py View on Github external
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,