示例#1
0
    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()
示例#2
0
    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
0
    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)
示例#4
0
    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)
示例#5
0
    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)
示例#6
0
    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
示例#7
0
    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)
示例#8
0
    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()
示例#9
0
 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)
示例#10
0
    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()
示例#11
0
 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)
示例#12
0
 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)
示例#13
0
 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.')
示例#14
0
 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])
示例#15
0
    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)
示例#16
0
    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)
示例#17
0
    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()))
示例#18
0
 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
示例#19
0
    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)
示例#20
0
    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)
示例#21
0
    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))
示例#22
0
    def test_0060_attach_port_group(self):
        """Attach a portgroup to an external network
       This test passes if the portgroup from another vCenter is added
       to 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']
        portgrouphelper = PortgroupHelper(TestExtNet._sys_admin_client)
        pg_name = portgrouphelper.get_available_portgroup_name(
            vc_name, TestExtNet._portgroupType)

        ext_net = self._get_ext_net(platform).attach_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(
            'Attach a portgroup to 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_refs = \
            ext_net['{' + NSMAP['vmext'] + '}VimPortGroupRefs']
        vc_href_found = False
        for vim_obj_ref in vim_port_group_refs.VimObjectRef:
            if vim_obj_ref.VimServerRef.get('href') == vc_href:
                vc_href_found = True
                break
        self.assertTrue(vc_href_found)
示例#23
0
    def test_0010_update(self):
        """Test the method Platform.update_external_network()

        Update name and description of the external network created by setup.
        Verifies name and description after update completes. Reset the name
        and description to original.

        This test passes if name and description are updated successfully.
        """
        logger = Environment.get_default_logger()
        platform = Platform(TestExtNet._sys_admin_client)
        new_name = 'updated_' + TestExtNet._name
        new_description = 'Updated ' + TestExtNet._description

        ext_net = platform.update_external_network(TestExtNet._name, new_name,
                                                   new_description)

        task = ext_net['{' + NSMAP['vcloud'] + '}Tasks'].Task[0]
        TestExtNet._sys_admin_client.get_task_monitor().wait_for_success(
            task=task)
        logger.debug('Updated external network ' + TestExtNet._name + '.')

        ext_net = platform.get_external_network(new_name)
        self.assertIsNotNone(ext_net)
        self.assertEqual(new_description,
                         ext_net['{' + NSMAP['vcloud'] + '}Description'].text)

        # Reset the name and description to original
        ext_net = platform.update_external_network(new_name, self._name,
                                                   self._description)
        task = ext_net['{' + NSMAP['vcloud'] + '}Tasks'].Task[0]
        TestExtNet._sys_admin_client.get_task_monitor().wait_for_success(
            task=task)
示例#24
0
    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)
示例#25
0
    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
示例#26
0
    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)
示例#27
0
    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)
示例#28
0
    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)
示例#29
0
    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)
示例#30
0
    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)
示例#31
0
    def test_0061_install_vmware_tools(self):
        """Test the method related to install vmware tools in vm.py.
        This test passes if install vmware tools operation is 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)

        logger.debug('Installing Vmware Tools in VM:  ' + vm_name)
        task = vm.install_vmware_tools()
        result = TestVM._client.get_task_monitor().wait_for_success(task=task)
        self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)
示例#32
0
    def test_0120_detach_independent_disk(self):
        vdc = Environment.get_test_vdc(TestVM._client)
        idisk = vdc.get_disk(name=TestVM._idisk_name)
        task = TestVM._test_vapp. \
            detach_disk_from_vm(disk_href=idisk.get('href'),
                                vm_name=TestVM._test_vapp_first_vm_name)
        result = TestVM._client.get_task_monitor().wait_for_success(task=task)
        self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)

        is_disk_attached = self.__validate_is_attached_disk(
            is_disk_attached=False)
        self.assertFalse(is_disk_attached)
