Leo Toyoda | a527891 | 2013-04-16 15:40:12 +0900 | [diff] [blame] | 1 | # 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 Treinish | 2190551 | 2015-07-13 10:33:35 -0400 | [diff] [blame] | 16 | from oslo_serialization import jsonutils as json |
Leo Toyoda | a527891 | 2013-04-16 15:40:12 +0900 | [diff] [blame] | 17 | |
ghanshyam | aa93b4b | 2015-03-20 11:03:44 +0900 | [diff] [blame] | 18 | from tempest.api_schema.response.compute.v2_1 import availability_zone \ |
| 19 | as schema |
Ken'ichi Ohmichi | 4771cbc | 2015-01-19 23:45:23 +0000 | [diff] [blame] | 20 | from tempest.common import service_client |
Leo Toyoda | a527891 | 2013-04-16 15:40:12 +0900 | [diff] [blame] | 21 | |
| 22 | |
Ken'ichi Ohmichi | a628707 | 2015-07-02 02:43:15 +0000 | [diff] [blame] | 23 | class AvailabilityZoneClient(service_client.ServiceClient): |
Leo Toyoda | a527891 | 2013-04-16 15:40:12 +0900 | [diff] [blame] | 24 | |
Ken'ichi Ohmichi | 3de6d98 | 2015-04-13 00:20:41 +0000 | [diff] [blame] | 25 | 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 Toyoda | a527891 | 2013-04-16 15:40:12 +0900 | [diff] [blame] | 31 | |
Ken'ichi Ohmichi | 3de6d98 | 2015-04-13 00:20:41 +0000 | [diff] [blame] | 32 | resp, body = self.get(url) |
Leo Toyoda | a527891 | 2013-04-16 15:40:12 +0900 | [diff] [blame] | 33 | body = json.loads(body) |
Ken'ichi Ohmichi | 3de6d98 | 2015-04-13 00:20:41 +0000 | [diff] [blame] | 34 | self.validate_response(schema_list, resp, body) |
ghanshyam | c651ea0 | 2015-08-04 15:18:12 +0900 | [diff] [blame] | 35 | return service_client.ResponseBody(resp, body) |