diff --git a/conf/vmware.yaml.template b/conf/vmware.yaml.template index 72b333cded6..27cbeadf69f 100644 --- a/conf/vmware.yaml.template +++ b/conf/vmware.yaml.template @@ -1,33 +1,31 @@ VMWARE: - # Vmware to be added as a compute resource - # vmware vcenter URL, e.g. example.com + # VMware to be added as a compute resource + # VCENTER: vmware vcenter URL VCENTER: - # Login for vmware + # USERNAME: Login for vmware USERNAME: - # Password for vmware + # PASSWORD: Password for vmware PASSWORD: - # vmware datacenter + # DATACENTER: vmware datacenter DATACENTER: - # cluster: vmware cluster + # CLUSTER: vmware cluster CLUSTER: - # Name of VM that should be used + # DATASTORE: vmware datastore + DATASTORE: + # VM_NAME: Name of VM to power On/Off & delete VM_NAME: - # mac_address: Mac address of the vm + # MAC_ADDRESS: Mac address of the vm MAC_ADDRESS: - # hypervisor: IP address of the hypervisor + # HYPERVISOR: IP address or hostname of the hypervisor HYPERVISOR: - - - # Vmware Compute resource image data - # Operating system of the image + # VMware Compute resource image data + # IMAGE_OS: Operating system of the image IMAGE_OS: - # Architecture of the image + # IMAGE_ARCH: Architecture of the image IMAGE_ARCH: - # Login to the image + # IMAGE_USERNAME: Login to the image IMAGE_USERNAME: - # Password of that user + # IMAGE_PASSWORD: Password to the image IMAGE_PASSWORD: - # Image name on the external provider + # IMAGE_NAME: Image name on the external provider IMAGE_NAME: - # Interface used for some tests; not required to work with provisioning, not required to be in VLAN - INTERFACE: diff --git a/conftest.py b/conftest.py index 8beb3e3b550..cf2522051ca 100644 --- a/conftest.py +++ b/conftest.py @@ -51,6 +51,7 @@ 'pytest_fixtures.component.provision_gce', 'pytest_fixtures.component.provision_libvirt', 'pytest_fixtures.component.provision_pxe', + 'pytest_fixtures.component.provision_vmware', 'pytest_fixtures.component.provisioning_template', 'pytest_fixtures.component.puppet', 'pytest_fixtures.component.repository', diff --git a/pytest_fixtures/component/provision_vmware.py b/pytest_fixtures/component/provision_vmware.py new file mode 100644 index 00000000000..4517e9fc904 --- /dev/null +++ b/pytest_fixtures/component/provision_vmware.py @@ -0,0 +1,59 @@ +from fauxfactory import gen_string +import pytest + +from robottelo.config import settings + + +@pytest.fixture(scope='module') +def module_vmware_cr(module_provisioning_sat, module_sca_manifest_org, module_location): + vmware_cr = module_provisioning_sat.sat.api.VMWareComputeResource( + name=gen_string('alpha'), + provider='Vmware', + url=settings.vmware.vcenter, + user=settings.vmware.username, + password=settings.vmware.password, + datacenter=settings.vmware.datacenter, + organization=[module_sca_manifest_org], + location=[module_location], + ).create() + return vmware_cr + + +@pytest.fixture +def module_vmware_hostgroup( + module_vmware_cr, + module_provisioning_sat, + module_sca_manifest_org, + module_location, + default_architecture, + module_provisioning_rhel_content, + module_lce_library, + default_partitiontable, + module_provisioning_capsule, + pxe_loader, +): + return module_provisioning_sat.sat.api.HostGroup( + name=gen_string('alpha'), + organization=[module_sca_manifest_org], + location=[module_location], + architecture=default_architecture, + domain=module_provisioning_sat.domain, + content_source=module_provisioning_capsule.id, + content_view=module_provisioning_rhel_content.cv, + compute_resource=module_vmware_cr, + kickstart_repository=module_provisioning_rhel_content.ksrepo, + lifecycle_environment=module_lce_library, + root_pass=settings.provisioning.host_root_password, + operatingsystem=module_provisioning_rhel_content.os, + ptable=default_partitiontable, + subnet=module_provisioning_sat.subnet, + pxe_loader=pxe_loader.pxe_loader, + group_parameters_attributes=[ + # assign AK in order the hosts to be subscribed + { + 'name': 'kt_activation_keys', + 'parameter_type': 'string', + 'value': module_provisioning_rhel_content.ak.name, + }, + ], + ).create() diff --git a/robottelo/constants/__init__.py b/robottelo/constants/__init__.py index a5d7db37956..1a9b0f6c5e2 100644 --- a/robottelo/constants/__init__.py +++ b/robottelo/constants/__init__.py @@ -1725,17 +1725,17 @@ class Colored(Box): STRING_TYPES = ['alpha', 'numeric', 'alphanumeric', 'latin1', 'utf8', 'cjk', 'html'] VMWARE_CONSTANTS = { - 'cluster': 'Satellite-Engineering', + 'cluster': 'SatQE-Cluster', 'folder': 'vm', - 'guest_os': 'Red Hat Enterprise Linux 7 (64-bit)', + 'guest_os': 'Red Hat Enterprise Linux 8 (64-bit)', 'scsicontroller': 'LSI Logic Parallel', 'virtualhw_version': 'Default', 'pool': 'Resources', 'network_interface_name': 'VMXNET 3', - 'datastore': 'Local-Ironforge', - 'network_interfaces': 'qe_%s', + 'datastore': 'SatQE-Datastore', } + HAMMER_CONFIG = "~/.hammer/cli.modules.d/foreman.yml" HAMMER_SESSIONS = "~/.hammer/sessions" diff --git a/robottelo/host_helpers/api_factory.py b/robottelo/host_helpers/api_factory.py index 92f40652d34..027f9b40caa 100644 --- a/robottelo/host_helpers/api_factory.py +++ b/robottelo/host_helpers/api_factory.py @@ -550,14 +550,14 @@ def check_create_os_with_title(self, os_title): :return: Created or found OS """ # Check if OS that image needs is present or no, If not create the OS + os_name, _, os_version = os_title.partition(' ') + os_version_major, os_version_minor = os_version.split('.') result = self._satellite.api.OperatingSystem().search( - query={'search': f'title="{os_title}"'} + query={'search': f'name={os_name}, major={os_version_major}, minor={os_version_minor}'} ) if result: os = result[0] else: - os_name, _, os_version = os_title.partition(' ') - os_version_major, os_version_minor = os_version.split('.') os = self._satellite.api.OperatingSystem( name=os_name, major=os_version_major, minor=os_version_minor ).create() diff --git a/tests/foreman/cli/test_computeresource_vmware.py b/tests/foreman/cli/test_computeresource_vmware.py index ed1164f063c..7c59fda4a19 100644 --- a/tests/foreman/cli/test_computeresource_vmware.py +++ b/tests/foreman/cli/test_computeresource_vmware.py @@ -11,73 +11,25 @@ :CaseImportance: High +:CaseAutomation: Automated + :Upstream: No """ from fauxfactory import gen_string import pytest +from wait_for import wait_for +from wrapanapi import VMWareSystem -from robottelo.cli.factory import make_compute_resource -from robottelo.cli.org import Org from robottelo.config import settings from robottelo.constants import FOREMAN_PROVIDERS -@pytest.fixture(scope='module') -def vmware(module_org, module_location): - vmware = type('vmware', (object,), {})() - vmware.org = module_org - vmware.loc = module_location - Org.add_location({'id': vmware.org.id, 'location-id': vmware.loc.id}) - vmware.vmware_server = settings.vmware.vcenter - vmware.vmware_password = settings.vmware.password - vmware.vmware_username = settings.vmware.username - vmware.vmware_datacenter = settings.vmware.datacenter - vmware.vmware_img_name = settings.vmware.image_name - vmware.vmware_img_arch = settings.vmware.image_arch - vmware.vmware_img_os = settings.vmware.image_os - vmware.vmware_img_user = settings.vmware.image_username - vmware.vmware_img_pass = settings.vmware.image_password - vmware.vmware_vm_name = settings.vmware.vm_name - return vmware - - @pytest.mark.tier1 -def test_positive_create_with_server(vmware): - """Create VMware compute resource with server field - - :id: a06b02c4-fe6a-44ef-bf61-5a28c3905527 - - :customerscenario: true - - :expectedresults: Compute resource is created, server field saved - correctly - - :BZ: 1387917 - - :CaseAutomation: Automated - - :CaseImportance: Critical - """ - cr_name = gen_string('alpha') - vmware_cr = make_compute_resource( - { - 'name': cr_name, - 'provider': FOREMAN_PROVIDERS['vmware'], - 'server': vmware.vmware_server, - 'user': vmware.vmware_username, - 'password': vmware.vmware_password, - 'datacenter': vmware.vmware_datacenter, - } - ) - assert vmware_cr['name'] == cr_name - assert vmware_cr['server'] == vmware.vmware_server - - -@pytest.mark.tier1 -def test_positive_create_with_org(vmware): - """Create VMware Compute Resource with organizations +@pytest.mark.upgrade +def test_positive_create_with_org_and_loc(target_sat, module_org, module_location): + """Create VMware Compute Resource with organizations and locations - :id: 807a1f70-4cc3-4925-b145-0c3b26c57559 + :id: 96faae3f-bc64-4147-a9fc-09c858e0a68f :customerscenario: true @@ -85,84 +37,102 @@ def test_positive_create_with_org(vmware): :BZ: 1387917 - :CaseAutomation: Automated - :CaseImportance: Critical """ cr_name = gen_string('alpha') - vmware_cr = make_compute_resource( + vmware_cr = target_sat.cli.ComputeResource.create( { 'name': cr_name, - 'organization-ids': vmware.org.id, + 'organization-ids': module_org.id, + 'location-ids': module_location.id, 'provider': FOREMAN_PROVIDERS['vmware'], - 'server': vmware.vmware_server, - 'user': vmware.vmware_username, - 'password': vmware.vmware_password, - 'datacenter': vmware.vmware_datacenter, + 'server': settings.vmware.vcenter, + 'user': settings.vmware.username, + 'password': settings.vmware.password, + 'datacenter': settings.vmware.datacenter, } ) assert vmware_cr['name'] == cr_name - - -@pytest.mark.tier1 -def test_positive_create_with_loc(vmware): - """Create VMware Compute Resource with locations - - :id: 214a0f54-6fc2-4e7b-91ab-a45760ffb2f2 - - :customerscenario: true - - :expectedresults: VMware Compute resource is created - - :BZ: 1387917 + assert vmware_cr['locations'][0] == module_location.name + assert vmware_cr['organizations'] == module_org.name + assert vmware_cr['server'] == settings.vmware.vcenter + assert vmware_cr['datacenter'] == settings.vmware.datacenter + + +@pytest.mark.e2e +@pytest.mark.on_premises_provisioning +@pytest.mark.parametrize('setting_update', ['destroy_vm_on_host_delete=True'], indirect=True) +@pytest.mark.parametrize('pxe_loader', ['bios', 'uefi'], indirect=True) +@pytest.mark.parametrize('provision_method', ['build', 'bootdisk']) +@pytest.mark.rhel_ver_match('[^6]') +@pytest.mark.tier3 +def test_positive_provision_end_to_end( + request, + setting_update, + module_provisioning_sat, + module_sca_manifest_org, + module_location, + pxe_loader, + module_vmware_cr, + module_vmware_hostgroup, + provision_method, +): + """Provision a host on vmware compute resource with + the help of hostgroup. + + :id: ff9963fc-a2a7-4392-aa9a-190d5d1c8357 + + :steps: + + 1. Configure provisioning setup. + 2. Create VMware CR + 3. Configure host group setup. + 4. Provision a host on VMware + 5. Verify created host on VMware with wrapanapi + + :expectedresults: Host is provisioned succesfully with hostgroup :CaseAutomation: Automated - - :CaseImportance: Critical """ - cr_name = gen_string('alpha') - vmware_cr = make_compute_resource( + sat = module_provisioning_sat.sat + hostname = gen_string('alpha').lower() + host = sat.cli.Host.create( { - 'name': cr_name, - 'location-ids': vmware.loc.id, - 'provider': FOREMAN_PROVIDERS['vmware'], - 'server': vmware.vmware_server, - 'user': vmware.vmware_username, - 'password': vmware.vmware_password, - 'datacenter': vmware.vmware_datacenter, + 'name': hostname, + 'organization': module_sca_manifest_org.name, + 'location': module_location.name, + 'hostgroup': module_vmware_hostgroup.name, + 'compute-resource-id': module_vmware_cr.id, + 'ip': None, + 'mac': None, + 'compute-attributes': f'cluster={settings.vmware.cluster},' + f'path=/Datacenters/{settings.vmware.datacenter}/vm/,' + 'scsi_controller_type=VirtualLsiLogicController,' + 'guest_id=rhel8_64Guest,firmware=automatic,' + 'cpus=1,memory_mb=6000, start=1', + 'interface': f'compute_type=VirtualVmxnet3,' + f'compute_network=VLAN {settings.provisioning.vlan_id}', + 'volume': f'name=Hard disk,size_gb=10,thin=true,eager_zero=false,datastore={settings.vmware.datastore}', + 'provision-method': provision_method, } ) - assert vmware_cr['name'] == cr_name - - -@pytest.mark.tier1 -@pytest.mark.upgrade -def test_positive_create_with_org_and_loc(vmware): - """Create VMware Compute Resource with organizations and locations - - :id: 96faae3f-bc64-4147-a9fc-09c858e0a68f - - :customerscenario: true - - :expectedresults: VMware Compute resource is created - - :BZ: 1387917 - - :CaseAutomation: Automated - - :CaseImportance: Critical - """ - cr_name = gen_string('alpha') - vmware_cr = make_compute_resource( - { - 'name': cr_name, - 'organization-ids': vmware.org.id, - 'location-ids': vmware.loc.id, - 'provider': FOREMAN_PROVIDERS['vmware'], - 'server': vmware.vmware_server, - 'user': vmware.vmware_username, - 'password': vmware.vmware_password, - 'datacenter': vmware.vmware_datacenter, - } + # teardown + request.addfinalizer(lambda: sat.cli.Host.delete({'id': host['id']})) + + hostname = f'{hostname}.{module_provisioning_sat.domain.name}' + assert hostname == host['name'] + # check if vm is created on vmware + vmware = VMWareSystem( + hostname=settings.vmware.vcenter, + username=settings.vmware.username, + password=settings.vmware.password, ) - assert vmware_cr['name'] == cr_name + assert vmware.does_vm_exist(hostname) is True + wait_for( + lambda: sat.cli.Host.info({'name': hostname})['status']['build-status'] + != 'Pending installation', + timeout=1800, + delay=30, + ) + host_info = sat.cli.Host.info({'id': host['id']}) + assert host_info['status']['build-status'] == 'Installed' diff --git a/tests/foreman/longrun/test_provisioning_computeresource.py b/tests/foreman/longrun/test_provisioning_computeresource.py deleted file mode 100644 index 65444304df0..00000000000 --- a/tests/foreman/longrun/test_provisioning_computeresource.py +++ /dev/null @@ -1,239 +0,0 @@ -""" -:CaseLevel: Acceptance - -:CaseComponent: ComputeResources - -:Team: Rocket - -:TestType: Functional - -:CaseImportance: Critical - -:Upstream: No -""" -from fauxfactory import gen_string -import pytest -from wrapanapi import VMWareSystem - -from robottelo.cli.factory import make_compute_resource, make_host -from robottelo.cli.host import Host -from robottelo.config import settings -from robottelo.constants import FOREMAN_PROVIDERS, VMWARE_CONSTANTS - - -@pytest.fixture(scope="module") -def vmware(): - bridge = settings.vlan_networking.bridge - vmware = type("", (), {})() - vmware.vmware_server = settings.vmware.vcenter - vmware.vmware_password = settings.vmware.password - vmware.vmware_username = settings.vmware.username - vmware.vmware_datacenter = settings.vmware.datacenter - vmware.vmware_img_name = settings.vmware.image_name - vmware.vmware_img_arch = settings.vmware.image_arch - vmware.vmware_img_os = settings.vmware.image_os - vmware.vmware_img_user = settings.vmware.image_username - vmware.vmware_img_pass = settings.vmware.image_password - vmware.vmware_vm_name = settings.vmware.vm_name - vmware.current_interface = VMWARE_CONSTANTS.get('network_interfaces') % bridge - vmware.vmware_api = VMWareSystem( - hostname=vmware.vmware_server, - username=vmware.vmware_username, - password=vmware.vmware_password, - ) - vmware.vmware_net_id = vmware.vmware_api.get_network(vmware.current_interface)._moId - return vmware - - -@pytest.fixture(scope="module") -def provisioning(module_org, module_location, module_target_sat): - os = None - if hasattr(settings, 'rhev') and hasattr(settings.rhev, 'image_os') and settings.rhev.image_os: - os = settings.rhev.image_os - provisioning = type("", (), {})() - provisioning.org_name = module_org.name - provisioning.loc_name = module_location.name - provisioning.config_env = module_target_sat.api_factory.configure_provisioning( - compute=True, org=module_org, loc=module_location, os=os - ) - provisioning.os_name = provisioning.config_env['os'] - return provisioning - - -@pytest.fixture(scope="module") -def vmware_cr(provisioning, vmware): - return make_compute_resource( - { - 'name': gen_string('alpha'), - 'organizations': provisioning.org_name, - 'locations': provisioning.loc_name, - 'provider': FOREMAN_PROVIDERS['vmware'], - 'server': vmware.vmware_server, - 'user': vmware.vmware_username, - 'password': vmware.vmware_password, - 'datacenter': vmware.vmware_datacenter, - } - ) - - -@pytest.fixture(scope="function") -def tear_down(provisioning): - """Delete the hosts to free the resources""" - yield - hosts = Host.list({'organization': provisioning.org_name}) - for host in hosts: - Host.delete({'id': host['id']}) - - -@pytest.mark.on_premises_provisioning -@pytest.mark.vlan_networking -@pytest.mark.tier3 -def test_positive_provision_vmware_with_host_group( - vmware, provisioning, tear_down, vmware_cr, target_sat -): - """Provision a host on vmware compute resource with - the help of hostgroup. - - :Requirement: Computeresource Vmware - - :CaseComponent: ComputeResources-VMWare - - :Team: Rocket - - :customerscenario: true - - :id: ae4d5949-f0e6-44ca-93b6-c5241a02b64b - - :setup: - - 1. Vaild vmware hostname ,credentials. - 2. Configure provisioning setup. - 3. Configure host group setup. - - :steps: - - 1. Go to "Hosts --> New host". - 2. Assign the host group to the host. - 3. Select the Deploy on as vmware Compute Resource. - 4. Provision the host. - - :expectedresults: The host should be provisioned with host group - - :CaseAutomation: Automated - - :CaseLevel: System - """ - host_name = gen_string('alpha').lower() - host = make_host( - { - 'name': f'{host_name}', - 'root-password': gen_string('alpha'), - 'organization': provisioning.org_name, - 'location': provisioning.loc_name, - 'hostgroup': provisioning.config_env['host_group'], - 'pxe-loader': 'PXELinux BIOS', - 'compute-resource-id': vmware_cr.get('id'), - 'compute-attributes': "cpus=2," - "corespersocket=2," - "memory_mb=4028," - "cluster={}," - "path=/Datacenters/{}/vm/QE," - "guest_id=rhel7_64Guest," - "scsi_controller_type=VirtualLsiLogicController," - "hardware_version=Default," - "start=1".format(VMWARE_CONSTANTS['cluster'], vmware.vmware_datacenter), - 'ip': None, - 'mac': None, - 'interface': "compute_network={}," - "compute_type=VirtualVmxnet3".format(vmware.vmware_net_id), - 'volume': "name=Hard disk," - "size_gb=10," - "thin=true," - "eager_zero=false," - "datastore={}".format(VMWARE_CONSTANTS['datastore'].split()[0]), - 'provision-method': 'build', - } - ) - hostname = '{}.{}'.format(host_name, provisioning.config_env['domain']) - assert hostname == host['name'] - # Check on Vmware, if VM exists - assert vmware.vmware_api.does_vm_exist(hostname) - host_info = Host.info({'name': hostname}) - host_ip = host_info.get('network').get('ipv4-address') - # Start to run a ping check if network was established on VM - target_sat.ping_host(host=host_ip) - - -@pytest.mark.on_premises_provisioning -@pytest.mark.vlan_networking -@pytest.mark.tier3 -def test_positive_provision_vmware_with_host_group_bootdisk( - vmware, provisioning, tear_down, vmware_cr, target_sat -): - """Provision a bootdisk based host on VMWare compute resource. - - :Requirement: Computeresource Vmware - - :CaseComponent: ComputeResources-VMWare - - :id: bc5f457d-c29a-4c62-bbdc-af8f4f813519 - - :bz: 1679225 - - :setup: - - 1. Vaild VMWare hostname, credentials. - 2. Configure provisioning setup. - 3. Configure host group setup. - - :steps: Using Hammer CLI, Provision a VM on VMWare with hostgroup and - provisioning method as `bootdisk`. - - :expectedresults: The host should be provisioned with provisioning type bootdisk - - :CaseAutomation: Automated - - :customerscenario: true - - :CaseLevel: System - """ - host_name = gen_string('alpha').lower() - host = make_host( - { - 'name': f'{host_name}', - 'root-password': gen_string('alpha'), - 'organization': provisioning.org_name, - 'location': provisioning.loc_name, - 'hostgroup': provisioning.config_env['host_group'], - 'pxe-loader': 'PXELinux BIOS', - 'compute-resource-id': vmware_cr.get('id'), - 'content-source-id': '1', - 'compute-attributes': "cpus=2," - "corespersocket=2," - "memory_mb=4028," - "cluster={}," - "path=/Datacenters/{}/vm/QE," - "guest_id=rhel7_64Guest," - "scsi_controllers=`type=VirtualLsiLogicController,key=1000'," - "hardware_version=Default," - "start=1".format(VMWARE_CONSTANTS['cluster'], vmware.vmware_datacenter), - "ip": None, - "mac": None, - 'interface': "compute_network={}," - "compute_type=VirtualVmxnet3".format(vmware.vmware_net_id), - 'volume': "name=Hard disk," - "size_gb=10," - "thin=true," - "eager_zero=false," - "datastore={}".format(VMWARE_CONSTANTS['datastore'].split()[0]), - 'provision-method': 'bootdisk', - } - ) - hostname = '{}.{}'.format(host_name, provisioning.config_env['domain']) - assert hostname == host['name'] - # Check on Vmware, if VM exists - assert vmware.vmware_api.does_vm_exist(hostname) - host_info = Host.info({'name': hostname}) - host_ip = host_info.get('network').get('ipv4-address') - # Start to run a ping check if network was established on VM - target_sat.ping_host(host=host_ip) diff --git a/tests/foreman/ui/test_computeresource_vmware.py b/tests/foreman/ui/test_computeresource_vmware.py index dfe4ca1abe7..0b3288c7293 100644 --- a/tests/foreman/ui/test_computeresource_vmware.py +++ b/tests/foreman/ui/test_computeresource_vmware.py @@ -85,35 +85,8 @@ def _get_vmware_datastore_summary_string(data_store_name=VMWARE_CONSTANTS['datas return f'{data_store_name} (free: {free_space}, prov: {prov}, total: {capacity})' -@pytest.fixture(scope='module') -def module_org(): - return entities.Organization().create() - - -@pytest.fixture(scope='module') -def module_vmware_settings(): - ret = dict( - vcenter=settings.vmware.vcenter, - user=settings.vmware.username, - password=settings.vmware.password, - datacenter=settings.vmware.datacenter, - image_name=settings.vmware.image_name, - image_arch=settings.vmware.image_arch, - image_os=settings.vmware.image_os, - image_username=settings.vmware.image_username, - image_password=settings.vmware.image_password, - vm_name=settings.vmware.vm_name, - cluster=settings.vmware.cluster, - mac_address=settings.vmware.mac_address, - hypervisor=settings.vmware.hypervisor, - ) - if 'INTERFACE' in settings.vmware: - ret['interface'] = VMWARE_CONSTANTS['network_interfaces'] % settings.vmware.interface - return ret - - @pytest.mark.tier1 -def test_positive_end_to_end(session, module_org, module_location, module_vmware_settings): +def test_positive_end_to_end(session, module_org, module_location): """Perform end to end testing for compute resource VMware component. :id: 47fc9e77-5b22-46b4-a76c-3217434fde2f @@ -136,10 +109,10 @@ def test_positive_end_to_end(session, module_org, module_location, module_vmware 'name': cr_name, 'description': description, 'provider': FOREMAN_PROVIDERS['vmware'], - 'provider_content.vcenter': module_vmware_settings['vcenter'], - 'provider_content.user': module_vmware_settings['user'], - 'provider_content.password': module_vmware_settings['password'], - 'provider_content.datacenter.value': module_vmware_settings['datacenter'], + 'provider_content.vcenter': settings.vmware.vcenter, + 'provider_content.user': settings.vmware.username, + 'provider_content.password': settings.vmware.password, + 'provider_content.datacenter.value': settings.vmware.datacenter, 'provider_content.display_type': display_type, 'provider_content.vnc_console_passwords': vnc_console_passwords, 'provider_content.enable_caching': enable_caching, @@ -151,11 +124,8 @@ def test_positive_end_to_end(session, module_org, module_location, module_vmware assert cr_values['name'] == cr_name assert cr_values['description'] == description assert cr_values['provider'] == FOREMAN_PROVIDERS['vmware'] - assert cr_values['provider_content']['user'] == module_vmware_settings['user'] - assert ( - cr_values['provider_content']['datacenter']['value'] - == module_vmware_settings['datacenter'] - ) + assert cr_values['provider_content']['user'] == settings.vmware.username + assert cr_values['provider_content']['datacenter']['value'] == settings.vmware.datacenter assert cr_values['provider_content']['display_type'] == display_type assert cr_values['provider_content']['vnc_console_passwords'] == vnc_console_passwords assert cr_values['provider_content']['enable_caching'] == enable_caching @@ -189,7 +159,7 @@ def test_positive_end_to_end(session, module_org, module_location, module_vmware @pytest.mark.tier2 -def test_positive_retrieve_virtual_machine_list(session, module_vmware_settings): +def test_positive_retrieve_virtual_machine_list(session): """List the virtual machine list from vmware compute resource :id: 21ade57a-0caa-4144-9c46-c8e22f33414e @@ -206,16 +176,16 @@ def test_positive_retrieve_virtual_machine_list(session, module_vmware_settings) :CaseLevel: Integration """ cr_name = gen_string('alpha') - vm_name = module_vmware_settings['vm_name'] + vm_name = settings.vmware.vm_name with session: session.computeresource.create( { 'name': cr_name, 'provider': FOREMAN_PROVIDERS['vmware'], - 'provider_content.vcenter': module_vmware_settings['vcenter'], - 'provider_content.user': module_vmware_settings['user'], - 'provider_content.password': module_vmware_settings['password'], - 'provider_content.datacenter.value': module_vmware_settings['datacenter'], + 'provider_content.vcenter': settings.vmware.vcenter, + 'provider_content.user': settings.vmware.username, + 'provider_content.password': settings.vmware.password, + 'provider_content.datacenter.value': settings.vmware.datacenter, } ) assert session.computeresource.search(cr_name)[0]['Name'] == cr_name @@ -225,7 +195,7 @@ def test_positive_retrieve_virtual_machine_list(session, module_vmware_settings) @pytest.mark.tier2 -def test_positive_image_end_to_end(session, module_vmware_settings, target_sat): +def test_positive_image_end_to_end(session, target_sat): """Perform end to end testing for compute resource VMware component image. :id: 6b7949ef-c684-40aa-b181-11f8d4cd39c6 @@ -237,17 +207,17 @@ def test_positive_image_end_to_end(session, module_vmware_settings, target_sat): cr_name = gen_string('alpha') image_name = gen_string('alpha') new_image_name = gen_string('alpha') - target_sat.api_factory.check_create_os_with_title(module_vmware_settings['image_os']) + os = target_sat.api_factory.check_create_os_with_title(settings.vmware.image_os) image_user_data = choice((False, True)) with session: session.computeresource.create( { 'name': cr_name, 'provider': FOREMAN_PROVIDERS['vmware'], - 'provider_content.vcenter': module_vmware_settings['vcenter'], - 'provider_content.user': module_vmware_settings['user'], - 'provider_content.password': module_vmware_settings['password'], - 'provider_content.datacenter.value': module_vmware_settings['datacenter'], + 'provider_content.vcenter': settings.vmware.vcenter, + 'provider_content.user': settings.vmware.username, + 'provider_content.password': settings.vmware.password, + 'provider_content.datacenter.value': settings.vmware.datacenter, } ) assert session.computeresource.search(cr_name)[0]['Name'] == cr_name @@ -255,21 +225,21 @@ def test_positive_image_end_to_end(session, module_vmware_settings, target_sat): cr_name, dict( name=image_name, - operating_system=module_vmware_settings['image_os'], - architecture=module_vmware_settings['image_arch'], - username=module_vmware_settings['image_username'], + operating_system=os.title, + architecture=settings.vmware.image_arch, + username=settings.vmware.image_username, user_data=image_user_data, - password=module_vmware_settings['image_password'], - image=module_vmware_settings['image_name'], + password=settings.vmware.image_password, + image=settings.vmware.image_name, ), ) values = session.computeresource.read_image(cr_name, image_name) assert values['name'] == image_name - assert values['operating_system'] == module_vmware_settings['image_os'] - assert values['architecture'] == module_vmware_settings['image_arch'] - assert values['username'] == module_vmware_settings['image_username'] + assert values['operating_system'] == os.title + assert values['architecture'] == settings.vmware.image_arch + assert values['username'] == settings.vmware.image_username assert values['user_data'] == image_user_data - assert values['image'] == module_vmware_settings['image_name'] + assert values['image'] == settings.vmware.image_name session.computeresource.update_image(cr_name, image_name, dict(name=new_image_name)) assert session.computeresource.search_images(cr_name, image_name)[0]['Name'] != image_name assert ( @@ -285,7 +255,7 @@ def test_positive_image_end_to_end(session, module_vmware_settings, target_sat): @pytest.mark.tier2 @pytest.mark.run_in_one_thread -def test_positive_resource_vm_power_management(session, module_vmware_settings): +def test_positive_resource_vm_power_management(session): """Read current VMware Compute Resource virtual machine power status and change it to opposite one @@ -296,16 +266,16 @@ def test_positive_resource_vm_power_management(session, module_vmware_settings): :CaseLevel: Integration """ cr_name = gen_string('alpha') - vm_name = module_vmware_settings['vm_name'] + vm_name = settings.vmware.vm_name with session: session.computeresource.create( { 'name': cr_name, 'provider': FOREMAN_PROVIDERS['vmware'], - 'provider_content.vcenter': module_vmware_settings['vcenter'], - 'provider_content.user': module_vmware_settings['user'], - 'provider_content.password': module_vmware_settings['password'], - 'provider_content.datacenter.value': module_vmware_settings['datacenter'], + 'provider_content.vcenter': settings.vmware.vcenter, + 'provider_content.user': settings.vmware.username, + 'provider_content.password': settings.vmware.password, + 'provider_content.datacenter.value': settings.vmware.datacenter, } ) assert session.computeresource.search(cr_name)[0]['Name'] == cr_name @@ -329,7 +299,7 @@ def test_positive_resource_vm_power_management(session, module_vmware_settings): @pytest.mark.tier2 -def test_positive_select_vmware_custom_profile_guest_os_rhel7(session, module_vmware_settings): +def test_positive_select_vmware_custom_profile_guest_os_rhel7(session): """Select custom default (3-Large) compute profile guest OS RHEL7. :id: 24f7bb5f-2aaf-48cb-9a56-d2d0713dfe3d @@ -360,10 +330,10 @@ def test_positive_select_vmware_custom_profile_guest_os_rhel7(session, module_vm { 'name': cr_name, 'provider': FOREMAN_PROVIDERS['vmware'], - 'provider_content.vcenter': module_vmware_settings['vcenter'], - 'provider_content.user': module_vmware_settings['user'], - 'provider_content.password': module_vmware_settings['password'], - 'provider_content.datacenter.value': module_vmware_settings['datacenter'], + 'provider_content.vcenter': settings.vmware.vcenter, + 'provider_content.user': settings.vmware.username, + 'provider_content.password': settings.vmware.password, + 'provider_content.datacenter.value': settings.vmware.datacenter, } ) assert session.computeresource.search(cr_name)[0]['Name'] == cr_name @@ -375,7 +345,7 @@ def test_positive_select_vmware_custom_profile_guest_os_rhel7(session, module_vm @pytest.mark.tier2 -def test_positive_access_vmware_with_custom_profile(session, module_vmware_settings): +def test_positive_access_vmware_with_custom_profile(session): """Associate custom default (3-Large) compute profile :id: 751ef765-5091-4322-a0d9-0c9c73009cc4 @@ -412,15 +382,15 @@ def test_positive_access_vmware_with_custom_profile(session, module_vmware_setti cdrom_drive=True, annotation_notes=gen_string('alpha'), network_interfaces=[] - if 'interface' not in module_vmware_settings + if not settings.provisioning.vlan_id else [ dict( nic_type=VMWARE_CONSTANTS.get('network_interface_name'), - network=module_vmware_settings['interface'], + network=f'VLAN {settings.provisioning.vlan_id}', ), dict( nic_type=VMWARE_CONSTANTS.get('network_interface_name'), - network=module_vmware_settings['interface'], + network=f'VLAN {settings.provisioning.vlan_id}', ), ], storage=[ @@ -458,10 +428,10 @@ def test_positive_access_vmware_with_custom_profile(session, module_vmware_setti { 'name': cr_name, 'provider': FOREMAN_PROVIDERS['vmware'], - 'provider_content.vcenter': module_vmware_settings['vcenter'], - 'provider_content.user': module_vmware_settings['user'], - 'provider_content.password': module_vmware_settings['password'], - 'provider_content.datacenter.value': module_vmware_settings['datacenter'], + 'provider_content.vcenter': settings.vmware.vcenter, + 'provider_content.user': settings.vmware.username, + 'provider_content.password': settings.vmware.password, + 'provider_content.datacenter.value': settings.vmware.datacenter, } ) assert session.computeresource.search(cr_name)[0]['Name'] == cr_name @@ -507,9 +477,7 @@ def test_positive_access_vmware_with_custom_profile(session, module_vmware_setti @pytest.mark.tier2 -def test_positive_virt_card( - session, target_sat, module_vmware_settings, module_location, module_org -): +def test_positive_virt_card(session, target_sat, module_location, module_org): """Check to see that the Virtualization card appears for an imported VM :id: 0502d5a6-64c1-422f-a9ba-ac7c2ee7bad2 @@ -574,10 +542,10 @@ def test_positive_virt_card( { 'name': cr_name, 'provider': FOREMAN_PROVIDERS['vmware'], - 'provider_content.vcenter': module_vmware_settings['vcenter'], - 'provider_content.user': module_vmware_settings['user'], - 'provider_content.password': module_vmware_settings['password'], - 'provider_content.datacenter.value': module_vmware_settings['datacenter'], + 'provider_content.vcenter': settings.vmware.vcenter, + 'provider_content.user': settings.vmware.username, + 'provider_content.password': settings.vmware.password, + 'provider_content.datacenter.value': settings.vmware.datacenter, 'locations.resources.assigned': [module_location.name], 'organizations.resources.assigned': [module_org.name], } @@ -585,23 +553,19 @@ def test_positive_virt_card( session.hostgroup.update(hostgroup_name, {'host_group.deploy': cr_name + " (VMware)"}) session.computeresource.vm_import( cr_name, - module_vmware_settings['vm_name'], + settings.vmware.vm_name, hostgroup_name, module_location.name, - module_org.name, - module_vmware_settings['vm_name'], ) - host_name = module_vmware_settings['vm_name'] + '.' + domain.name - power_status = session.computeresource.vm_status(cr_name, module_vmware_settings['vm_name']) + host_name = settings.vmware.vm_name + '.' + domain.name + power_status = session.computeresource.vm_status(cr_name, settings.vmware.vm_name) if power_status is False: - session.computeresource.vm_poweron(cr_name, module_vmware_settings['vm_name']) + session.computeresource.vm_poweron(cr_name, settings.vmware.vm_name) try: wait_for( lambda: ( session.browser.refresh(), - session.computeresource.vm_status( - cr_name, module_vmware_settings['vm_name'] - ), + session.computeresource.vm_status(cr_name, settings.vmware.vm_name), )[1] is not power_status, timeout=30, @@ -611,11 +575,11 @@ def test_positive_virt_card( raise AssertionError('Timed out waiting for VM to toggle power state') virt_card = session.host_new.get_virtualization(host_name)['details'] - assert virt_card['datacenter'] == module_vmware_settings['datacenter'] - assert virt_card['cluster'] == module_vmware_settings['cluster'] - assert virt_card['memory'] == '2 GB' + assert virt_card['datacenter'] == settings.vmware.datacenter + assert virt_card['cluster'] == settings.vmware.cluster + assert virt_card['memory'] == '5 GB' assert 'public_ip_address' in virt_card - assert virt_card['mac_address'] == module_vmware_settings['mac_address'] + assert virt_card['mac_address'] == settings.vmware.mac_address assert virt_card['cpus'] == '1' if 'disk_label' in virt_card: assert virt_card['disk_label'] == 'Hard disk 1'