From 1de89ad8ff6e2b1b690baa491ea6df83339945c6 Mon Sep 17 00:00:00 2001 From: Andreas Nowak <3660291+4nn0@users.noreply.github.com> Date: Tue, 13 Mar 2018 10:51:05 +0100 Subject: [PATCH] skip version which are part of composite content views (#40) --- clean_content_views.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/clean_content_views.py b/clean_content_views.py index 3e8a7ca..8a595fe 100755 --- a/clean_content_views.py +++ b/clean_content_views.py @@ -62,6 +62,11 @@ def get_cv(org_id, cleanup_list, keep): return ver_list, ver_descr, ver_keep +def get_content_view_version(cvid): + cvv = helpers.get_json( + helpers.KATELLO_API + "content_view_versions/" + str(cvid)) + + return cvv def get_content_view_info(cvid): """ @@ -135,8 +140,10 @@ def cleanup(ver_list, ver_descr, dry_run, runuser, ver_keep, cleanall, ignorefir helpers.log_msg(msg, 'DEBUG') for version in cvinfo['versions']: - # Find versions that are not in any environment - if not version['environment_ids']: + # Get composite content views for version + cvv = get_content_view_version(version['id']) + # Find versions that are not in any environment and not in any composite content view + if not version['environment_ids'] and not cvv['composite_content_view_ids']: if not locked: msg = "Orphan view version " + str(version['version']) + " found in '" +\ str(ver_descr[cvid]) + "'"