Skip to content

Commit

Permalink
bypass cvv promote to lce if already promoted (#12309)
Browse files Browse the repository at this point in the history
* bypass cvv promote to lce if already promoted

* made changes in cli_factory and factory module
  • Loading branch information
vijaysawant authored Aug 24, 2023
1 parent 9b1bf61 commit 4b2ae90
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
13 changes: 8 additions & 5 deletions robottelo/cli/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -1687,13 +1687,16 @@ def setup_org_for_a_custom_repo(options=None):
ContentView.publish({'id': cv_id})
except CLIReturnCodeError as err:
raise CLIFactoryError(f'Failed to publish new version of content view\n{err.msg}')
# Get the version id
cvv = ContentView.info({'id': cv_id})['versions'][-1]
# Get the content view info
cv_info = ContentView.info({'id': cv_id})
lce_promoted = cv_info['lifecycle-environments']
cvv = cv_info['versions'][-1]
# Promote version to next env
try:
ContentView.version_promote(
{'id': cvv['id'], 'organization-id': org_id, 'to-lifecycle-environment-id': env_id}
)
if env_id not in [int(lce['id']) for lce in lce_promoted]:
ContentView.version_promote(
{'id': cvv['id'], 'organization-id': org_id, 'to-lifecycle-environment-id': env_id}
)
except CLIReturnCodeError as err:
raise CLIFactoryError(f'Failed to promote version to next environment\n{err.msg}')
# Create activation key if needed and associate content view with it
Expand Down
15 changes: 11 additions & 4 deletions robottelo/host_helpers/cli_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,12 +628,19 @@ def setup_org_for_a_custom_repo(self, options=None):
except CLIReturnCodeError as err:
raise CLIFactoryError(f'Failed to publish new version of content view\n{err.msg}')
# Get the version id
cvv = self._satellite.cli.ContentView.info({'id': cv_id})['versions'][-1]
cv_info = self._satellite.cli.ContentView.info({'id': cv_id})
lce_promoted = cv_info['lifecycle-environments']
cvv = cv_info['versions'][-1]
# Promote version to next env
try:
self._satellite.cli.ContentView.version_promote(
{'id': cvv['id'], 'organization-id': org_id, 'to-lifecycle-environment-id': env_id}
)
if env_id not in [int(lce['id']) for lce in lce_promoted]:
self._satellite.cli.ContentView.version_promote(
{
'id': cvv['id'],
'organization-id': org_id,
'to-lifecycle-environment-id': env_id,
}
)
except CLIReturnCodeError as err:
raise CLIFactoryError(f'Failed to promote version to next environment\n{err.msg}')
# Create activation key if needed and associate content view with it
Expand Down
5 changes: 2 additions & 3 deletions tests/foreman/longrun/test_oscap.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
from robottelo.cli.arfreport import Arfreport
from robottelo.cli.factory import make_hostgroup
from robottelo.cli.factory import make_scap_policy
from robottelo.cli.factory import setup_org_for_a_custom_repo
from robottelo.cli.host import Host
from robottelo.cli.job_invocation import JobInvocation
from robottelo.cli.proxy import Proxy
Expand Down Expand Up @@ -96,7 +95,7 @@ def content_view(module_org):


@pytest.fixture(scope='module', autouse=True)
def activation_key(module_org, lifecycle_env, content_view):
def activation_key(module_target_sat, module_org, lifecycle_env, content_view):
"""Create activation keys"""
repo_values = [
{'repo': settings.repos.satclient_repo.rhel8, 'akname': ak_name['rhel8']},
Expand All @@ -109,7 +108,7 @@ def activation_key(module_org, lifecycle_env, content_view):
name=repo.get('akname'), environment=lifecycle_env, organization=module_org
).create()
# Setup org for a custom repo for RHEL6, RHEL7 and RHEL8.
setup_org_for_a_custom_repo(
module_target_sat.cli_factory.setup_org_for_a_custom_repo(
{
'url': repo.get('repo'),
'organization-id': module_org.id,
Expand Down

0 comments on commit 4b2ae90

Please sign in to comment.