Matthew Treinish | 9e26ca8 | 2016-02-23 11:43:20 -0500 | [diff] [blame] | 1 | # Copyright 2012 OpenStack Foundation |
| 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 | |
zhufl | 8013413 | 2018-03-29 10:28:59 +0800 | [diff] [blame] | 18 | from tempest.lib.api_schema.response.compute.v2_1 import limits as schemav21 |
| 19 | from tempest.lib.api_schema.response.compute.v2_36 import limits as schemav236 |
| 20 | from tempest.lib.api_schema.response.compute.v2_39 import limits as schemav239 |
| 21 | from tempest.lib.api_schema.response.compute.v2_57 import limits as schemav257 |
Matthew Treinish | 9e26ca8 | 2016-02-23 11:43:20 -0500 | [diff] [blame] | 22 | from tempest.lib.common import rest_client |
Ghanshyam | ee9af30 | 2016-02-25 06:12:43 +0900 | [diff] [blame] | 23 | from tempest.lib.services.compute import base_compute_client |
Matthew Treinish | 9e26ca8 | 2016-02-23 11:43:20 -0500 | [diff] [blame] | 24 | |
| 25 | |
Ghanshyam | ee9af30 | 2016-02-25 06:12:43 +0900 | [diff] [blame] | 26 | class LimitsClient(base_compute_client.BaseComputeClient): |
Matthew Treinish | 9e26ca8 | 2016-02-23 11:43:20 -0500 | [diff] [blame] | 27 | |
zhufl | 8013413 | 2018-03-29 10:28:59 +0800 | [diff] [blame] | 28 | schema_versions_info = [ |
| 29 | {'min': None, 'max': '2.35', 'schema': schemav21}, |
| 30 | {'min': '2.36', 'max': '2.38', 'schema': schemav236}, |
| 31 | {'min': '2.39', 'max': '2.56', 'schema': schemav239}, |
| 32 | {'min': '2.57', 'max': None, 'schema': schemav257}] |
| 33 | |
Matthew Treinish | 9e26ca8 | 2016-02-23 11:43:20 -0500 | [diff] [blame] | 34 | def show_limits(self): |
| 35 | resp, body = self.get("limits") |
| 36 | body = json.loads(body) |
zhufl | 8013413 | 2018-03-29 10:28:59 +0800 | [diff] [blame] | 37 | schema = self.get_schema(self.schema_versions_info) |
Matthew Treinish | 9e26ca8 | 2016-02-23 11:43:20 -0500 | [diff] [blame] | 38 | self.validate_response(schema.get_limit, resp, body) |
| 39 | return rest_client.ResponseBody(resp, body) |