示例#33
0
 def test_0022_disable_rate_limit(self):
     """Disables rate limit of gateway.
      It will trigger the cli command configure-rate-limits disable
     """
     self._config = Environment.get_config()
     config = self._config['external_network']
     ext_name = config['name']
     result = self._runner.invoke(gateway,
                                  args=[
                                      'configure-rate-limits', 'disable',
                                      self._name, '-e', ext_name
                                  ])
示例#34
0
    def test_9998_teardown(self):
        """Delete the vApp created during setup.

        This test passes if the task for deleting the vApp succeed.
        """
        vapps_to_delete = []
        if TestVM._test_vapp_href is not None:
            vapps_to_delete.append(TestVM._test_vapp_name)

        if TestVM._empty_vapp_href is not None:
            vapps_to_delete.append(TestVM._empty_vapp_name)

        vdc = Environment.get_test_vdc(TestVM._sys_admin_client)
        vdc.delete_disk(name=self._idisk_name)

        vdc = Environment.get_test_vdc(TestVM._client)

        for vapp_name in vapps_to_delete:
            task = vdc.delete_vapp(name=vapp_name, force=True)
            result = TestVM._client.get_task_monitor().wait_for_success(task)
            self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)
示例#35
0
    def test_0050_update_user_password(self):
        """Test the method Client.update_user().

        This test passes if the method is able to update an
        existing user password with a supplied user password.
        """
        logger = Environment.get_default_logger()
        logger.debug('Update org_user password from vApp User tp vApp Author')
        updated_user = TestUser._org.update_user(TestUser._org_user,
                                                 password="******")

        self.assertNotEqual(updated_user, None)
示例#36
0
 def _login(self):
     org = VmTest._config['vcd']['default_org_name']
     user = Environment.get_username_for_role_in_test_org(
         CommonRoles.ORGANIZATION_ADMINISTRATOR)
     password = VmTest._config['vcd']['default_org_user_password']
     login_args = [
         VmTest._config['vcd']['host'], org, user, "-i", "-w",
         "--password={0}".format(password)
     ]
     result = VmTest._runner.invoke(login, args=login_args)
     self.assertEqual(0, result.exit_code)
     self.assertTrue("logged in" in result.output)
示例#37
0
    def test_0098_teardown(self):
        """Test the  method vdc.delete_vapp().

        Invoke the method for all the vApps created by setup.

        This test passes if all the tasks for deleting the vApps succeed.
        """
        vdc = Environment.get_test_vdc(TestVappFirewall._client)
        task = vdc.delete_vapp(name=TestVappFirewall._vapp_name, force=True)
        result = TestVappFirewall._client.get_task_monitor().wait_for_success(
            task)
        self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)
示例#38
0
    def test_0040_get_vc(self):
        """Test the method VM.get_vc().

        This test passes if the retrieved vc name matches with the expected
        vc name.
        """
        vm = VM(TestVM._sys_admin_client, href=TestVM._test_vapp_first_vm_href)
        retrieved_vc_name = vm.get_vc()

        expected_vc_name = Environment.get_config()['vc']['vcenter_host_name']

        self.assertEqual(retrieved_vc_name, expected_vc_name)
示例#39
0
    def test_0098_teardown(self):
        """Test the method System.delete_gateway().

        Invoke the method for the gateway created by setup.

        This test passes if no errors are generated while deleting the gateway.
        """
        vdc = Environment.get_test_vdc(TestGateway._client)
        task = vdc.delete_gateway(TestGateway._name)
        result = TestGateway._client.get_task_monitor().wait_for_success(
            task=task)
        self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)
