summaryrefslogtreecommitdiff
path: root/heatclient/v1
diff options
context:
space:
mode:
authorricolin <rico.lin@easystack.cn>2016-11-15 08:39:07 +0800
committerRico Lin <rico.lin.guanyu@gmail.com>2017-05-17 09:30:10 +0000
commit7998d7bb3fdce093df2c88e5b82b1bfa9db5560b (patch)
tree39fcbf19f7f141bfd3f7420e95cda23e4c644c37 /heatclient/v1
parenta80995ddd0a1ce7ad95df048bc5b6c5fad526d19 (diff)
downloadpython-heatclient-7998d7bb3fdce093df2c88e5b82b1bfa9db5560b.tar.gz
Add optional arguments '-y' in CLI:snapshot-delete
There is no judgement before use the cli: heat snapshot-delete. So I add it. Partial-Bug: #1642490 Depends-On: If7b515dff64a18f56046b890279c2c59b0ab9dc7 Change-Id: I6e82630816e54aa2d98c3653ab43b865f445e881
Diffstat (limited to 'heatclient/v1')
-rw-r--r--heatclient/v1/shell.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/heatclient/v1/shell.py b/heatclient/v1/shell.py
index 70ffc9f..97484ca 100644
--- a/heatclient/v1/shell.py
+++ b/heatclient/v1/shell.py
@@ -1634,13 +1634,34 @@ def do_snapshot_show(hc, args):
help=_('Name or ID of the stack containing the snapshot.'))
@utils.arg('snapshot', metavar='<SNAPSHOT>',
help=_('The ID of the snapshot to delete.'))
+@utils.arg('-y', '--yes', default=False, action="store_true",
+ help=_('Skip yes/no prompt (assume yes).'))
def do_snapshot_delete(hc, args):
'''Delete a snapshot of a stack.'''
show_deprecated('heat snapshot-delete', 'openstack stack snapshot delete')
-
+ msg = "User did not confirm snapshot delete %sso taking no action."
+ try:
+ if not args.yes and sys.stdin.isatty():
+ sys.stdout.write(
+ _('Are you sure you want to delete the snapshot of this '
+ 'stack [Y/N]?'))
+ prompt_response = sys.stdin.readline().lower()
+ if not prompt_response.startswith('y'):
+ logger.info(msg, '')
+ return
+ except KeyboardInterrupt: # ctrl-c
+ logger.info(msg, '(ctrl-c) ')
+ return
+ except EOFError: # ctrl-d
+ logger.info(msg, '(ctrl-d) ')
+ return
fields = {'stack_id': args.id, 'snapshot_id': args.snapshot}
try:
hc.stacks.snapshot_delete(**fields)
+ success_msg = _("Request to delete the snapshot %(snapshot_id)s of "
+ "the stack %(stack_id)s has been accepted.")
+ print(success_msg % {'stack_id': args.id,
+ 'snapshot_id': args.snapshot})
except exc.HTTPNotFound:
raise exc.CommandError(_('Stack or snapshot not found'))