blob: d2aaec6f39103d1211d779e1d62ce70433672508 [file] [log] [blame]
ZhiQiang Fan39f97222013-09-20 04:49:44 +08001# Copyright 2012 OpenStack Foundation
dwallecke62b9f02012-10-10 23:34:42 -05002# 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
16import json
Matthew Treinish684d8992014-01-30 16:27:40 +000017
ghanshyamaa93b4b2015-03-20 11:03:44 +090018from tempest.api_schema.response.compute.v2_1 import limits as schema
Ken'ichi Ohmichi4771cbc2015-01-19 23:45:23 +000019from tempest.common import service_client
dwallecke62b9f02012-10-10 23:34:42 -050020
21
Ken'ichi Ohmichi4771cbc2015-01-19 23:45:23 +000022class LimitsClientJSON(service_client.ServiceClient):
dwallecke62b9f02012-10-10 23:34:42 -050023
rajalakshmi-ganesana4ab0072012-08-07 19:48:56 +053024 def get_absolute_limits(self):
dwallecke62b9f02012-10-10 23:34:42 -050025 resp, body = self.get("limits")
26 body = json.loads(body)
Masayuki Igawa435fa492014-03-18 12:00:54 +090027 self.validate_response(schema.get_limit, resp, body)
David Kranz3e4c28b2015-02-09 12:35:18 -050028 return service_client.ResponseBody(resp, body['limits']['absolute'])
dwallecke62b9f02012-10-10 23:34:42 -050029
rajalakshmi-ganesana4ab0072012-08-07 19:48:56 +053030 def get_specific_absolute_limit(self, absolute_limit):
31 resp, body = self.get("limits")
32 body = json.loads(body)
Masayuki Igawa435fa492014-03-18 12:00:54 +090033 self.validate_response(schema.get_limit, resp, body)
rajalakshmi-ganesana4ab0072012-08-07 19:48:56 +053034 if absolute_limit not in body['limits']['absolute']:
35 return None
36 else:
37 return body['limits']['absolute'][absolute_limit]