Nikolay Pliashechnikov | b053aab | 2013-11-05 06:06:44 -0800 | [diff] [blame] | 1 | # Copyright 2014 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 lxml import etree |
| 17 | |
| 18 | from tempest.common.rest_client import RestClientXML |
| 19 | from tempest.services.compute.xml.common import Document |
| 20 | from tempest.services.compute.xml.common import xml_to_json |
| 21 | import tempest.services.telemetry.telemetry_client_base as client |
| 22 | |
| 23 | |
| 24 | class TelemetryClientXML(client.TelemetryClientBase): |
| 25 | |
| 26 | def get_rest_client(self, config, username, |
| 27 | password, auth_url, tenant_name=None): |
| 28 | return RestClientXML(config, username, password, auth_url, tenant_name) |
| 29 | |
| 30 | def _parse_array(self, body): |
| 31 | array = [] |
| 32 | for child in body.getchildren(): |
| 33 | array.append(xml_to_json(child)) |
| 34 | return array |
| 35 | |
| 36 | def serialize(self, body): |
| 37 | return str(Document(body)) |
| 38 | |
| 39 | def deserialize(self, body): |
| 40 | return self._parse_array(etree.fromstring(body)) |