Support skip-validation for quota update

Support skip-validation parameter for quota update.

Change-Id: Iec4f1598987c632f45ad6eee751f78bedbf3ec26
This commit is contained in:
wangxiyuan 2017-07-17 09:21:32 +08:00
parent f3a1e6e708
commit c6ca3cf7cb
4 changed files with 55 additions and 1 deletions

View File

@ -237,6 +237,9 @@ def quota_update(manager, identifier, args):
updates[resource] = val
if updates:
skip_validation = getattr(args, 'skip_validation', True)
if not skip_validation:
updates['skip_validation'] = skip_validation
quota_show(manager.update(identifier, **updates))

View File

@ -0,0 +1,29 @@
# Copyright (c) 2017 OpenStack Foundation
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from cinderclient.tests.unit import utils
from cinderclient.tests.unit.v3 import fakes
cs = fakes.FakeClient()
class QuotaSetsTest(utils.TestCase):
def test_update_quota_with_skip_(self):
q = cs.quotas.get('test')
q.update(skip_validation=False)
cs.assert_called('PUT', '/os-quota-sets/test?skip_validation=False')
self._assert_request_id(q)

View File

@ -13,4 +13,22 @@
# License for the specific language governing permissions and limitations
# under the License.
from cinderclient.v2.quotas import * # flake8: noqa
from cinderclient.v2 import quotas
class QuotaSetManager(quotas.QuotaSetManager):
def update(self, tenant_id, **updates):
skip_validation = updates.pop('skip_validation', True)
body = {'quota_set': {'tenant_id': tenant_id}}
for update in updates:
body['quota_set'][update] = updates[update]
request_url = '/os-quota-sets/%s' % tenant_id
if not skip_validation:
request_url += '?skip_validation=False'
result = self._update(request_url, body)
return self.resource_class(self, result['quota_set'], loaded=True,
resp=result.request_ids)

View File

@ -756,6 +756,10 @@ def do_group_type_key(cs, args):
metavar='<per_volume_gigabytes>',
type=int, default=None,
help='Set max volume size limit. Default=None.')
@utils.arg('--skip-validation',
metavar='<skip_validation>',
default=False,
help='Skip validate the existing resource quota. Default=False.')
def do_quota_update(cs, args):
"""Updates quotas for a tenant."""