Merge "Fix quota-set no required parameters on update"
This commit is contained in:
commit
b7f417afdf
@ -139,6 +139,20 @@ class QuotaSetsMixin(object):
|
||||
|
||||
@wsgi.Controller.authorize("update")
|
||||
def _update(self, req, id, body):
|
||||
body = body.get('quota_set', {})
|
||||
if (body.get('gigabytes') is None and
|
||||
body.get('snapshots') is None and
|
||||
body.get('snapshot_gigabytes') is None and
|
||||
body.get('shares') is None and
|
||||
body.get('share_networks') is None and
|
||||
body.get('share_groups') is None and
|
||||
body.get('share_group_snapshots') is None and
|
||||
body.get('share_replicas') is None and
|
||||
body.get('replica_gigabytes') is None and
|
||||
body.get('per_share_gigabytes') is None):
|
||||
msg = _("Must supply at least one quota field to update.")
|
||||
raise webob.exc.HTTPBadRequest(explanation=msg)
|
||||
|
||||
context = req.environ['manila.context']
|
||||
project_id = id
|
||||
bad_keys = []
|
||||
@ -148,7 +162,6 @@ class QuotaSetsMixin(object):
|
||||
share_type = params.get('share_type', [None])[0]
|
||||
self._validate_user_id_and_share_type_args(user_id, share_type)
|
||||
share_type_id = self._get_share_type_id(context, share_type)
|
||||
body = body.get('quota_set', {})
|
||||
if share_type and body.get('share_groups',
|
||||
body.get('share_group_snapshots')):
|
||||
msg = _("Share type quotas cannot constrain share groups and "
|
||||
|
@ -771,3 +771,18 @@ class QuotaSetsControllerTest(test.TestCase):
|
||||
exception.VersionNotFoundForAPIMethod,
|
||||
controller().update,
|
||||
req, self.project_id)
|
||||
|
||||
def test_update_without_quota(self):
|
||||
body = {
|
||||
'quota_set': {
|
||||
'tenant_id': self.project_id,
|
||||
}
|
||||
}
|
||||
req = _get_request(True, False)
|
||||
|
||||
self.assertRaises(
|
||||
webob.exc.HTTPBadRequest,
|
||||
self.controller.update,
|
||||
req, self.project_id, body=body)
|
||||
self.mock_policy_check.assert_called_once_with(
|
||||
req.environ['manila.context'], self.resource_name, 'update')
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
Fixed a manila issue while updating quotas. Now manila requires at least
|
||||
a quota value to be updated.
|
Loading…
Reference in New Issue
Block a user