Matthew Treinish | 9e26ca8 | 2016-02-23 11:43:20 -0500 | [diff] [blame] | 1 | # Copyright 2012 NTT Data |
| 2 | # All Rights Reserved. |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 5 | # not use this file except in compliance with the License. You may obtain |
| 6 | # a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 | # License for the specific language governing permissions and limitations |
| 14 | # under the License. |
| 15 | |
| 16 | from oslo_serialization import jsonutils as json |
| 17 | |
| 18 | from tempest.lib.api_schema.response.compute.v2_1\ |
| 19 | import quota_classes as classes_schema |
| 20 | from tempest.lib.common import rest_client |
Ghanshyam | ee9af30 | 2016-02-25 06:12:43 +0900 | [diff] [blame] | 21 | from tempest.lib.services.compute import base_compute_client |
Matthew Treinish | 9e26ca8 | 2016-02-23 11:43:20 -0500 | [diff] [blame] | 22 | |
| 23 | |
Ghanshyam | ee9af30 | 2016-02-25 06:12:43 +0900 | [diff] [blame] | 24 | class QuotaClassesClient(base_compute_client.BaseComputeClient): |
Matthew Treinish | 9e26ca8 | 2016-02-23 11:43:20 -0500 | [diff] [blame] | 25 | |
| 26 | def show_quota_class_set(self, quota_class_id): |
| 27 | """List the quota class set for a quota class.""" |
| 28 | |
| 29 | url = 'os-quota-class-sets/%s' % quota_class_id |
| 30 | resp, body = self.get(url) |
| 31 | body = json.loads(body) |
| 32 | self.validate_response(classes_schema.get_quota_class_set, resp, body) |
| 33 | return rest_client.ResponseBody(resp, body) |
| 34 | |
| 35 | def update_quota_class_set(self, quota_class_id, **kwargs): |
| 36 | """Update the quota class's limits for one or more resources. |
| 37 | |
kkush | 09a66e6 | 2018-01-29 19:00:15 +0530 | [diff] [blame] | 38 | For a full list of available parameters, please refer to the official |
| 39 | API reference: |
Andreas Jaeger | bf30ae7 | 2019-07-22 19:22:57 +0200 | [diff] [blame^] | 40 | https://docs.openstack.org/api-ref/compute/#create-or-update-quotas-for-quota-class |
Matthew Treinish | 9e26ca8 | 2016-02-23 11:43:20 -0500 | [diff] [blame] | 41 | """ |
| 42 | post_body = json.dumps({'quota_class_set': kwargs}) |
| 43 | |
| 44 | resp, body = self.put('os-quota-class-sets/%s' % quota_class_id, |
| 45 | post_body) |
| 46 | |
| 47 | body = json.loads(body) |
| 48 | self.validate_response(classes_schema.update_quota_class_set, |
| 49 | resp, body) |
| 50 | return rest_client.ResponseBody(resp, body) |