RedHatSatellite / sat6_scripts

Scripts to automate various Satellite 6 content related tasks, including disconnected export/import, publish, promote, cleanup and more...
GNU General Public License v3.0
54 stars 33 forks source link

option to cleanup and keep versions among promoted ones #26

Closed camandel closed 6 years ago

camandel commented 6 years ago

Hello,

I like the feature of "clean_content_views" to delete unused CVs keeping a specified number of backups. By default this works for versions before the first one promoted (except if you use "--cleanall", that isn't what I need). Usually in our environment we need to delete versions among different promoted ones but keeping some of them:

v7.0 Library
v6.0 dev
v5.0  
v4.0 
v3.0 prod
v2.0
v1.0 goldenimg

To obtain it I added a new parameter "--ignorefirstpromoted" to start counting from the first version available rgardless the promoted one. For instance if I set "keep: 1" versions 2.0 and 4.0 will be deleted and 5.0 will my backup.

ggatward commented 6 years ago

Looks like a good idea... When I test this running with the original "-a" flag though I am getting a TypeError at line 127:

Traceback (most recent call last): File "/usr/local/bin/clean_content_views", line 7, in clean_content_views.main(sys.argv[1:]) File "/usr/share/sat6_scripts/clean_content_views.py", line 278, in main cleanup(ver_list, ver_descr, dry_run, runuser, ver_keep, cleanall, ignorefirstpromoted) File "/usr/share/sat6_scripts/clean_content_views.py", line 127, in cleanup todelete = version_list_all[:(len(version_list_all) - ver_keep[cvid])] TypeError: unsupported operand type(s) for -: 'int' and 'str'