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
This commit is contained in:
wangxiyuan
2015-08-17 10:34:22 +08:00
parent d90c7d6896
commit bf02b048bf
3 changed files with 63 additions and 17 deletions
+20 -6
View File
@@ -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>',