示例#40
0
    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 passes if none of the delete operations generate any
        exceptions.
        """
        org = Environment.get_test_org(TestCatalog._client)
        logger = Environment.get_default_logger()
        logger.debug('Deleting catalog item : ' +
                     TestCatalog._test_template_name)
        org.delete_catalog_item(TestCatalog._test_catalog_name,
                                TestCatalog._test_template_name)
        logger.debug('Deleting catalog item : ' +
                     TestCatalog._test_template_with_chunk_size_name)
        org.delete_catalog_item(
            TestCatalog._test_catalog_name,
            TestCatalog._test_template_with_chunk_size_name)
        logger.debug('Deleting catalog : ' + TestCatalog._test_catalog_name)
        org.delete_catalog(TestCatalog._test_catalog_name)
示例#41
0
    def test_0030_get_non_existent_vdc(self):
        """Test the method VDC.get_vdc().

        This test passes if the non-existent vdc can't be successfully
        retrieved by name.
        """
        org = Environment.get_test_org(TestOrgVDC._client)
        try:
            resource = org.get_vdc(TestOrgVDC._non_existent_vdc_name)
            self.assertIsNone(resource)
        except EntityNotFoundException as e:
            pass
示例#42
0
 def test_0063_eject_cd(self):
     """Test the method related to eject CD in vm.py.
     This test passes if eject CD operation is 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)
     media_href = TestVM._media_resource.Entity.get('href')
     logger.debug('Ejecting CD from VM:  ' + vm_name)
     task = vm.eject_cd(media_href)
     result = TestVM._client.get_task_monitor().wait_for_success(task=task)
     self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)
示例#43
0
    def test_0000_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()
        TestVM._client = Environment.get_client_in_default_org(
            TestVM._test_runner_role)
        TestVM._sys_admin_client = Environment.get_sys_admin_client()
        vdc = Environment.get_test_vdc(TestVM._client)

        logger.debug('Creating vApp ' + TestVM._test_vapp_name + '.')
        TestVM._test_vapp_href = create_customized_vapp_from_template(
            client=TestVM._client,
            vdc=vdc,
            name=TestVM._test_vapp_name,
            catalog_name=Environment.get_default_catalog_name(),
            template_name=Environment.get_default_template_name(),
            memory_size=TestVM._test_vapp_first_vm_memory_size,
            num_cpu=TestVM._test_vapp_first_vm_num_cpu,
            disk_size=TestVM._test_vapp_first_vm_first_disk_size,
            vm_name=TestVM._test_vapp_first_vm_name,
            nw_adapter_type=TestVM._test_vapp_first_vm_network_adapter_type)

        self.assertIsNotNone(TestVM._test_vapp_href)

        vapp = VApp(TestVM._client, href=TestVM._test_vapp_href)
        vm_resource = vapp.get_vm(TestVM._test_vapp_first_vm_name)
        TestVM._test_vapp_first_vm_href = vm_resource.get('href')

        self.assertIsNotNone(TestVM._test_vapp_first_vm_href)
示例#44
0
    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)
        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)
示例#45
0
    def test_0040_change_idisk_owner(self):
        """Test the  method vdc.change_disk_owner().

           Invoke the method for the third independent disk, to make vapp_user
           the owner of the disk. Revert back teh ownership to catalog_author
           once the test is over.

           This test passes if the disk states it's owner as vapp_user after
           the method call.
        """
        org_admin_client = Environment.get_client_in_default_org(
            CommonRoles.ORGANIZATION_ADMINISTRATOR)
        org = Environment.get_test_org(org_admin_client)
        vdc = Environment.get_test_vdc(org_admin_client)

        try:
            username = Environment.get_username_for_role_in_test_org(
                CommonRoles.VAPP_USER)
            user_resource = org.get_user(username)

            vdc.change_disk_owner(disk_id=TestDisk._idisk3_id,
                                  user_href=user_resource.get('href'))

            disk_resource = vdc.get_disk(disk_id=TestDisk._idisk3_id)
            new_owner_name = disk_resource.Owner.User.get('name')
            self.assertEqual(new_owner_name, username)

            # Revert owenership to catalog author
            username = Environment.get_username_for_role_in_test_org(
                CommonRoles.CATALOG_AUTHOR)
            user_resource = org.get_user(username)

            vdc.change_disk_owner(disk_id=TestDisk._idisk3_id,
                                  user_href=user_resource.get('href'))

            disk_resource = vdc.get_disk(disk_id=TestDisk._idisk3_id)
            new_owner_name = disk_resource.Owner.User.get('name')
            self.assertEqual(new_owner_name, username)
        finally:
            org_admin_client.logout()
