blob: ac5fa32273681450632ea4cff3b23164c624f81d [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
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))