diff --git a/reddwarf/common/exception.py b/reddwarf/common/exception.py index fd94e90f56..7bc80590e9 100644 --- a/reddwarf/common/exception.py +++ b/reddwarf/common/exception.py @@ -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") + diff --git a/reddwarf/instance/service.py b/reddwarf/instance/service.py index 2b774909a4..f23b01acf8 100644 --- a/reddwarf/instance/service.py +++ b/reddwarf/instance/service.py @@ -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,