summaryrefslogtreecommitdiff
path: root/openstackclient/image
diff options
context:
space:
mode:
authorsunyajing <yajing.sun@easystack.cn>2016-06-01 13:48:23 +0800
committersunyajing <yajing.sun@easystack.cn>2016-06-13 16:15:01 +0800
commit8c7e34d65ca6217eee54389fcd40554a8cb454e6 (patch)
tree86d60a88abdde220baf6fa5020940816841f42d1 /openstackclient/image
parent0695d1495e8337149850b8f753c603e7cac1989c (diff)
downloadpython-openstackclient-8c7e34d65ca6217eee54389fcd40554a8cb454e6.tar.gz
Fix image delete multiple arguments error
Fix image delete command, support processing multiple arguments delete error. Fix doc/source/command-errors.rst, make the msg format correct. Change-Id: Icbe347fe077bc148bf71ea8f7399b0e934b7cdf9 Partially-Implements: blueprint multi-argument-image
Diffstat (limited to 'openstackclient/image')
-rw-r--r--openstackclient/image/v2/image.py24
1 files changed, 19 insertions, 5 deletions
diff --git a/openstackclient/image/v2/image.py b/openstackclient/image/v2/image.py
index fa1de424..a6d244c3 100644
--- a/openstackclient/image/v2/image.py
+++ b/openstackclient/image/v2/image.py
@@ -372,13 +372,27 @@ class DeleteImage(command.Command):
return parser
def take_action(self, parsed_args):
+
+ del_result = 0
image_client = self.app.client_manager.image
for image in parsed_args.images:
- image_obj = utils.find_resource(
- image_client.images,
- image,
- )
- image_client.images.delete(image_obj.id)
+ try:
+ image_obj = utils.find_resource(
+ image_client.images,
+ image,
+ )
+ image_client.images.delete(image_obj.id)
+ except Exception as e:
+ del_result += 1
+ self.app.log.error(_("Failed to delete image with "
+ "name or ID '%(image)s': %(e)s")
+ % {'image': image, 'e': e})
+
+ total = len(parsed_args.images)
+ if (del_result > 0):
+ msg = (_("Failed to delete %(dresult)s of %(total)s images.")
+ % {'dresult': del_result, 'total': total})
+ raise exceptions.CommandError(msg)
class ListImage(command.Lister):