blob: 673f98eafab598906c4952b8416e74920b96197e [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
vponomaryov960eeb42014-02-22 18:25:25 +020018from tempest.common import rest_client
Eiichi Aikawaca3d9bd2014-03-06 15:06:21 +090019from tempest.services.compute.xml import common
Nikolay Pliashechnikovb053aab2013-11-05 06:06:44 -080020import tempest.services.telemetry.telemetry_client_base as client
21
22
23class TelemetryClientXML(client.TelemetryClientBase):
vponomaryov960eeb42014-02-22 18:25:25 +020024 TYPE = "xml"
Nikolay Pliashechnikovb053aab2013-11-05 06:06:44 -080025
Andrea Frittoli8bbdb162014-01-06 11:06:13 +000026 def get_rest_client(self, auth_provider):
vponomaryov960eeb42014-02-22 18:25:25 +020027 rc = rest_client.RestClient(auth_provider)
28 rc.TYPE = self.TYPE
29 return rc
Nikolay Pliashechnikovb053aab2013-11-05 06:06:44 -080030
31 def _parse_array(self, body):
32 array = []
33 for child in body.getchildren():
Eiichi Aikawaca3d9bd2014-03-06 15:06:21 +090034 array.append(common.xml_to_json(child))
Nikolay Pliashechnikovb053aab2013-11-05 06:06:44 -080035 return array
36
37 def serialize(self, body):
Eiichi Aikawaca3d9bd2014-03-06 15:06:21 +090038 return str(common.Document(body))
Nikolay Pliashechnikovb053aab2013-11-05 06:06:44 -080039
40 def deserialize(self, body):
41 return self._parse_array(etree.fromstring(body))