Daryl Walleck | ed8bef3 | 2011-12-05 23:02:08 -0600 | [diff] [blame] | 1 | import json |
| 2 | from tempest.common import rest_client |
| 3 | |
| 4 | |
| 5 | class LimitsClient(object): |
| 6 | |
Daryl Walleck | 587385b | 2012-03-03 13:00:26 -0600 | [diff] [blame^] | 7 | def __init__(self, config, username, password, auth_url, tenant_name=None): |
Daryl Walleck | 4aa82a9 | 2012-02-14 15:45:46 -0600 | [diff] [blame] | 8 | self.config = config |
Daryl Walleck | 587385b | 2012-03-03 13:00:26 -0600 | [diff] [blame^] | 9 | catalog_type = self.config.compute.catalog_type |
| 10 | self.client = rest_client.RestClient(config, username, password, |
Daryl Walleck | b90a1a6 | 2012-02-27 11:23:10 -0600 | [diff] [blame] | 11 | auth_url, catalog_type, |
Daryl Walleck | 4aa82a9 | 2012-02-14 15:45:46 -0600 | [diff] [blame] | 12 | tenant_name) |
Daryl Walleck | ed8bef3 | 2011-12-05 23:02:08 -0600 | [diff] [blame] | 13 | |
| 14 | def get_limits(self): |
| 15 | resp, body = self.client.get("limits") |
| 16 | body = json.loads(body) |
| 17 | return resp, body['limits'] |
| 18 | |
| 19 | def get_max_server_meta(self): |
| 20 | resp, limits_dict = self.get_limits() |
| 21 | return resp, limits_dict['absolute']['maxServerMeta'] |
| 22 | |
| 23 | def get_personality_file_limit(self): |
| 24 | resp, limits_dict = self.get_limits() |
| 25 | return resp, limits_dict['absolute']['maxPersonality'] |
| 26 | |
| 27 | def get_personality_size_limit(self): |
| 28 | resp, limits_dict = self.get_limits() |
| 29 | return resp, limits_dict['absolute']['maxPersonalitySize'] |