Exemplo n.º 1
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)
        TestVM._media_resource = Environment.get_test_media_resource()

        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)
        TestVM._test_vapp = vapp
        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)

        logger.debug('Creating empty vApp.')
        TestVM._empty_vapp_href = \
            create_empty_vapp(client=TestVM._client,
                              vdc=vdc,
                              name=TestVM._empty_vapp_name,
                              description=TestVM._empty_vapp_description)
        TestVM._empty_vapp_owner_name = Environment. \
            get_username_for_role_in_test_org(TestVM._test_runner_role)

        #Create independent disk
        TestVM._idisk = vdc.create_disk(name=self._idisk_name,
                                        size=self._idisk_size,
                                        description=self._idisk_description)
Exemplo n.º 2
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._pvdc_name = Environment.get_test_pvdc_name()
        TestVApp._config = Environment.get_config()
        TestVApp._default_org_name = TestVApp._config['vcd'][
            'default_org_name']
        TestVApp._client = Environment.get_client_in_default_org(
            TestVApp._test_runner_role)
        TestVApp._sys_admin_client = Environment.get_sys_admin_client()
        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)
        TestVApp._create_org_vdc()

        self.assertIsNotNone(TestVApp._empty_vapp_href)
        self.assertIsNotNone(TestVApp._customized_vapp_href)
Exemplo n.º 3
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)
        TestVM._media_resource = Environment.get_test_media_resource()

        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)

        logger.debug('Creating empty vApp.')
        TestVM._empty_vapp_href = \
            create_empty_vapp(client=TestVM._client,
                              vdc=vdc,
                              name=TestVM._empty_vapp_name,
                              description=TestVM._empty_vapp_description)
        TestVM._empty_vapp_owner_name = Environment. \
            get_username_for_role_in_test_org(TestVM._test_runner_role)
Exemplo n.º 4
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)
        TestVApp._sys_admin_client = Environment.get_sys_admin_client()
        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)
Exemplo n.º 5
0
    def test_0000_setup(self):
        """Load configuration and create a click runner to invoke CLI."""
        logger = Environment.get_default_logger()
        VmTest._config = Environment.get_config()
        VmTest._logger = logger
        VmTest._client = Environment.get_client_in_default_org(
            CommonRoles.ORGANIZATION_ADMINISTRATOR)
        VmTest._media_resource = Environment.get_test_media_resource()

        VmTest._runner = CliRunner()
        default_org = VmTest._config['vcd']['default_org_name']
        VmTest._login(self)
        VmTest._runner.invoke(org, ['use', default_org])

        default_ovdc = VmTest._config['vcd']['default_ovdc_name']
        VmTest._default_ovdc = default_ovdc
        VmTest._runner.invoke(vdc, ['use', VmTest._default_ovdc])

        VmTest._test_vdc = Environment.get_test_vdc(VmTest._client)
        VmTest._test_vapp = Environment.get_test_vapp_with_network(
            VmTest._client)
        VmTest._test_old_vapp_href = VmTest._test_vapp.get_resource().get(
            'href')
        self.assertIsNotNone(VmTest._test_old_vapp_href)
        logger.debug("Old vapp href is : " + VmTest._test_old_vapp_href)

        VmTest._test_vm = VM(VmTest._client,
                             href=VmTest._test_vapp.get_vm(
                                 VAppConstants.vm1_name).get('href'))
        self.assertIsNotNone(
            VmTest._test_vapp.get_vm(VAppConstants.vm1_name).get('href'))
        logger.debug(
            "Old vapp VM href is : " +
            VmTest._test_vapp.get_vm(VAppConstants.vm1_name).get('href'))

        vdc1 = Environment.get_test_vdc(VmTest._client)
        logger.debug('Creating empty vApp.')
        VmTest._empty_vapp_href = \
            create_empty_vapp(client=VmTest._client,
                              vdc=vdc1,
                              name=VmTest._empty_vapp_name,
                              description=VmTest._empty_vapp_description)
        self.assertIsNotNone(VmTest._empty_vapp_href)
        logger.debug("Empty vapp href is: " + VmTest._empty_vapp_href)

        # Create independent disk
        VmTest._idisk_id = create_independent_disk(
            client=VmTest._client,
            vdc=vdc1,
            name=self._idisk_name,
            size=self._idisk_size,
            description=self._idisk_description)
        self.assertIsNotNone(VmTest._idisk_id)

        logger.debug("Independent disk id is: " + VmTest._idisk_id)

        # Upload template with vm tools.
        catalog_author_client = Environment.get_client_in_default_org(
            CommonRoles.CATALOG_AUTHOR)
        org_admin_client = Environment.get_client_in_default_org(
            CommonRoles.ORGANIZATION_ADMINISTRATOR)
        org1 = Environment.get_test_org(org_admin_client)
        catalog_name = Environment.get_config()['vcd']['default_catalog_name']
        catalog_items = org1.list_catalog_items(catalog_name)
        config = Environment.get_config()
        template_name = config['vcd']['default_template_vmtools_file_name']
        catalog_item_flag = False
        for item in catalog_items:
            if item.get('name').lower() == template_name.lower():
                logger.debug('Reusing existing template ' + template_name)
                catalog_item_flag = True
                break
        if not catalog_item_flag:
            logger.debug('Uploading template ' + template_name +
                         ' to catalog ' + catalog_name + '.')
            org1.upload_ovf(catalog_name=catalog_name, file_name=template_name)
            # wait for the template import to finish in vCD.
            catalog_item = org1.get_catalog_item(name=catalog_name,
                                                 item_name=template_name)
            template = catalog_author_client.get_resource(
                catalog_item.Entity.get('href'))
            catalog_author_client.get_task_monitor().wait_for_success(
                task=template.Tasks.Task[0])
            logger.debug("Template upload comleted for: " + template_name)

        # Create Vapp with template of vmware tools
        logger.debug('Creating vApp ' + VmTest._test_vapp_vmtools_name)
        VmTest._test_vapp_vmtools_href = create_customized_vapp_from_template(
            client=VmTest._client,
            vdc=vdc1,
            name=VmTest._test_vapp_vmtools_name,
            catalog_name=catalog_name,
            template_name=template_name)
        self.assertIsNotNone(VmTest._test_vapp_vmtools_href)
        logger.debug("vmtools vapp href is: " + VmTest._test_vapp_vmtools_href)
        vapp = VApp(VmTest._client, href=VmTest._test_vapp_vmtools_href)
        VmTest._test_vapp_vmtools = vapp
        vm_resource = vapp.get_vm(VmTest._test_vapp_vmtools_vm_name)
        VmTest._test_vapp_vmtools_vm_href = vm_resource.get('href')
        self.assertIsNotNone(VmTest._test_vapp_vmtools_vm_href)
        temp_name = config['vcd']['default_template_file_name']
        VmTest._test_vapp_href = create_customized_vapp_from_template(
            client=VmTest._client,
            vdc=vdc1,
            name=VmTest._vapp_name,
            catalog_name=catalog_name,
            template_name=temp_name)
        self.assertIsNotNone(VmTest._test_vapp_href)

        VmTest._sys_admin_client = Environment.get_sys_admin_client()
        resource = VmTest._sys_admin_client.get_extension()
        result = VmTest._sys_admin_client.get_linked_resource(
            resource, RelationType.DOWN, EntityType.DATASTORE_REFERENCES.value)
        if hasattr(result, '{' + NSMAP['vcloud'] + '}Reference'):
            for reference in result['{' + NSMAP['vcloud'] + '}Reference']:
                datastore_id = reference.get('id')
                VmTest._datastore_id = datastore_id.split(':')[3]
                break
        self.assertIsNotNone(VmTest._datastore_id)
