From 43bd52ba9f59086f2aaf7c5cc3a81ca40721f887 Mon Sep 17 00:00:00 2001 From: Zhou ShaoYu Date: Thu, 31 Jan 2013 19:02:30 +0800 Subject: 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 --- nova/api/openstack/compute/contrib/quotas.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'nova/api') 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) -- cgit