blob: a911191613b7a98dd45e9cf5077ecc74be2b18c5 [file] [log] [blame]
Matthew Treinish9e26ca82016-02-23 11:43:20 -05001# 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 oslo_serialization import jsonutils as json
17
18from tempest.lib.api_schema.response.compute.v2_1 import availability_zone \
19 as schema
20from tempest.lib.common import rest_client
Ghanshyamee9af302016-02-25 06:12:43 +090021from tempest.lib.services.compute import base_compute_client
Matthew Treinish9e26ca82016-02-23 11:43:20 -050022
23
Ghanshyamee9af302016-02-25 06:12:43 +090024class AvailabilityZoneClient(base_compute_client.BaseComputeClient):
Matthew Treinish9e26ca82016-02-23 11:43:20 -050025
26 def list_availability_zones(self, detail=False):
27 url = 'os-availability-zone'
28 schema_list = schema.list_availability_zone_list
29 if detail:
30 url += '/detail'
31 schema_list = schema.list_availability_zone_list_detail
32
33 resp, body = self.get(url)
34 body = json.loads(body)
35 self.validate_response(schema_list, resp, body)
36 return rest_client.ResponseBody(resp, body)