Fixing validation for volume size
This commit is contained in:
parent
cab7ab623e
commit
c4f0f697e7
@ -124,3 +124,9 @@ class TaskManagerError(ReddwarfError):
|
||||
|
||||
message = _("An error occurred communicating with the task manager: "
|
||||
"%(original_message)s.")
|
||||
|
||||
|
||||
class BadValue(ReddwarfError):
|
||||
|
||||
message = _("Value could not be converted: %(msg)s")
|
||||
|
||||
|
@ -47,6 +47,7 @@ class BaseController(wsgi.Controller):
|
||||
models.InvalidModelError,
|
||||
exception.BadRequest,
|
||||
exception.CannotResizeToSameSize,
|
||||
exception.BadValue
|
||||
],
|
||||
webob.exc.HTTPNotFound: [
|
||||
exception.NotFound,
|
||||
@ -263,7 +264,10 @@ class InstanceController(BaseController):
|
||||
if databases is None:
|
||||
databases = []
|
||||
if body['instance'].get('volume', None) is not None:
|
||||
volume_size = body['instance']['volume']['size']
|
||||
try:
|
||||
volume_size = int(body['instance']['volume']['size'])
|
||||
except ValueError as e:
|
||||
raise exception.BadValue(msg=e)
|
||||
else:
|
||||
volume_size = None
|
||||
instance = models.Instance.create(context, name, flavor_ref,
|
||||
|
Loading…
x
Reference in New Issue
Block a user