Skip to content

Commit

Permalink
virtwho config hammer deploy option name organization-title and locat…
Browse files Browse the repository at this point in the history
…ion-id support (SatelliteQE#13632)

* virtwho config hammer option name organization-title and location-id support

* use fstring and optimize duplicated code

* remove print

* Update pytest_fixtures/component/virtwho_config.py

Co-authored-by: Shubham Ganar <[email protected]>

* Update pytest_fixtures/component/virtwho_config.py

Co-authored-by: Shubham Ganar <[email protected]>

* Update pytest_fixtures/component/virtwho_config.py

Co-authored-by: Shubham Ganar <[email protected]>

* Update pytest_fixtures/component/virtwho_config.py

Co-authored-by: Shubham Ganar <[email protected]>

---------

Co-authored-by: Shubham Ganar <[email protected]>
  • Loading branch information
2 people authored and shweta83 committed Apr 10, 2024
1 parent 5936772 commit 294f712
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 8 deletions.
21 changes: 15 additions & 6 deletions pytest_fixtures/component/virtwho_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
deploy_configure_by_command,
deploy_configure_by_script,
get_configure_command,
get_configure_command_option,
get_guest_info,
)

Expand Down Expand Up @@ -271,21 +272,29 @@ def deploy_type_cli(
form_data_cli,
virtwho_config_cli,
target_sat,
default_location,
):
deploy_type = request.param.lower()
assert virtwho_config_cli['status'] == 'No Report Yet'
if "id" in deploy_type:
command = get_configure_command(virtwho_config_cli['id'], org_module.name)
hypervisor_name, guest_name = deploy_configure_by_command(
command, form_data_cli['hypervisor-type'], debug=True, org=org_module.label
)
elif "script" in deploy_type:
if 'script' in deploy_type:
script = target_sat.cli.VirtWhoConfig.fetch(
{'id': virtwho_config_cli['id']}, output_format='base'
)
hypervisor_name, guest_name = deploy_configure_by_script(
script, form_data_cli['hypervisor-type'], debug=True, org=org_module.label
)
elif deploy_type == 'organization-title':
virtwho_config_cli['organization-title'] = org_module.title
elif deploy_type == 'location-id':
virtwho_config_cli['location-id'] = default_location.id
if deploy_type in ['id', 'name', 'organization-title', 'location-id']:
if 'id' in deploy_type:
command = get_configure_command(virtwho_config_cli['id'], org_module.name)
else:
command = get_configure_command_option(deploy_type, virtwho_config_cli, org_module.name)
hypervisor_name, guest_name = deploy_configure_by_command(
command, form_data_cli['hypervisor-type'], debug=True, org=org_module.label
)
return hypervisor_name, guest_name


Expand Down
14 changes: 14 additions & 0 deletions robottelo/utils/virtwho.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,3 +526,17 @@ def create_http_proxy(org, name=None, url=None, http_type='https'):
organization=[org.id],
).create()
return http_proxy.url, http_proxy.name, http_proxy.id


def get_configure_command_option(deploy_type, args, org=DEFAULT_ORG):
"""Return the deploy command line based on option.
:param str option: the unique id of the configure file you have created.
:param str org: the satellite organization name.
"""
username, password = Base._get_username_password()
if deploy_type == 'location-id':
return f"hammer -u {username} -p {password} virt-who-config deploy --id {args['id']} --location-id '{args['location-id']}' "
elif deploy_type == 'organization-title':
return f"hammer -u {username} -p {password} virt-who-config deploy --id {args['id']} --organization-title '{args['organization-title']}' "
elif deploy_type == 'name':
return f"hammer -u {username} -p {password} virt-who-config deploy --name {args['name']} --organization '{org}' "
8 changes: 6 additions & 2 deletions tests/foreman/virtwho/cli/test_esx_sca.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@
class TestVirtWhoConfigforEsx:
@pytest.mark.tier2
@pytest.mark.upgrade
@pytest.mark.parametrize('deploy_type_cli', ['id', 'script'], indirect=True)
def test_positive_deploy_configure_by_id_script(
@pytest.mark.parametrize(
'deploy_type_cli',
['id', 'script', 'name', 'location-id', 'organization-title'],
indirect=True,
)
def test_positive_deploy_configure_by_id_script_name_locationid_organizationtitle(
self, module_sca_manifest_org, target_sat, virtwho_config_cli, deploy_type_cli
):
"""Verify "hammer virt-who-config deploy & fetch"
Expand Down

0 comments on commit 294f712

Please sign in to comment.