blob: 9af80c472b259c994eb81ab993c4fb08efad2a74 [file] [log] [blame]
Matthew Treinish9e26ca82016-02-23 11:43:20 -05001# 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
16from oslo_serialization import jsonutils as json
17
zhufl80134132018-03-29 10:28:59 +080018from tempest.lib.api_schema.response.compute.v2_1 import limits as schemav21
19from tempest.lib.api_schema.response.compute.v2_36 import limits as schemav236
20from tempest.lib.api_schema.response.compute.v2_39 import limits as schemav239
21from tempest.lib.api_schema.response.compute.v2_57 import limits as schemav257
Matthew Treinish9e26ca82016-02-23 11:43:20 -050022from tempest.lib.common import rest_client
Ghanshyamee9af302016-02-25 06:12:43 +090023from tempest.lib.services.compute import base_compute_client
Matthew Treinish9e26ca82016-02-23 11:43:20 -050024
25
Ghanshyamee9af302016-02-25 06:12:43 +090026class LimitsClient(base_compute_client.BaseComputeClient):
Matthew Treinish9e26ca82016-02-23 11:43:20 -050027
zhufl80134132018-03-29 10:28:59 +080028 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 Treinish9e26ca82016-02-23 11:43:20 -050034 def show_limits(self):
35 resp, body = self.get("limits")
36 body = json.loads(body)
zhufl80134132018-03-29 10:28:59 +080037 schema = self.get_schema(self.schema_versions_info)
Matthew Treinish9e26ca82016-02-23 11:43:20 -050038 self.validate_response(schema.get_limit, resp, body)
39 return rest_client.ResponseBody(resp, body)