示例#46
0
 def test_0150_reload_from_vc(self):
     """Test the method related to reload_from_vc in vm.py.
     This test passes if reload from VC operation is successful.
     """
     logger = Environment.get_default_logger()
     vm_name = TestVM._test_vapp_first_vm_name
     vm = VM(TestVM._sys_admin_client, href=TestVM._test_vapp_first_vm_href)
     vm.reload()
     logger.debug('Reloading VM:  ' + vm_name + ' from VC.')
     task = vm.reload_from_vc()
     result = TestVM._sys_admin_client.\
         get_task_monitor().wait_for_success(task=task)
     self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)
示例#47
0
    def test_0110_create_vapp_network(self):
        """Test the method vapp.create_vapp_network().

        This test passes if the vApp network creation is successful.
        """
        logger = Environment.get_default_logger()
        vapp_name = TestVApp._customized_vapp_name
        vapp = Environment.get_vapp_in_test_vdc(client=TestVApp._client,
                                                vapp_name=vapp_name)
        logger.debug('Creating a vApp network in ' +
                     TestVApp._customized_vapp_name)
        task = vapp.create_vapp_network(
            TestVApp._vapp_network_name, TestVApp._vapp_network_cidr,
            TestVApp._vapp_network_description, TestVApp._vapp_network_dns1,
            TestVApp._vapp_network_dns2, TestVApp._vapp_network_dns_suffix,
            [TestVApp._vapp_network_ip_range])
        result = TestVApp._client.get_task_monitor().wait_for_success(task)
        self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)
        # Verification
        vapp.reload()
        self.assertTrue(
            self._is_network_present(vapp, TestVApp._vapp_network_name))
示例#48
0
    def test_0057_enable_and_download_ova(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('Enable download a vApp ' + vapp_name)
        vapp.enable_download()

        logger.debug('Downloading a vApp ' + vapp_name)
        vapp.reload()
        bytes_written = vapp.download_ova(TestVApp._ova_file_name)
        self.assertNotEqual(bytes_written, 0)

        logger.debug('Deploying vApp ' + vapp_name)
        vapp.reload()
        task = vapp.deploy(power_on=False)
        result = TestVApp._client.get_task_monitor().wait_for_success(task)
        self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)

        logger.debug('Remove downloaded ' + TestVApp._ova_file_name)
        os.remove(TestVApp._ova_file_name)
示例#49
0
    def test_0030_add_delete_vm(self):
        """Test the method vapp.add_vms() and vapp.delete_vms().

        This test passes if the supplied vm is sucessfully added to the vApp
        and then successfully removed from the vApp.
        """
        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)

        source_vapp_name = TestVApp._customized_vapp_name
        source_vapp = Environment.get_vapp_in_test_vdc(
            client=TestVApp._client, vapp_name=source_vapp_name)
        source_vapp_resource = source_vapp.get_resource()
        source_vm_name = TestVApp._customized_vapp_vm_name
        target_vm_name = TestVApp._additional_vm_name
        spec = {
            'vapp': source_vapp_resource,
            'source_vm_name': source_vm_name,
            'target_vm_name': target_vm_name
        }

        logger.debug('Adding vm ' + target_vm_name + ' to vApp ' + vapp_name)
        # deploy and power_on are false to make sure that the subsequent
        # deletion of vm doesn't require additional power operations
        task = vapp.add_vms([spec],
                            deploy=False,
                            power_on=False,
                            all_eulas_accepted=True)
        result = TestVApp._client.get_task_monitor().wait_for_success(task)
        self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)

        logger.debug('Removing vm ' + target_vm_name + ' from vApp ' +
                     vapp_name)
        vapp.reload()
        task = vapp.delete_vms([target_vm_name])
        result = TestVApp._client.get_task_monitor().wait_for_success(task)
        self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)
示例#50
0
    def test_0020_get_nonexistent_vapp(self):
        """Test the method vdc.get_vapp().

        This test passes if the non-existent vApp can't be successfully
        retrieved by name.
        """
        vdc = Environment.get_test_vdc(TestVApp._client)
        try:
            vdc.get_vapp(TestVApp._non_existent_vapp_name)
            self.fail('Should not be able to fetch vApp ' +
                      TestVApp._non_existent_vapp_name)
        except EntityNotFoundException as e:
            return
