summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorHaiwei Xu <xu-haiwei@mxw.nes.nec.co.jp>2013-02-12 01:37:27 +0000
committerHaiwei Xu <xu-haiwei@mxw.nes.nec.co.jp>2013-02-13 10:32:48 +0000
commit2c1bb9efd9287381f16979899bf25022822bf95b (patch)
tree6b59fd6cd6382c5c20c93a322caf4d54aad669eb /nova/api
parentd980805880c681881504e269e03130e4452630ab (diff)
Check the length of flavor name in "flavor-create"
Fixes bug 1102280 The length of flavor name is defined 255 charaters in database. But flavor name can be more than 255 characters when a flavor is created. This patch adds the length check of flavor name. Change-Id: If9db879e5f6340594b215b057a29d03c6fef1503
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)