Skip to content

Commit 65c3381

Browse files
committed
Added cleanall option to clean script
1 parent dfc723e commit 65c3381

2 files changed

Lines changed: 28 additions & 6 deletions

File tree

clean_content_views.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def get_content_view_info(cvid):
7373
return cvinfo
7474

7575

76-
def cleanup(ver_list, ver_descr, dry_run, runuser, ver_keep):
76+
def cleanup(ver_list, ver_descr, dry_run, runuser, ver_keep, cleanall):
7777
"""Clean Content Views"""
7878

7979
# 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):
125125
helpers.log_msg(msg, 'DEBUG')
126126

127127
if float(version['version']) > float(lastver):
128-
msg = "Skipping delete of version " + str(version['version'])
129-
helpers.log_msg(msg, 'INFO')
130-
print msg
131-
continue
128+
# If we have chosen to remove all orphans
129+
if cleanall:
130+
msg = "Removing version " + str(version['version'])
131+
helpers.log_msg(msg, 'INFO')
132+
print helpers.HEADER + msg + helpers.ENDC
133+
else:
134+
msg = "Skipping delete of version " + str(version['version'])
135+
helpers.log_msg(msg, 'INFO')
136+
print msg
137+
continue
132138
else:
133139
if float(version['version']) < (lastver - float(ver_keep[cvid])):
134140
msg = "Removing version " + str(version['version'])
@@ -195,6 +201,8 @@ def main(args):
195201
required=False)
196202
group.add_argument('-a', '--all', help='Clean ALL content views', required=False,
197203
action="store_true")
204+
parser.add_argument('-c', '--cleanall', help='Remove orphan versions between in-use views',
205+
required=False, action="store_true")
198206
parser.add_argument('-d', '--dryrun', help='Dry Run - Only show what will be cleaned',
199207
required=False, action="store_true")
200208

@@ -210,6 +218,7 @@ def main(args):
210218
else:
211219
org_name = helpers.ORG_NAME
212220
dry_run = args.dryrun
221+
cleanall = args.cleanall
213222
if args.keep:
214223
keep = args.keep
215224
else:
@@ -234,7 +243,7 @@ def main(args):
234243
(ver_list, ver_descr, ver_keep) = get_cv(org_id, cleanup_list, keep)
235244

236245
# Clean the content views. Returns a list of task IDs.
237-
cleanup(ver_list, ver_descr, dry_run, runuser, ver_keep)
246+
cleanup(ver_list, ver_descr, dry_run, runuser, ver_keep, cleanall)
238247

239248

240249
if __name__ == "__main__":

man/clean_content_views.8

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,19 @@ file - see
5353
If the keep value is not specified in either the config.yml or the --keep option, the default value is 0.
5454
.RE
5555
.PP
56+
.BR "-c", " --cleanall"
57+
.RS 3
58+
Clean all orphaned versions of the content view.
59+
By default the removal of versions between published, in-use versions is not performed.
60+
.PP
61+
For example, a given content view contains versions 1, 2 (Production), 3, 4, 5, 6 (Quality), 7, 8 (Library)
62+
.br
63+
By default versions 3-5 and 7 will not be deleted as they exist in between 'live' published versions.
64+
Using the
65+
.B -c
66+
option will cause these versions to be cleaned up as well as any older than the oldest promoted version.
67+
.RE
68+
.PP
5669
.BR "-d", " --dryrun"
5770
.RS 3
5871
Do not perform the actual cleanup activity, but show what would be done.

0 commit comments

Comments
 (0)