示例#51
0
    def test_0050_get_catalog(self):
        """Test the method org.get_catalog().

        Retrieve the catalog created in test_0000_setup.

        This test passes if the catalog created in test_0000_setup is
        retrieved successfully without any errors.
        """
        org = Environment.get_test_org(TestCatalog._client)
        catalog_resource = org.get_catalog(TestCatalog._test_catalog_name)

        self.assertEqual(TestCatalog._test_catalog_name,
                         catalog_resource.get('name'))
示例#52
0
 def test_0040_check_all_resource_types(self):
     """Verify that we can search on any resource type without error."""
     self._client = Environment.get_client_in_default_org(
         CommonRoles.ORGANIZATION_ADMINISTRATOR)
     resource_types = [r.value for r in ResourceType]
     # Some types of course won't exist but the search should not fail.
     for resource_type in resource_types:
         q1 = self._client.get_typed_query(
             resource_type,
             query_result_format=QueryResultFormat.ID_RECORDS)
         q1_records = list(q1.execute())
         self.assertTrue(
             len(q1_records) >= 0, "Should get a list, even if tempty")
示例#53
0
    def test_0030_get_disk_by_id(self):
        """Test the  method vdc.get_disk() called with 'id' param.

           Invoke the method with the id of the second independent disk.

           This test passes if the disk returned by the method is nor None,
           and it's id matches the expected id of the disk.
        """
        vdc = Environment.get_test_vdc(TestDisk._client)

        fetched_disk = vdc.get_disk(disk_id=TestDisk._idisk2_id)
        self.assertIsNotNone(fetched_disk)
        self.assertEqual(fetched_disk.get('name'), self._idisk2_name)
示例#54
0
 def test_0160_check_compliance(self):
     """Test the method related to check_compliance in vm.py.
     This test passes if check compliance operation is successful.
     """
     logger = Environment.get_default_logger()
     vm_name = TestVM._test_vapp_first_vm_name
     vm = VM(TestVM._sys_admin_client, href=TestVM._test_vapp_first_vm_href)
     vm.reload()
     logger.debug('Checking compliance of VM:  ' + vm_name)
     task = vm.check_compliance()
     result = TestVM._sys_admin_client.\
         get_task_monitor().wait_for_success(task=task)
     self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)
示例#55
0
    def test_0030_get_non_existent_vdc(self):
        """Test the method VDC.get_vdc().

        This test passes if the non-existent vdc can't be successfully
        retrieved by name.
        """
        org = Environment.get_test_org(TestOrgVDC._client)
        try:
            org.get_vdc(TestOrgVDC._non_existent_vdc_name)
            self.fail('Should not be able to fetch vdc ' +
                      TestOrgVDC._non_existent_vdc_name)
        except EntityNotFoundException as e:
            pass
示例#56
0
 def test_0201_enable_fence_mode(self):
     vapp = Environment.get_vapp_in_test_vdc(
         client=TestVApp._sys_admin_client,
         vapp_name=TestVApp._customized_vapp_name)
     task = vapp.enable_fence_mode()
     result = TestVApp._sys_admin_client.get_task_monitor(
     ).wait_for_success(task)
     self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)
     vapp.reload()
     task = vapp.delete_vapp_network(TestVApp._ovdc_network_name)
     result = TestVApp._sys_admin_client.get_task_monitor(
     ).wait_for_success(task)
     self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)
