From: Jenkins Date: Fri, 22 Nov 2013 05:06:05 +0000 (+0000) Subject: Merge "Add valid check and unit tests on quota class" X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=e6f2ed60be911ff01f4f2b7aa67450ac273df9cf;p=openstack-build%2Fcinder-build.git Merge "Add valid check and unit tests on quota class" --- e6f2ed60be911ff01f4f2b7aa67450ac273df9cf diff --cc cinder/api/contrib/quota_classes.py index 72bffcb2e,8d4b8ebf8..c7e6d5f16 --- a/cinder/api/contrib/quota_classes.py +++ b/cinder/api/contrib/quota_classes.py @@@ -68,14 -68,17 +68,22 @@@ class QuotaClassSetsController(wsgi.Con context = req.environ['cinder.context'] authorize(context) quota_class = id + if not self.is_valid_body(body, 'quota_class_set'): + msg = (_("Missing required element quota_class_set" + " in request body.")) + raise webob.exc.HTTPBadRequest(explanation=msg) + for key in body['quota_class_set'].keys(): if key in QUOTAS: - value = int(body['quota_class_set'][key]) + try: + value = int(body['quota_class_set'][key]) + except ValueError: + msg = _("Quota class limit must be specified as an" + " integer value.") + raise webob.exc.HTTPBadRequest(explanation=msg) + if value < -1: + msg = _("Quota class limit must be -1 or greater.") + raise webob.exc.HTTPBadRequest(explanation=msg) try: db.quota_class_update(context, quota_class, key, value) except exception.QuotaClassNotFound: