diff --git a/clean_content_views.py b/clean_content_views.py index 836d1e6..f97f424 100755 --- a/clean_content_views.py +++ b/clean_content_views.py @@ -73,7 +73,7 @@ def get_content_view_info(cvid): return cvinfo -def cleanup(ver_list, ver_descr, dry_run, runuser, ver_keep): +def cleanup(ver_list, ver_descr, dry_run, runuser, ver_keep, cleanall): """Clean Content Views""" # Set the task name to be displayed in the task monitoring stage @@ -125,10 +125,16 @@ def cleanup(ver_list, ver_descr, dry_run, runuser, ver_keep): helpers.log_msg(msg, 'DEBUG') if float(version['version']) > float(lastver): - msg = "Skipping delete of version " + str(version['version']) - helpers.log_msg(msg, 'INFO') - print msg - continue + # If we have chosen to remove all orphans + if cleanall: + msg = "Removing version " + str(version['version']) + helpers.log_msg(msg, 'INFO') + print helpers.HEADER + msg + helpers.ENDC + else: + msg = "Skipping delete of version " + str(version['version']) + helpers.log_msg(msg, 'INFO') + print msg + continue else: if float(version['version']) < (lastver - float(ver_keep[cvid])): msg = "Removing version " + str(version['version']) @@ -195,6 +201,8 @@ def main(args): required=False) group.add_argument('-a', '--all', help='Clean ALL content views', required=False, action="store_true") + parser.add_argument('-c', '--cleanall', help='Remove orphan versions between in-use views', + required=False, action="store_true") parser.add_argument('-d', '--dryrun', help='Dry Run - Only show what will be cleaned', required=False, action="store_true") @@ -210,6 +218,7 @@ def main(args): else: org_name = helpers.ORG_NAME dry_run = args.dryrun + cleanall = args.cleanall if args.keep: keep = args.keep else: @@ -234,7 +243,7 @@ def main(args): (ver_list, ver_descr, ver_keep) = get_cv(org_id, cleanup_list, keep) # Clean the content views. Returns a list of task IDs. - cleanup(ver_list, ver_descr, dry_run, runuser, ver_keep) + cleanup(ver_list, ver_descr, dry_run, runuser, ver_keep, cleanall) if __name__ == "__main__": diff --git a/man/clean_content_views.8 b/man/clean_content_views.8 index 53f20cc..05c5853 100644 --- a/man/clean_content_views.8 +++ b/man/clean_content_views.8 @@ -53,6 +53,19 @@ file - see If the keep value is not specified in either the config.yml or the --keep option, the default value is 0. .RE .PP +.BR "-c", " --cleanall" +.RS 3 +Clean all orphaned versions of the content view. +By default the removal of versions between published, in-use versions is not performed. +.PP +For example, a given content view contains versions 1, 2 (Production), 3, 4, 5, 6 (Quality), 7, 8 (Library) +.br +By default versions 3-5 and 7 will not be deleted as they exist in between 'live' published versions. +Using the +.B -c +option will cause these versions to be cleaned up as well as any older than the oldest promoted version. +.RE +.PP .BR "-d", " --dryrun" .RS 3 Do not perform the actual cleanup activity, but show what would be done.