From 854740c4c793444c955180e7c0c96977e3e06c56 Mon Sep 17 00:00:00 2001 From: Seif Lotfy Date: Thu, 18 Jul 2013 18:01:41 +0000 Subject: [PATCH] Add evaluation of --force parameter when creating snapshots Raise BadRequest Exception if value of --force parameter in snapshot-create is invalid Fixes: bug #1014689 Change-Id: If4858dc17cedf027112defb935016137727681cc --- cinderclient/v1/shell.py | 6 ++++++ cinderclient/v2/shell.py | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/cinderclient/v1/shell.py b/cinderclient/v1/shell.py index 856facbbe..4d41d6d04 100644 --- a/cinderclient/v1/shell.py +++ b/cinderclient/v1/shell.py @@ -413,6 +413,12 @@ def do_snapshot_show(cs, args): @utils.service_type('volume') def do_snapshot_create(cs, args): """Add a new snapshot.""" + + if not args.force.lower() in ['true', '1', 'yes', 'y', + 'false', '0', 'no', 'n']: + msg = "Parameter 'force' does not support value '%s'" % args.force + raise exceptions.BadRequest(msg) + snapshot = cs.volume_snapshots.create(args.volume_id, args.force, args.display_name, diff --git a/cinderclient/v2/shell.py b/cinderclient/v2/shell.py index 7bf15dfda..56921d5c0 100644 --- a/cinderclient/v2/shell.py +++ b/cinderclient/v2/shell.py @@ -470,6 +470,11 @@ def do_snapshot_create(cs, args): if args.display_description is not None: args.description = args.display_description + if not args.force.lower() in ['true', '1', 'yes', 'y', + 'false', '0', 'no', 'n']: + msg = "Parameter 'force' does not support value '%s'" % args.force + raise exceptions.BadRequest(msg) + snapshot = cs.volume_snapshots.create(args.volume_id, args.force, args.name,