diff options
| author | Dan Prince <dprince@redhat.com> | 2012-04-04 09:38:59 -0400 |
|---|---|---|
| committer | Dan Prince <dprince@redhat.com> | 2012-04-04 09:38:59 -0400 |
| commit | c7dbed99d115989ad8d03db7dc3ffbcaa6fb78c3 (patch) | |
| tree | e3053c853e1d40c06b1c44ac684c4ee781177807 /nova/api | |
| parent | d9019f7aa6e1817d2aabcd59e7dde3d212b4e092 (diff) | |
Add validation on quota limits (negative numbers).
Quotas should not accept negative numbers other than -1.
Fixes LP Bug #973034.
Change-Id: Icc647d80df42d09928717d48ae95dfc8b76c4795
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/openstack/compute/contrib/quotas.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/nova/api/openstack/compute/contrib/quotas.py b/nova/api/openstack/compute/contrib/quotas.py index f669fad79..cf42b434f 100644 --- a/nova/api/openstack/compute/contrib/quotas.py +++ b/nova/api/openstack/compute/contrib/quotas.py @@ -53,6 +53,12 @@ class QuotaSetsController(object): return dict(quota_set=result) + def _validate_quota_limit(self, limit): + # NOTE: -1 is a flag value for unlimited + if limit < -1: + msg = _("Quota limit must be -1 or greater.") + raise webob.exc.HTTPBadRequest(explanation=msg) + @wsgi.serializers(xml=QuotaTemplate) def show(self, req, id): context = req.environ['nova.context'] @@ -72,6 +78,7 @@ class QuotaSetsController(object): for key in body['quota_set'].keys(): if key in quota.quota_resources: value = int(body['quota_set'][key]) + self._validate_quota_limit(value) try: db.quota_update(context, project_id, key, value) except exception.ProjectQuotaNotFound: |
