How to use the pyvcloud.system_test_framework.environment.Environment.get_default_logger 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 / pyvcloud / system_tests / vm_tests.py View on Github external
def test_0050_customize_vm(self):
        """Test the methods to update and retrieve memory and cpu of a vm.
        The test passes if the update operations are successful and the values
        retrieved thereafter matches the expected values.
        """
        logger = Environment.get_default_logger()
        vm_name = TestVM._test_vapp_first_vm_name
        vm = VM(TestVM._client, href=TestVM._test_vapp_first_vm_href)
        old_num_cpu_data = vm.get_cpus()
        self.assertEqual(old_num_cpu_data['num_cpus'],
                         TestVM._test_vapp_first_vm_num_cpu)
        old_memory_size = vm.get_memory()
        self.assertEqual(old_memory_size,
                         TestVM._test_vapp_first_vm_memory_size)
        # vm can be updated only when it's powered off
        if not vm.is_powered_off():
            task = vm.power_off()
            TestVM._client.get_task_monitor().wait_for_success(task)
            vm.reload()
        logger.debug('Updating number of cpus of vm ' + vm_name + ' to ' +
                     str(TestVM._test_vapp_first_vm_new_num_cpu))
        task = vm.modify_cpu(
github vmware / pyvcloud / system_tests / vm_tests.py View on Github external
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)
github vmware / pyvcloud / system_tests / vapp_tests.py View on Github external
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()
github vmware / pyvcloud / system_tests / catalog_tests.py View on Github external
import of the template as catalog item to finish.

        :param pyvcloud.vcd.org.Org org: the organization which contains the
            catalog to which the templates will be uploaded to.
        :param str catalog_name: name of the catalog to which the template will
            be uploaded to.
        :param str template_name: name of the catalog item which represents the
            uploaded template
        :param str template_file_name: name of the local template file which
            will be uploaded.

        :raises: EntityNotFoundException: if the catalog is not found.
        :raises: InternalServerException: if template already exists in vCD.
        """
        bytes_uploaded = -1
        logger = Environment.get_default_logger()
        logger.debug('Uploading template : ' + template_name)
        bytes_uploaded = org.upload_ovf(
            catalog_name=catalog_name,
            file_name=template_file_name,
            item_name=template_name)
        self.assertNotEqual(bytes_uploaded, -1)
github vmware / pyvcloud / system_tests / gateway_tests.py View on Github external
def _delete_external_network(self, network):
        logger = Environment.get_default_logger()
        platform = Platform(TestGateway._client)
        task = platform.delete_external_network(network.get('name'))
        TestGateway._client.get_task_monitor().wait_for_success(task=task)
        logger.debug('Deleted external network ' + network.get('name') + '.')
github vmware / pyvcloud / system_tests / catalog_tests.py View on Github external
def test_0110_catalog_item_metadata(self):
        """Test the methods related to metadata manipulation in catalog item.

        This test passes if all the metadata operations are successful.
        """
        print("Executing CatalogItem metadata ")

        sys_admin_client = None

        try:
            logger = Environment.get_default_logger()
            sys_admin_client = Environment.get_sys_admin_client()
            org_sys_admin = Environment.get_test_org(sys_admin_client)

            # add new metadata as sys admin
            logger.debug(f'Adding metadata '
                         f'[key={TestCatalog._test_metadata_key},'
                         f'value={TestCatalog._test_metadata_value}]) '
                         f'as Sys admin.')
            task = org_sys_admin.set_metadata_on_catalog_item(
                TestCatalog._test_catalog_name,
                TestCatalog._test_template_name,
                key=TestCatalog._test_metadata_key,
                value=TestCatalog._test_metadata_value)
            result = sys_admin_client.get_task_monitor().wait_for_success(task)
            self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)
github vmware / pyvcloud / system_tests / vdc_tests.py View on Github external
def test_0060_vdc_metadata(self):
        """Test the methods related to metadata manipulation in vdc.py.
        This test passes if all the metadata operations are successful.
        """
        vapp_author_client = None
        sys_admin_client = None
        try:
            logger = Environment.get_default_logger()
            vapp_author_client = Environment.get_client_in_default_org(
                CommonRoles.VAPP_AUTHOR)
            vdc_vapp_author_view = VDC(client=vapp_author_client,
                                       href=get_non_admin_href(
                                           TestOrgVDC._new_vdc_href))
            sys_admin_client = Environment.get_sys_admin_client()
            vdc_sys_admin_view = VDC(client=sys_admin_client,
                                     href=TestOrgVDC._new_vdc_href)
            # try to add new metadata as vapp author
            try:
                logger.debug(f'Adding metadata [key={TestOrgVDC._metadata_key}'
                             ', value={TestOrgVDC._metadata_value}]) as vApp '
                             'author')
                vdc_vapp_author_view.set_metadata(
                    key=TestOrgVDC._metadata_key,
                    value=TestOrgVDC._metadata_value)
github vmware / pyvcloud / system_tests / vapp_tests.py View on Github external
def test_0054_enter_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('Entering maintenance mode of vApp ' + vapp_name)
        vapp.reload()
        result = vapp.enter_maintenance_mode()
        self.assertEqual(result, None)
github vmware / pyvcloud / system_tests / catalog_tests.py View on Github external
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)
github vmware / pyvcloud / system_tests / catalog_tests.py View on Github external
def _0110_catalog_access_settings(self):
        """Test the access control methods for catalogs.

        This test passes if all the acl operations complete successfully.
        """
        logger = Environment.get_default_logger()
        org = Environment.get_test_org(TestCatalog._client)

        org_name = org.get_name()
        print(org_name)
        catalog_name = TestCatalog._test_catalog_name
        vapp_author_username = Environment.get_username_for_role_in_test_org(
            CommonRoles.VAPP_AUTHOR)
        org_admin_username = Environment.get_username_for_role_in_test_org(
            CommonRoles.ORGANIZATION_ADMINISTRATOR)

        # remove all access control settings to the catalog
        logger.debug('Removing all access control settings from catalog:' +
                     catalog_name)
        control_access = org.remove_catalog_access_settings(catalog_name,
                                                            remove_all=True)
        self.assertFalse(hasattr(control_access, 'AccessSettings'))