blob: 75142a9d4feefd7fe7b16f45dfc1ac979cb4d73d [file] [log] [blame]
Matthew Treinish33634462012-08-16 16:51:23 -04001# vim: tabstop=4 shiftwidth=4 softtabstop=4
2#
3# Copyright 2012 IBM
4# All Rights Reserved.
5#
6# Licensed under the Apache License, Version 2.0 (the "License"); you may
7# not use this file except in compliance with the License. You may obtain
8# a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15# License for the specific language governing permissions and limitations
16# under the License.
17
18from tempest.common.rest_client import RestClientXML
19from lxml import etree
20from lxml import objectify
21
22NS = "{http://docs.openstack.org/common/api/v1.0}"
23
24
25class LimitsClientXML(RestClientXML):
26
27 def __init__(self, config, username, password, auth_url, tenant_name=None):
28 super(LimitsClientXML, self).__init__(config, username, password,
Zhongyue Luo79d8d362012-09-25 13:49:27 +080029 auth_url, tenant_name)
Matthew Treinish33634462012-08-16 16:51:23 -040030 self.service = self.config.compute.catalog_type
31
32 def get_limits(self):
33 resp, body = self.get("limits", self.headers)
34 body = objectify.fromstring(body)
35 lim = NS + 'absolute'
36 ret = {}
37
38 for el in body[lim].iterchildren():
39 attributes = el.attrib
40 if attributes['name'] == 'maxServerMeta':
41 ret['maxServerMeta'] = int(attributes['value'])
42 elif attributes['name'] == 'maxPersonality':
43 ret['maxPersonality'] = int(attributes['value'])
44 elif attributes['name'] == 'maxPersonalitySize':
45 ret['maxPersonalitySize'] = int(attributes['value'])
46
47 return resp, ret
48
49 def get_max_server_meta(self):
50 resp, limits_dict = self.get_limits()
51 return resp, limits_dict['maxServerMeta']
52
53 def get_personality_file_limit(self):
54 resp, limits_dict = self.get_limits()
55 return resp, limits_dict['maxPersonality']
56
57 def get_personality_size_limit(self):
58 resp, limits_dict = self.get_limits()
59 return resp, limits_dict['maxPersonalitySize']