diff options
| author | wangxiyuan <wangxiyuan@huawei.com> | 2015-08-17 10:34:22 +0800 |
|---|---|---|
| committer | wangxiyuan <wangxiyuan@huawei.com> | 2015-10-10 10:18:02 +0800 |
| commit | bf02b048bf43dbb86f1e072d040f2a9f66d04130 (patch) | |
| tree | 141c6d2932a8c6f1b13e9b83612a355f7db4ac3e /glanceclient/v2/shell.py | |
| parent | d90c7d68965f9fc975ca49d2602d2a91f86b981e (diff) | |
| download | python-glanceclient-bf02b048bf43dbb86f1e072d040f2a9f66d04130.tar.gz | |
Support image deletion in batches in v2
Client doesn't support image deletion in batches in v2 now.
It's useful. So it's need to add it.
Change-Id: Idf5a6890b3fd01a65fecab2033b21367c30bc6b1
Closes-bug:#1485407
Diffstat (limited to 'glanceclient/v2/shell.py')
| -rw-r--r-- | glanceclient/v2/shell.py | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/glanceclient/v2/shell.py b/glanceclient/v2/shell.py index 593630d..23c6753 100644 --- a/glanceclient/v2/shell.py +++ b/glanceclient/v2/shell.py @@ -311,14 +311,28 @@ def do_image_upload(gc, args): gc.images.upload(args.id, image_data, args.size) -@utils.arg('id', metavar='<IMAGE_ID>', help='ID of image to delete.') +@utils.arg('id', metavar='<IMAGE_ID>', nargs='+', + help='ID of image(s) to delete.') def do_image_delete(gc, args): """Delete specified image.""" - try: - gc.images.delete(args.id) - except exc.HTTPNotFound: - msg = "No image with an ID of '%s' exists." % args.id - utils.exit(msg) + failure_flag = False + for args_id in args.id: + try: + gc.images.delete(args_id) + except exc.HTTPForbidden: + msg = "You are not permitted to delete the image '%s'." % args_id + utils.print_err(msg) + failure_flag = True + except exc.HTTPNotFound: + msg = "No image with an ID of '%s' exists." % args_id + utils.print_err(msg) + failure_flag = True + except exc.HTTPException as e: + msg = "'%s': Unable to delete image '%s'" % (e, args_id) + utils.print_err(msg) + failure_flag = True + if failure_flag: + utils.exit() @utils.arg('image_id', metavar='<IMAGE_ID>', |
