diff options
| author | Flavio Percoco <flaper87@gmail.com> | 2015-09-16 10:56:31 +0200 |
|---|---|---|
| committer | Flavio Percoco <flaper87@gmail.com> | 2015-09-23 11:18:36 +0200 |
| commit | 68cf63da7a53a88f0b977bf9f9ce875a51ecb407 (patch) | |
| tree | 849b17718b42a9ad4120f647731137ba894048aa /glanceclient/v2/shell.py | |
| parent | 12fd2f0ecdc4a261d4b7198a9988e7ffa27373e3 (diff) | |
| download | python-glanceclient-68cf63da7a53a88f0b977bf9f9ce875a51ecb407.tar.gz | |
Don't get the image before deleting it
The client currently downloads the image metadata to check if it's deleted
or not. This logic belongs to the server and it's already implemented
there. Instead of getting the image, send the delete request and catch
the 404 error, which is already raised by the server.
Change-Id: I1e6ef42340f8e380ff99b9d6ca7ea416e0eebfbc
Closes-bug: #1496305
(cherry picked from commit b8a881f5ea89514d715e61b632bc3081a0dde2c6)
(cherry picked from commit e82d9df74cbac9accc8a6724c0759760e44bb315)
Diffstat (limited to 'glanceclient/v2/shell.py')
| -rw-r--r-- | glanceclient/v2/shell.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/glanceclient/v2/shell.py b/glanceclient/v2/shell.py index 41bcfa7..44ec71a 100644 --- a/glanceclient/v2/shell.py +++ b/glanceclient/v2/shell.py @@ -296,11 +296,11 @@ def do_image_upload(gc, args): @utils.arg('id', metavar='<IMAGE_ID>', help='ID of image to delete.') def do_image_delete(gc, args): """Delete specified image.""" - image = gc.images.get(args.id) - if image and image.status == "deleted": - msg = "No image with an ID of '%s' exists." % image.id + try: + gc.images.delete(args.id) + except exc.HTTPNotFound: + msg = "No image with an ID of '%s' exists." % args.id utils.exit(msg) - gc.images.delete(args.id) @utils.arg('image_id', metavar='<IMAGE_ID>', |
