Skip to content
Open
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
10 changes: 9 additions & 1 deletion clean_content_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,18 @@ def check_version_views(version_id):
viewlist = helpers.get_json(
helpers.KATELLO_API + "content_view_versions/" + str(version_id))

# Set the key based on the Katello version
katello_ver = helpers.get_katello_version()
if helpers.version_tuple(katello_ver) >= helpers.version_tuple('3.10'):
# Satellite 6.5 has Katello 3.10
cv_key = 'environments'
else:
cv_key = 'katello_content_views'

# If the list is not empty we need to return this fact. A CV that belongs
# to NO versions will be a candidate for cleanup.
viewlist['composite_content_view_ids']
if viewlist['katello_content_views']:
if viewlist[cv_key]:
version_in_use = True
msg = "Version " + str(viewlist['version']) + " is associated with published CV"
helpers.log_msg(msg, 'DEBUG')
Expand Down
22 changes: 22 additions & 0 deletions helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,28 @@ def get_org_label(org_name):

return org_label

def version_tuple(version):
"""
Parse a version string into a tuple for comparison

A version string is dot (.) separated.

version_tuple by Phaxmohdem is licensed under CC BY-SA 3.0
https://stackoverflow.com/a/28568003/813821
https://creativecommons.org/licenses/by-sa/3.0/
"""
filled = []
for point in version.split("."):
filled.append(point.zfill(8))
return tuple(filled)

def get_katello_version():
"""
Return the Katello version
"""
status = get_json(SAT_API + 'status/')
return status['version']


class ProgressBar:
def __init__(self, duration):
Expand Down