diff options
| author | Zhou ShaoYu <hzzhoushaoyu@corp.netease.com> | 2013-01-31 19:02:30 +0800 |
|---|---|---|
| committer | Zhou ShaoYu <hzzhoushaoyu@corp.netease.com> | 2013-02-02 12:33:48 +0800 |
| commit | 43bd52ba9f59086f2aaf7c5cc3a81ca40721f887 (patch) | |
| tree | 22c26ab40c1e6f8480bd28fd89a75bc8a8a4267e /nova/api | |
| parent | 194ec6204ee3a67193b1ffd63de073d50878ce77 (diff) | |
Fix update quota with invalid value
If update quota with a value which is not integer, it will response
with http status code 500. Catch the exception and continue for
updating other quotas.
Fix LP# 1111327
Change-Id: I0ab3b10ff106a2e6c7677d1acdb55c2f35c492db
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/openstack/compute/contrib/quotas.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/nova/api/openstack/compute/contrib/quotas.py b/nova/api/openstack/compute/contrib/quotas.py index bdf82ea86..728c3fad6 100644 --- a/nova/api/openstack/compute/contrib/quotas.py +++ b/nova/api/openstack/compute/contrib/quotas.py @@ -23,10 +23,12 @@ from nova.api.openstack import xmlutil from nova import db from nova.db.sqlalchemy import api as sqlalchemy_api from nova import exception +from nova.openstack.common import log as logging from nova import quota QUOTAS = quota.QUOTAS +LOG = logging.getLogger(__name__) authorize_update = extensions.extension_authorizer('compute', 'quotas:update') @@ -88,7 +90,14 @@ class QuotaSetsController(object): project_id = id for key in body['quota_set'].keys(): if key in QUOTAS: - value = int(body['quota_set'][key]) + try: + value = int(body['quota_set'][key]) + except (ValueError, TypeError): + LOG.warn(_("Quota for %s should be integer.") % key) + # NOTE(hzzhoushaoyu): Do not prevent valid value to be + # updated. If raise BadRequest, some may be updated and + # others may be not. + continue self._validate_quota_limit(value) try: db.quota_update(context, project_id, key, value) |