Exemplo n.º 6
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)
        TestVM._media_resource = Environment.get_test_media_resource()

        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)
        TestVM._test_vapp = vapp
        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)

        logger.debug('Creating empty vApp.')
        TestVM._empty_vapp_href = \
            create_empty_vapp(client=TestVM._client,
                              vdc=vdc,
                              name=TestVM._empty_vapp_name,
                              description=TestVM._empty_vapp_description)
        TestVM._empty_vapp_owner_name = Environment. \
            get_username_for_role_in_test_org(TestVM._test_runner_role)

        #Create independent disk
        TestVM._idisk = vdc.create_disk(name=self._idisk_name,
                                        size=self._idisk_size,
                                        description=self._idisk_description)

        # Upload template with vm tools.
        catalog_author_client = Environment.get_client_in_default_org(
            CommonRoles.CATALOG_AUTHOR)
        org_admin_client = Environment.get_client_in_default_org(
            CommonRoles.ORGANIZATION_ADMINISTRATOR)
        org = Environment.get_test_org(org_admin_client)
        catalog_name = Environment.get_config()['vcd']['default_catalog_name']
        catalog_items = org.list_catalog_items(catalog_name)
        template_name = Environment.get_config(
        )['vcd']['default_template_vmtools_file_name']
        catalog_item_flag = False
        for item in catalog_items:
            if item.get('name').lower() == template_name.lower():
                logger.debug('Reusing existing template ' + template_name)
                catalog_item_flag = True
                break
        if not catalog_item_flag:
            logger.debug('Uploading template ' + template_name +
                         ' to catalog ' + catalog_name + '.')
            org.upload_ovf(catalog_name=catalog_name, file_name=template_name)
            # wait for the template import to finish in vCD.
            catalog_item = org.get_catalog_item(name=catalog_name,
                                                item_name=template_name)
            template = catalog_author_client.get_resource(
                catalog_item.Entity.get('href'))
            catalog_author_client.get_task_monitor().wait_for_success(
                task=template.Tasks.Task[0])
        # Create Vapp with template of vmware tools
        logger.debug('Creating vApp ' + TestVM._test_vapp_vmtools_name + '.')
        TestVM._test_vapp_vmtools_href = create_customized_vapp_from_template(
            client=TestVM._client,
            vdc=vdc,
            name=TestVM._test_vapp_vmtools_name,
            catalog_name=catalog_name,
            template_name=template_name)
        self.assertIsNotNone(TestVM._test_vapp_href)
        vapp = VApp(TestVM._client, href=TestVM._test_vapp_vmtools_href)
        TestVM._test_vapp_vmtools = vapp
        vm_resource = vapp.get_vm(TestVM._test_vapp_vmtools_vm_name)
        TestVM._test_vapp_vmtools_vm_href = vm_resource.get('href')
        self.assertIsNotNone(TestVM._test_vapp_vmtools_vm_href)
