diff options
author | naichuans <naichuan.sun@citrix.com> | 2017-05-18 13:01:06 +0000 |
---|---|---|
committer | Stephen Finucane <stephenfin@redhat.com> | 2017-10-23 16:29:16 +0000 |
commit | 693ace79fbf856967684f11dfd7663d465dbe19a (patch) | |
tree | c14ba1716e0959e38a6f0d731b03941acfa05242 /tools | |
parent | a067f8c64654a058e04e41389019bd6ff5841cdc (diff) | |
download | nova-693ace79fbf856967684f11dfd7663d465dbe19a.tar.gz |
xenapi: cached images should be cleaned up by time
For xenapi driver, there needs to be some way to delete cached
images based on when they were created. add an optional arg to
control delete operation.
Change-Id: I24fc45e989aa951aab55a261fce77f7e3667d988
Closes-bug: 1481689
Diffstat (limited to 'tools')
-rw-r--r-- | tools/xenserver/destroy_cached_images.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/tools/xenserver/destroy_cached_images.py b/tools/xenserver/destroy_cached_images.py index 1cf254788d..c9025e9423 100644 --- a/tools/xenserver/destroy_cached_images.py +++ b/tools/xenserver/destroy_cached_images.py @@ -21,6 +21,8 @@ Options: --dry_run - Don't actually destroy the VDIs --all_cached - Destroy all cached images instead of just unused cached images. + --keep_days - N - Only remove those cached images which were created + more than N days ago. """ import eventlet eventlet.monkey_patch() @@ -52,7 +54,11 @@ destroy_opts = [ ' images.'), cfg.BoolOpt('dry_run', default=False, - help='Don\'t actually delete the VDIs.') + help='Don\'t actually delete the VDIs.'), + cfg.IntOpt('keep_days', + default=0, + help='Destroy cached images which were' + ' created over keep_days.') ] CONF = nova.conf.CONF @@ -69,7 +75,7 @@ def main(): sr_ref = vm_utils.safe_find_sr(_session) destroyed = vm_utils.destroy_cached_images( _session, sr_ref, all_cached=CONF.all_cached, - dry_run=CONF.dry_run) + dry_run=CONF.dry_run, keep_days=CONF.keep_days) if '--verbose' in sys.argv: print('\n'.join(destroyed)) |