Ken'ichi Ohmichi | a89dd6b | 2015-06-15 05:25:14 +0000 | [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 | |
Matthew Treinish | 2190551 | 2015-07-13 10:33:35 -0400 | [diff] [blame] | 16 | from oslo_serialization import jsonutils as json |
Ken'ichi Ohmichi | a89dd6b | 2015-06-15 05:25:14 +0000 | [diff] [blame] | 17 | |
| 18 | from tempest.api_schema.response.compute.v2_1\ |
| 19 | import quota_classes as classes_schema |
| 20 | from tempest.common import service_client |
| 21 | |
| 22 | |
Ken'ichi Ohmichi | a628707 | 2015-07-02 02:43:15 +0000 | [diff] [blame] | 23 | class QuotaClassesClient(service_client.ServiceClient): |
Ken'ichi Ohmichi | a89dd6b | 2015-06-15 05:25:14 +0000 | [diff] [blame] | 24 | |
Ken'ichi Ohmichi | f9868fc | 2015-06-17 02:36:06 +0000 | [diff] [blame] | 25 | def show_quota_class_set(self, quota_class_id): |
Ken'ichi Ohmichi | a89dd6b | 2015-06-15 05:25:14 +0000 | [diff] [blame] | 26 | """List the quota class set for a quota class.""" |
| 27 | |
Ken'ichi Ohmichi | f9868fc | 2015-06-17 02:36:06 +0000 | [diff] [blame] | 28 | url = 'os-quota-class-sets/%s' % quota_class_id |
Ken'ichi Ohmichi | a89dd6b | 2015-06-15 05:25:14 +0000 | [diff] [blame] | 29 | resp, body = self.get(url) |
| 30 | body = json.loads(body) |
| 31 | self.validate_response(classes_schema.get_quota_class_set, resp, body) |
| 32 | return service_client.ResponseBody(resp, body['quota_class_set']) |
| 33 | |
| 34 | def update_quota_class_set(self, quota_class_id, **kwargs): |
| 35 | """ |
| 36 | Updates the quota class's limits for one or more resources. |
| 37 | """ |
| 38 | post_body = json.dumps({'quota_class_set': kwargs}) |
| 39 | |
Ken'ichi Ohmichi | f9868fc | 2015-06-17 02:36:06 +0000 | [diff] [blame] | 40 | resp, body = self.put('os-quota-class-sets/%s' % quota_class_id, |
Ken'ichi Ohmichi | a89dd6b | 2015-06-15 05:25:14 +0000 | [diff] [blame] | 41 | post_body) |
| 42 | |
| 43 | body = json.loads(body) |
| 44 | self.validate_response(classes_schema.update_quota_class_set, |
| 45 | resp, body) |
| 46 | return service_client.ResponseBody(resp, body['quota_class_set']) |