blob: f29fe229755c9d78b68802712e06603ab5e869c8 [file] [log] [blame]
Nikolay Pliashechnikovb053aab2013-11-05 06:06:44 -08001# 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
16from lxml import etree
17
18from tempest.common.rest_client import RestClientXML
19from tempest.services.compute.xml.common import Document
20from tempest.services.compute.xml.common import xml_to_json
21import tempest.services.telemetry.telemetry_client_base as client
22
23
24class TelemetryClientXML(client.TelemetryClientBase):
25
Andrea Frittoli8bbdb162014-01-06 11:06:13 +000026 def get_rest_client(self, auth_provider):
27 return RestClientXML(auth_provider)
Nikolay Pliashechnikovb053aab2013-11-05 06:06:44 -080028
29 def _parse_array(self, body):
30 array = []
31 for child in body.getchildren():
32 array.append(xml_to_json(child))
33 return array
34
35 def serialize(self, body):
36 return str(Document(body))
37
38 def deserialize(self, body):
39 return self._parse_array(etree.fromstring(body))