Exemplo n.º 7
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)
        TestVM._media_resource = Environment.get_test_media_resource()

        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)
        TestVM._test_vapp = vapp
        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)

        logger.debug('Creating empty vApp.')
        TestVM._empty_vapp_href = \
            create_empty_vapp(client=TestVM._client,
                              vdc=vdc,
                              name=TestVM._empty_vapp_name,
                              description=TestVM._empty_vapp_description)
        TestVM._empty_vapp_owner_name = Environment. \
            get_username_for_role_in_test_org(TestVM._test_runner_role)

        # Create independent disk
        TestVM._idisk = vdc.create_disk(name=self._idisk_name,
                                        size=self._idisk_size,
                                        description=self._idisk_description)

        # Upload template with vm tools.
        catalog_author_client = Environment.get_client_in_default_org(
            CommonRoles.CATALOG_AUTHOR)
        org_admin_client = Environment.get_client_in_default_org(
            CommonRoles.ORGANIZATION_ADMINISTRATOR)
        org = Environment.get_test_org(org_admin_client)
        catalog_name = Environment.get_config()['vcd']['default_catalog_name']
        catalog_items = org.list_catalog_items(catalog_name)
        template_name = Environment.get_config(
        )['vcd']['default_template_vmtools_file_name']
        catalog_item_flag = False
        for item in catalog_items:
            if item.get('name').lower() == template_name.lower():
                logger.debug('Reusing existing template ' + template_name)
                catalog_item_flag = True
                break
        if not catalog_item_flag:
            logger.debug('Uploading template ' + template_name +
                         ' to catalog ' + catalog_name + '.')
            org.upload_ovf(catalog_name=catalog_name, file_name=template_name)
            # wait for the template import to finish in vCD.
            catalog_item = org.get_catalog_item(name=catalog_name,
                                                item_name=template_name)
            template = catalog_author_client.get_resource(
                catalog_item.Entity.get('href'))
            catalog_author_client.get_task_monitor().wait_for_success(
                task=template.Tasks.Task[0])
        # Create Vapp with template of vmware tools
        logger.debug('Creating vApp ' + TestVM._test_vapp_vmtools_name + '.')
        TestVM._test_vapp_vmtools_href = create_customized_vapp_from_template(
            client=TestVM._client,
            vdc=vdc,
            name=TestVM._test_vapp_vmtools_name,
            catalog_name=catalog_name,
            template_name=template_name)
        self.assertIsNotNone(TestVM._test_vapp_href)
        vapp = VApp(TestVM._client, href=TestVM._test_vapp_vmtools_href)
        TestVM._test_vapp_vmtools = vapp
        vm_resource = vapp.get_vm(TestVM._test_vapp_vmtools_vm_name)
        TestVM._test_vapp_vmtools_vm_href = vm_resource.get('href')
        self.assertIsNotNone(TestVM._test_vapp_vmtools_vm_href)

        resource = TestVM._sys_admin_client.get_extension()
        result = TestVM._sys_admin_client.get_linked_resource(
            resource, RelationType.DOWN, EntityType.DATASTORE_REFERENCES.value)
        if hasattr(result, '{' + NSMAP['vcloud'] + '}Reference'):
            for reference in result['{' + NSMAP['vcloud'] + '}Reference']:
                if reference.get('name') == 'shared-disk-2':
                    TestVM._datastore_id = reference.get('id')
                    break

        vapp = Environment.get_vapp_in_test_vdc(
            client=TestVM._client, vapp_name=TestVM._test_vapp_name)
        logger.debug('Creating a vApp network in ' + TestVM._test_vapp_name)
        task = vapp.create_vapp_network(
            TestVM._vapp_network_name, TestVM._vapp_network_cidr,
            TestVM._vapp_network_description, TestVM._vapp_network_dns1,
            TestVM._vapp_network_dns2, TestVM._vapp_network_dns_suffix,
            [TestVM._vapp_network_ip_range])
        result = TestVM._client.get_task_monitor().wait_for_success(task)
        self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)
        vapp.reload()