Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Removed release server parameter to avoid bad url error. #341

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions upgrade/helpers/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
},
'capsule': {
'prod': 'Red Hat Satellite Capsule',
'repofull': 'Red Hat Satellite Capsule {cap_ver} for RHEL {os_ver} Server RPMs '
'{arch} {os_ver}Server',
'repofull': 'Red Hat Satellite Capsule {cap_ver} for RHEL {os_ver} Server RPMs {arch}',
'repo': 'Red Hat Satellite Capsule {cap_ver} (for RHEL {os_ver} Server) (RPMs)',
'label': 'rhel-{os_ver}-server-satellite-capsule-{cap_ver}-rpms'
},
Expand Down
36 changes: 35 additions & 1 deletion upgrade/helpers/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ def sync_capsule_repos_to_upgrade(capsules):
RHEV_CAPSULE_AK
The AK name used in capsule subscription
"""
command = "foreman-maintain health check --label " \
"foreman-tasks-not-running -y"
check_status_of_running_task(command, 3)
if bz_bug_is_open('1721055'):
setup_foreman_maintain()
logger.info('Disabling the sync plan ...')
run('foreman-maintain advanced procedure run sync-plans-disable')
logger.info('Syncing latest capsule repos in Satellite ...')
to_version = os.environ.get('TO_VERSION')
os_ver = os.environ.get('OS')[-1]
Expand Down Expand Up @@ -141,6 +148,9 @@ def sync_capsule_repos_to_upgrade(capsules):
if capsuletools_url:
add_custom_product_subscription_to_hosts(
customcontents['capsule_tools']['prod'], capsules)
if bz_bug_is_open('1721055'):
logger.info("Enabling the sync plan...")
run('foreman-maintain advanced procedure run sync-plans-enable')


def _sync_capsule_subscription_to_capsule_ak(ak):
Expand Down Expand Up @@ -173,7 +183,7 @@ def _sync_capsule_subscription_to_capsule_ak(ak):
).search()[0]
try:
cap_reposet.enable(
data={'basearch': 'x86_64', 'releasever': '7Server', 'organization_id': org.id})
data={'basearch': 'x86_64', 'organization_id': org.id})
except requests.exceptions.HTTPError as exp:
logger.warn(exp)
cap_repo = entities.Repository(
Expand Down Expand Up @@ -863,3 +873,27 @@ def add_custom_product_subscription_to_hosts(product, hosts):
host = entities.Host().search(query={'search': 'name={}'.format(host)})[0]
entities.HostSubscription(host=host).add_subscriptions(
data={'subscriptions': [{'id': sub.id, 'quantity': 1}]})


def check_status_of_running_task(command, attempt):
"""
This function is used to check the running tasks status via foreman-maintain,
If task is running then wait for their completion otherwise move to
the next step.
"""
retry = 0
while retry <= attempt:
status = run("{} >/dev/null 2>&1; echo $?".format(command))
if status:
logger.info("Attempt{}: Command: {}\n"
"Task is still in running state".
format(retry, command))
retry += 1
else:
logger.info("Command: {}\n "
"Check for running tasks:: [OK]".format(command))
return 0
else:
logger.info("Command: {}\n"
"Exceeded the maximum attempt to check the "
"tasks running status".format(command))
18 changes: 11 additions & 7 deletions upgrade_tests/helpers/existence.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,11 +489,15 @@ def assert_templates(template_type, pre, post):
diff = Differ()
difference = list(diff.compare(pre.splitlines(), post.splitlines()))
del diff
added_elements = [added for added in difference if added.startswith('+')]
removed_elements = [added for added in difference if added.startswith('-')]
for changed_element in added_elements+removed_elements:
for expected_varients in template_varients[template_type]:
if changed_element in expected_varients:
return True
added_lines = [added for added in difference if added.startswith('+')]
removed_lines = [removed for removed in difference if removed.startswith('-')]
all_changed_lines = added_lines + removed_lines
# Check if all the changed lines are expected changes
for changed_line in all_changed_lines:
if changed_line not in template_varients[template_type]:
all_changed_lines_expected = False
break
else:
all_changed_lines_expected = True
pprint(difference)
return False
return all_changed_lines_expected
Loading