Skip to content

Commit

Permalink
Update provisioning_vmware_host fixture to use Broker contextmanager
Browse files Browse the repository at this point in the history
Signed-off-by: Gaurav Talreja <[email protected]>
  • Loading branch information
Gauravtalreja1 committed Oct 22, 2024
1 parent fe22847 commit 66a9cdf
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
25 changes: 14 additions & 11 deletions pytest_fixtures/component/provision_vmware.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from wrapanapi.systems.virtualcenter import VMWareVirtualMachine

from robottelo.config import settings
from robottelo.hosts import ContentHost


@pytest.fixture(scope='module')
Expand Down Expand Up @@ -112,20 +113,22 @@ def module_vmware_image(


@pytest.fixture
def provisioning_vmware_host(pxe_loader, vmwareclient):
def provisioning_vmware_host(pxe_loader, vmwareclient, module_ssh_key_file):
"""Fixture to check out blank VM on VMware"""
vm_boot_firmware = 'efi' if pxe_loader.vm_firmware.startswith('uefi') else 'bios'
vm_secure_boot = 'true' if pxe_loader.vm_firmware == 'uefi_secureboot' else 'false'
provisioning_host = Broker(
vlan_id = settings.provisioning.vlan_id
with Broker(
workflow='deploy-blank-vm-vcenter',
artifacts='last',
vm_network=settings.provisioning.vlan_id,
host_class=ContentHost,
vm_network=vlan_id,
vm_boot_firmware=vm_boot_firmware,
vm_secure_boot=vm_secure_boot,
).execute()
yield provisioning_host
# delete the host
vmware_host = VMWareVirtualMachine(vmwareclient, name=provisioning_host['name'])
vmware_host.delete()
# check if vm is deleted from VMware
assert vmwareclient.does_vm_exist(provisioning_host['name']) is False
auth=module_ssh_key_file,
) as provisioning_host:
yield provisioning_host
# delete the host
vmware_host = VMWareVirtualMachine(vmwareclient, name=provisioning_host['name'])
vmware_host.delete()
# check if vm is deleted from VMware
assert vmwareclient.does_vm_exist(provisioning_host['name']) is False
7 changes: 4 additions & 3 deletions tests/foreman/api/test_computeresource_vmware.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,13 @@ def test_positive_provision_vmware_pxe_discovery(
2. Provision the host
:expectedresults: Host should be provisioned successfully
"""
mac = provisioning_vmware_host['provisioning_nic_mac_addr']
mac = provisioning_vmware_host._broker_args['provisioning_nic_mac_addr']
sat = module_discovery_sat.sat
# start the provisioning host
vmware_host = VMWareVirtualMachine(vmwareclient, name=provisioning_vmware_host['name'])
vmware_host = VMWareVirtualMachine(
vmwareclient, name=provisioning_vmware_host._broker_args['name']
)
vmware_host.start()
wait_for(
lambda: sat.api.DiscoveredHost().search(query={'mac': mac}) != [],
Expand Down
6 changes: 4 additions & 2 deletions tests/foreman/api/test_provisioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ def test_rhel_pxe_provisioning_secureboot_enabled(
:parametrized: yes
"""
host_mac_addr = provisioning_vmware_host['provisioning_nic_mac_addr']
host_mac_addr = provisioning_vmware_host._broker_args['provisioning_nic_mac_addr']
sat = module_provisioning_sat.sat
host = sat.api.Host(
hostgroup=provisioning_hostgroup,
Expand All @@ -645,7 +645,9 @@ def test_rhel_pxe_provisioning_secureboot_enabled(
request.addfinalizer(lambda: sat.provisioning_cleanup(host.name))

# start the provisioning host on VMware, do not ensure that we can connect to SSHD
vmware_host = VMWareVirtualMachine(vmwareclient, name=provisioning_vmware_host['name'])
vmware_host = VMWareVirtualMachine(
vmwareclient, name=provisioning_vmware_host._broker_args['name']
)
vmware_host.start()

# TODO: Implement Satellite log capturing logic to verify that
Expand Down

0 comments on commit 66a9cdf

Please sign in to comment.