From 8690e41c222a49fa1d989eaca3f36e49913eabb1 Mon Sep 17 00:00:00 2001 From: Nate Potter Date: Mon, 19 Oct 2015 20:17:35 +0000 Subject: Adding backup-reset-state to CLI This patch adds the ability to reset the state of a backup with the command backup-reset-state. DocImpact Change-Id: I5851bb21c62252f61ad6a09f01859582e774a9db Closes-Bug: #1279764 --- cinderclient/v2/shell.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'cinderclient/v2/shell.py') diff --git a/cinderclient/v2/shell.py b/cinderclient/v2/shell.py index b4447d9..584902f 100644 --- a/cinderclient/v2/shell.py +++ b/cinderclient/v2/shell.py @@ -1429,6 +1429,36 @@ def do_backup_import(cs, args): utils.print_dict(info) +@utils.arg('backup', metavar='', nargs='+', + help='Name or ID of the backup to modify.') +@utils.arg('--state', metavar='', + default='available', + help='The state to assign to the backup. Valid values are ' + '"available", "error", "creating", "deleting", and ' + '"error_deleting". Default=available.') +@utils.service_type('volumev2') +def do_backup_reset_state(cs, args): + """Explicitly updates the backup state.""" + failure_count = 0 + + single = (len(args.backup) == 1) + + for backup in args.backup: + try: + _find_backup(cs, backup).reset_state(args.state) + except Exception as e: + failure_count += 1 + msg = "Reset state for backup %s failed: %s" % (backup, e) + if not single: + print(msg) + + if failure_count == len(args.backup): + if not single: + msg = ("Unable to reset the state for any of the specified " + "backups.") + raise exceptions.CommandError(msg) + + @utils.arg('volume', metavar='', help='Name or ID of volume to transfer.') @utils.arg('--name', -- cgit v1.2.1