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\ |
Ghanshyam Mann | dc517e0 | 2021-12-16 15:36:31 -0600 | [diff] [blame] | 19 | import quota_classes as schema |
| 20 | from tempest.lib.api_schema.response.compute.v2_50 import quota_classes \ |
| 21 | as schemav250 |
| 22 | from tempest.lib.api_schema.response.compute.v2_57 import quota_classes \ |
| 23 | as schemav257 |
Matthew Treinish | 9e26ca8 | 2016-02-23 11:43:20 -0500 | [diff] [blame] | 24 | from tempest.lib.common import rest_client |
Ghanshyam | ee9af30 | 2016-02-25 06:12:43 +0900 | [diff] [blame] | 25 | from tempest.lib.services.compute import base_compute_client |
Matthew Treinish | 9e26ca8 | 2016-02-23 11:43:20 -0500 | [diff] [blame] | 26 | |
| 27 | |
Ghanshyam | ee9af30 | 2016-02-25 06:12:43 +0900 | [diff] [blame] | 28 | class QuotaClassesClient(base_compute_client.BaseComputeClient): |
Matthew Treinish | 9e26ca8 | 2016-02-23 11:43:20 -0500 | [diff] [blame] | 29 | |
Ghanshyam Mann | dc517e0 | 2021-12-16 15:36:31 -0600 | [diff] [blame] | 30 | schema_versions_info = [ |
| 31 | {'min': None, 'max': '2.49', 'schema': schema}, |
| 32 | {'min': '2.50', 'max': '2.56', 'schema': schemav250}, |
| 33 | {'min': '2.57', 'max': None, 'schema': schemav257}] |
| 34 | |
Matthew Treinish | 9e26ca8 | 2016-02-23 11:43:20 -0500 | [diff] [blame] | 35 | def show_quota_class_set(self, quota_class_id): |
| 36 | """List the quota class set for a quota class.""" |
| 37 | |
| 38 | url = 'os-quota-class-sets/%s' % quota_class_id |
| 39 | resp, body = self.get(url) |
| 40 | body = json.loads(body) |
Ghanshyam Mann | dc517e0 | 2021-12-16 15:36:31 -0600 | [diff] [blame] | 41 | _schema = self.get_schema(self.schema_versions_info) |
| 42 | self.validate_response(_schema.get_quota_class_set, resp, body) |
Matthew Treinish | 9e26ca8 | 2016-02-23 11:43:20 -0500 | [diff] [blame] | 43 | return rest_client.ResponseBody(resp, body) |
| 44 | |
| 45 | def update_quota_class_set(self, quota_class_id, **kwargs): |
| 46 | """Update the quota class's limits for one or more resources. |
| 47 | |
kkush | 09a66e6 | 2018-01-29 19:00:15 +0530 | [diff] [blame] | 48 | For a full list of available parameters, please refer to the official |
| 49 | API reference: |
Andreas Jaeger | bf30ae7 | 2019-07-22 19:22:57 +0200 | [diff] [blame] | 50 | 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] | 51 | """ |
| 52 | post_body = json.dumps({'quota_class_set': kwargs}) |
| 53 | |
| 54 | resp, body = self.put('os-quota-class-sets/%s' % quota_class_id, |
| 55 | post_body) |
| 56 | |
| 57 | body = json.loads(body) |
Ghanshyam Mann | dc517e0 | 2021-12-16 15:36:31 -0600 | [diff] [blame] | 58 | _schema = self.get_schema(self.schema_versions_info) |
| 59 | self.validate_response(_schema.update_quota_class_set, |
Matthew Treinish | 9e26ca8 | 2016-02-23 11:43:20 -0500 | [diff] [blame] | 60 | resp, body) |
| 61 | return rest_client.ResponseBody(resp, body) |