blob: 4d71186c3439523a0dcce6ad2aebe0b47c14f43a [file] [log] [blame]
Leo Toyodaa5278912013-04-16 15:40:12 +09001# Copyright 2013 NEC Corporation
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
Matthew Treinish684d8992014-01-30 16:27:40 +000019from tempest import config
Leo Toyodaa5278912013-04-16 15:40:12 +090020from tempest.services.compute.xml.common import xml_to_json
21
Matthew Treinish684d8992014-01-30 16:27:40 +000022CONF = config.CONF
23
Leo Toyodaa5278912013-04-16 15:40:12 +090024
vponomaryov960eeb42014-02-22 18:25:25 +020025class AvailabilityZoneClientXML(rest_client.RestClient):
26 TYPE = "xml"
Leo Toyodaa5278912013-04-16 15:40:12 +090027
Andrea Frittoli8bbdb162014-01-06 11:06:13 +000028 def __init__(self, auth_provider):
29 super(AvailabilityZoneClientXML, self).__init__(
30 auth_provider)
Matthew Treinish684d8992014-01-30 16:27:40 +000031 self.service = CONF.compute.catalog_type
Leo Toyodaa5278912013-04-16 15:40:12 +090032
33 def _parse_array(self, node):
34 return [xml_to_json(x) for x in node]
35
36 def get_availability_zone_list(self):
vponomaryovf4c27f92014-02-18 10:56:42 +020037 resp, body = self.get('os-availability-zone')
Leo Toyodaa5278912013-04-16 15:40:12 +090038 availability_zone = self._parse_array(etree.fromstring(body))
39 return resp, availability_zone
40
41 def get_availability_zone_list_detail(self):
vponomaryovf4c27f92014-02-18 10:56:42 +020042 resp, body = self.get('os-availability-zone/detail')
Leo Toyodaa5278912013-04-16 15:40:12 +090043 availability_zone = self._parse_array(etree.fromstring(body))
44 return resp, availability_zone