blob: 245ccb5b48a23a318319e8add731ca8b83471a81 [file] [log] [blame]
Nikolay Pliashechnikovb053aab2013-11-05 06:06:44 -08001# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
3# Copyright 2014 OpenStack Foundation
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 lxml import etree
19
20from tempest.common.rest_client import RestClientXML
21from tempest.services.compute.xml.common import Document
22from tempest.services.compute.xml.common import xml_to_json
23import tempest.services.telemetry.telemetry_client_base as client
24
25
26class TelemetryClientXML(client.TelemetryClientBase):
27
28 def get_rest_client(self, config, username,
29 password, auth_url, tenant_name=None):
30 return RestClientXML(config, username, password, auth_url, tenant_name)
31
32 def _parse_array(self, body):
33 array = []
34 for child in body.getchildren():
35 array.append(xml_to_json(child))
36 return array
37
38 def serialize(self, body):
39 return str(Document(body))
40
41 def deserialize(self, body):
42 return self._parse_array(etree.fromstring(body))