summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/compute/servers.py17
1 files changed, 5 insertions, 12 deletions
diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py
index 5858ad640..c10c6e1b3 100644
--- a/nova/api/openstack/compute/servers.py
+++ b/nova/api/openstack/compute/servers.py
@@ -563,18 +563,11 @@ class Controller(wsgi.Controller):
return instance
def _check_string_length(self, value, name, max_length=None):
- if not isinstance(value, basestring):
- msg = _("%s is not a string or unicode") % name
- raise exc.HTTPBadRequest(explanation=msg)
-
- if not value.strip():
- msg = _("%s is an empty string") % name
- raise exc.HTTPBadRequest(explanation=msg)
-
- if max_length and len(value) > max_length:
- msg = _("%(name)s can be at most %(max_length)s "
- "characters.") % locals()
- raise exc.HTTPBadRequest(explanation=msg)
+ try:
+ utils.check_string_length(value, name, min_length=1,
+ max_length=max_length)
+ except exception.InvalidInput as e:
+ raise exc.HTTPBadRequest(explanation=str(e))
def _validate_server_name(self, value):
self._check_string_length(value, 'Server name', max_length=255)