def test_0000_setup(self): """Setup the independent disks for the other tests in this module. Create three independent disks as per the configuration stated above. Also create a vApp that will be used in attach/detach independent disk tests. This test passes if all the three disk ids and the vapp href are not None. """ logger = Environment.get_default_logger() TestDisk._client = Environment.get_client_in_default_org( TestDisk._test_runner_role) vdc = Environment.get_test_vdc(TestDisk._client) logger.debug('Creating disk : ' + TestDisk._idisk1_name) TestDisk._idisk1_id = create_independent_disk( client=TestDisk._client, vdc=vdc, name=TestDisk._idisk1_name, size=TestDisk._idisk1_size, description=TestDisk._idisk1_description) logger.debug('Creating disk : ' + TestDisk._idisk2_name) TestDisk._idisk2_id = create_independent_disk( client=TestDisk._client, vdc=vdc, name=TestDisk._idisk2_name, size=TestDisk._idisk2_size, description=TestDisk._idisk2_description) logger.debug('Creating disk : ' + TestDisk._idisk3_name) TestDisk._idisk3_id = create_independent_disk( client=TestDisk._client, vdc=vdc, name=TestDisk._idisk3_name, size=TestDisk._idisk3_size, description=TestDisk._idisk3_description) logger.debug('Creating vApp ' + TestDisk._test_vapp_name + '.') TestDisk._test_vapp_href = create_customized_vapp_from_template( client=TestDisk._client, vdc=vdc, name=TestDisk._test_vapp_name, catalog_name=Environment.get_default_catalog_name(), template_name=Environment.get_default_template_name(), memory_size=TestDisk._test_vapp_first_vm_memory_size, num_cpu=TestDisk._test_vapp_first_vm_num_cpu, disk_size=TestDisk._test_vapp_first_vm_first_disk_size, vm_name=TestDisk._test_vapp_first_vm_name, nw_adapter_type=TestDisk._test_vapp_first_vm_network_adapter_type) self.assertIsNotNone(TestDisk._idisk1_id) self.assertIsNotNone(TestDisk._idisk2_id) self.assertIsNotNone(TestDisk._idisk3_id) self.assertIsNotNone(TestDisk._test_vapp_href)
def test_0000_setup(self): """Setup the org vdc required for the other tests in this module. """ TestOrgVDC._config = Environment.get_config() logger = Environment.get_default_logger() TestOrgVDC._client = Environment.get_client_in_default_org( CommonRoles.ORGANIZATION_ADMINISTRATOR) TestOrgVDC._runner = CliRunner() default_org = TestOrgVDC._config['vcd']['default_org_name'] TestOrgVDC._login(self) TestOrgVDC._runner.invoke(org, ['use', default_org]) TestOrgVDC._vdc_resource = Environment.get_test_vdc( TestOrgVDC._client).get_resource() TestOrgVDC._vdc1 = VDC(TestOrgVDC._client, href=TestOrgVDC._vdc_resource.get('href')) # Create Independent disk TestOrgVDC._idisk_id = \ create_independent_disk(client=TestOrgVDC._client, vdc=TestOrgVDC._vdc1, name=self._idisk_name, size=self._idisk_size, description=self._idisk_description) self.assertIsNotNone(TestOrgVDC._idisk_id)
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)