示例#57
0
    def test_0000_setup(self):
        """Setup the gateway required for the other tests in this module.

        Create a gateway as per the configuration stated
        above.

        This test passes if the gateway is created successfully.
        """
        TestGateway._client = Environment.get_sys_admin_client()
        TestGateway._vdc = Environment.get_test_vdc(TestGateway._client)

        TestGateway._org_client = Environment.get_client_in_default_org(
            CommonRoles.ORGANIZATION_ADMINISTRATOR)
        TestGateway._config = Environment.get_config()

        TestGateway._gateway = Environment.get_test_gateway(
            TestGateway._client)
        if TestGateway._gateway is not None:
            task = TestGateway._vdc.delete_gateway(self._name)
            result = TestGateway._client.get_task_monitor().wait_for_success(
                task=task)
            self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)

        external_network = Environment.get_test_external_network(
            TestGateway._client)

        ext_net_resource = external_network.get_resource()
        ip_scopes = ext_net_resource.xpath(
            'vcloud:Configuration/vcloud:IpScopes/vcloud:IpScope',
            namespaces=NSMAP)
        first_ipscope = ip_scopes[0]
        gateway_ip = first_ipscope.Gateway.text
        prefix_len = netmask_to_cidr_prefix_len(gateway_ip,
                                                first_ipscope.Netmask.text)
        subnet_addr = gateway_ip + '/' + str(prefix_len)
        ext_net_to_participated_subnet_with_ip_settings = {
            ext_net_resource.get('name'): {
                subnet_addr: 'Auto'
            }
        }

        gateway_ip_arr = gateway_ip.split('.')
        last_ip_digit = int(gateway_ip_arr[-1]) + 1
        gateway_ip_arr[-1] = str(last_ip_digit)
        next_ip = '.'.join(gateway_ip_arr)
        ext_net_to_subnet_with_ip_range = {
            ext_net_resource.get('name'): {
                subnet_addr: [next_ip + '-' + next_ip]
            }
        }
        ext_net_to_rate_limit = {ext_net_resource.get('name'): {100: 100}}
        TestGateway._gateway = TestGateway._vdc.create_gateway(
            self._name, [ext_net_resource.get('name')], 'compact', None, True,
            ext_net_resource.get('name'), gateway_ip, True, False, False,
            False, True, ext_net_to_participated_subnet_with_ip_settings, True,
            ext_net_to_subnet_with_ip_range, ext_net_to_rate_limit)
        result = TestGateway._client.get_task_monitor().wait_for_success(
            task=TestGateway._gateway.Tasks.Task)
        self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)
示例#58
0
    def test_0040_update_user_role(self):
        """Test the method Client.update_user().

        This test passes if the method is able to update an existing user role
        with a supplied user role.
        """
        logger = Environment.get_default_logger()
        logger.debug('Update org_user role from vApp User tp vApp Author')
        updated_user = TestUser._org.update_user(
            TestUser._org_user, role_name=TestUser._vapp_author_role)
        updated_user_role = updated_user['Role'].get('name')

        self.assertEqual(updated_user_role, TestUser._vapp_author_role)
示例#59
0
 def test_0000_setup(self):
     """Adds new ip range present to the sub allocate pool of gateway.
      It will trigger the cli command sub-allocate-ip add
     """
     self._config = Environment.get_config()
     TestNatRule._logger = Environment.get_default_logger()
     TestNatRule._runner = CliRunner()
     default_org = self._config['vcd']['default_org_name']
     self._login()
     TestNatRule._runner.invoke(org, ['use', default_org])
     config = self._config['external_network']
     gateway_sub_allocated_ip_range = \
         config['gateway_sub_allocated_ip_range']
     ext_name = config['name']
     result = TestNatRule._runner.invoke(gateway,
                                         args=[
                                             'sub-allocate-ip', 'add',
                                             TestNatRule._name, '-e',
                                             ext_name, '--ip-range',
                                             gateway_sub_allocated_ip_range
                                         ])
     self.assertEqual(0, result.exit_code)
示例#60
0
    def test_0020_get_isolated_orgvdc_network(self):
        """Test the method vdc.get_isolated_orgvdc_network().

        Retrieve the isolated orgvdc network created during setup.

        This test passes if the network created during setup is retrieved
        successfully without any errors.
        """
        vdc = Environment.get_test_vdc(TestNetwork._client)
        network = vdc.get_isolated_orgvdc_network(
            TestNetwork._isolated_orgvdc_network_name)
        self.assertEqual(TestNetwork._isolated_orgvdc_network_name,
                         network.get('name'))