Catch InUseByStore case in do_image_delete

In case do_image_delete() is called on an image that is
in use and can't be deleted by the driver a HTTPConflict
error is raised in glance. Catch this error and print a
propper error message.

Closes-Bug: #1551037

Change-Id: Id17098f27511df8e05e56b8df21e748921223bd9
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
This commit is contained in:
Danny Al-Gaaf
2016-03-09 23:19:22 +01:00
parent 22a03fd475
commit 860908c517
2 changed files with 18 additions and 0 deletions
+4
View File
@@ -338,6 +338,10 @@ def do_image_delete(gc, args):
msg = "No image with an ID of '%s' exists." % args_id
utils.print_err(msg)
failure_flag = True
except exc.HTTPConflict:
msg = "Unable to delete image '%s' because it is in use." % 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)