diff options
| author | Jenkins <jenkins@review.openstack.org> | 2013-02-13 19:50:03 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2013-02-13 19:50:03 +0000 |
| commit | 787e334a105c47bb387dc51c8798b4ac8e1d7bc0 (patch) | |
| tree | 4790e1037c69a189be5cc48af8c5dfc28b5a324b /nova/api | |
| parent | 07e0c2421adf14d01389f5d6692ac2e18b8b7134 (diff) | |
| parent | 2c1bb9efd9287381f16979899bf25022822bf95b (diff) | |
| download | nova-787e334a105c47bb387dc51c8798b4ac8e1d7bc0.tar.gz nova-787e334a105c47bb387dc51c8798b4ac8e1d7bc0.tar.xz nova-787e334a105c47bb387dc51c8798b4ac8e1d7bc0.zip | |
Merge "Check the length of flavor name in "flavor-create""
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/openstack/compute/servers.py | 17 |
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) |
