Fixes Error message during image upload due to file filtering
When filtering supported file types in Glance, uploading a none supported file gives a none informative/misleading error on Horizon -> Error: Unable to create new image. Uploading same image in Glance CLI returns a better warning: Invalid disk format. Change-Id: I3dced3a1056bd5bb4495881f246fcab39fbc1bff Closes-bug: #1296722
This commit is contained in:
parent
418e8c5a87
commit
2e3294ec30
|
@ -180,8 +180,17 @@ class CreateImageForm(forms.SelfHandlingForm):
|
|||
_('Your image %s has been queued for creation.') %
|
||||
data['name'])
|
||||
return image
|
||||
except Exception:
|
||||
exceptions.handle(request, _('Unable to create new image.'))
|
||||
except Exception as e:
|
||||
msg = _('Unable to create new image')
|
||||
# TODO(nikunj2512): Fix this once it is fixed in glance client
|
||||
if hasattr(e, 'code') and e.code == 400:
|
||||
if "Invalid disk format" in e.details:
|
||||
msg = _('Unable to create new image: Invalid disk format '
|
||||
'%s for image.') % data['disk_format']
|
||||
|
||||
exceptions.handle(request, msg)
|
||||
|
||||
return False
|
||||
|
||||
|
||||
class UpdateImageForm(forms.SelfHandlingForm):
|
||||
|
|
Loading…
Reference in New Issue