diff --git a/clean_content_views.py b/clean_content_views.py index 5a52ccf..5cc95f1 100644 --- a/clean_content_views.py +++ b/clean_content_views.py @@ -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') diff --git a/helpers.py b/helpers.py index 17c0d87..b999f9c 100644 --- a/helpers.py +++ b/helpers.py @@ -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):