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
This commit is contained in:
committed by
Stephen Finucane
parent
a067f8c646
commit
693ace79fb
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user