blob: 0012637668033b6525f2218115adf845b94c0467 [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
Matthew Treinish21905512015-07-13 10:33:35 -040016from oslo_serialization import jsonutils as json
Leo Toyodaa5278912013-04-16 15:40:12 +090017
ghanshyamaa93b4b2015-03-20 11:03:44 +090018from tempest.api_schema.response.compute.v2_1 import availability_zone \
19 as schema
Ken'ichi Ohmichi4771cbc2015-01-19 23:45:23 +000020from tempest.common import service_client
Leo Toyodaa5278912013-04-16 15:40:12 +090021
22
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +000023class AvailabilityZoneClient(service_client.ServiceClient):
Leo Toyodaa5278912013-04-16 15:40:12 +090024
Ken'ichi Ohmichi3de6d982015-04-13 00:20:41 +000025 def list_availability_zones(self, detail=False):
26 url = 'os-availability-zone'
27 schema_list = schema.list_availability_zone_list
28 if detail:
29 url += '/detail'
30 schema_list = schema.list_availability_zone_list_detail
Leo Toyodaa5278912013-04-16 15:40:12 +090031
Ken'ichi Ohmichi3de6d982015-04-13 00:20:41 +000032 resp, body = self.get(url)
Leo Toyodaa5278912013-04-16 15:40:12 +090033 body = json.loads(body)
Ken'ichi Ohmichi3de6d982015-04-13 00:20:41 +000034 self.validate_response(schema_list, resp, body)
ghanshyamc651ea02015-08-04 15:18:12 +090035 return service_client.ResponseBody(resp, body)