[fix] Purge option on removing repositories

This commit is contained in:
ljf 2018-08-31 20:29:36 +02:00
parent 62229d5264
commit 3d4ec54b5f
2 changed files with 20 additions and 3 deletions

View file

@ -1008,6 +1008,9 @@ backup:
help: Name of the backup repository to remove
extra:
pattern: *pattern_backup_repository_name
--purge:
help: Remove all archives and data inside repository
action: store_false
#############################
# Monitor #

View file

@ -71,12 +71,13 @@ def backup_repository_info(name, human_readable=True, space_used=False):
'backup_repository_doesnt_exists', name=name))
if space_used:
logger.info("--space-used option not yet implemented")
try:
repository['used'] = _get_repository_used_space(name)
if human_readable:
if 'quota' in repository:
repository['quota'] = binary_to_human(repository['quota'])
if 'used' in repository:
if 'used' in repository and isinstance(repository['used', int):
repository['used'] = binary_to_human(repository['used'])
return repository
@ -146,7 +147,7 @@ def backup_repository_update(operation_logger, name, description=None,
path=repository['path']))
@is_unit_operation()
def backup_repository_remove(operation_logger, name):
def backup_repository_remove(operation_logger, name, purge=False):
"""
Remove a backup repository
@ -204,3 +205,16 @@ def _get_repositories():
exc_info=1)
return repositories
def _get_repository_used_space(path, methods=None):
"""
Return the used space on a repository or 'unknown' if method don't support
this feature
Keyword argument:
path -- Path of the repository
"""
logger.info("--space-used option not yet implemented")
return 'unknown'