Merge "Use Tempest-lib's availability_zone_client"
diff --git a/tempest/api_schema/response/compute/v2_1/availability_zone.py b/tempest/api_schema/response/compute/v2_1/availability_zone.py
deleted file mode 100644
index d9aebce..0000000
--- a/tempest/api_schema/response/compute/v2_1/availability_zone.py
+++ /dev/null
@@ -1,78 +0,0 @@
-# Copyright 2014 NEC Corporation.  All rights reserved.
-#
-#    Licensed under the Apache License, Version 2.0 (the "License"); you may
-#    not use this file except in compliance with the License. You may obtain
-#    a copy of the License at
-#
-#         http://www.apache.org/licenses/LICENSE-2.0
-#
-#    Unless required by applicable law or agreed to in writing, software
-#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-#    License for the specific language governing permissions and limitations
-#    under the License.
-
-import copy
-
-
-base = {
-    'status_code': [200],
-    'response_body': {
-        'type': 'object',
-        'properties': {
-            'availabilityZoneInfo': {
-                'type': 'array',
-                'items': {
-                    'type': 'object',
-                    'properties': {
-                        'zoneName': {'type': 'string'},
-                        'zoneState': {
-                            'type': 'object',
-                            'properties': {
-                                'available': {'type': 'boolean'}
-                            },
-                            'additionalProperties': False,
-                            'required': ['available']
-                        },
-                        # NOTE: Here is the difference between detail and
-                        # non-detail.
-                        'hosts': {'type': 'null'}
-                    },
-                    'additionalProperties': False,
-                    'required': ['zoneName', 'zoneState', 'hosts']
-                }
-            }
-        },
-        'additionalProperties': False,
-        'required': ['availabilityZoneInfo']
-    }
-}
-
-detail = {
-    'type': 'object',
-    'patternProperties': {
-        # NOTE: Here is for a hostname
-        '^[a-zA-Z0-9-_.]+$': {
-            'type': 'object',
-            'patternProperties': {
-                # NOTE: Here is for a service name
-                '^.*$': {
-                    'type': 'object',
-                    'properties': {
-                        'available': {'type': 'boolean'},
-                        'active': {'type': 'boolean'},
-                        'updated_at': {'type': ['string', 'null']}
-                    },
-                    'additionalProperties': False,
-                    'required': ['available', 'active', 'updated_at']
-                }
-            }
-        }
-    }
-}
-
-list_availability_zone_list = copy.deepcopy(base)
-
-list_availability_zone_list_detail = copy.deepcopy(base)
-list_availability_zone_list_detail['response_body']['properties'][
-    'availabilityZoneInfo']['items']['properties']['hosts'] = detail
diff --git a/tempest/clients.py b/tempest/clients.py
index 276f7eb..c545f94 100644
--- a/tempest/clients.py
+++ b/tempest/clients.py
@@ -18,6 +18,8 @@
 from oslo_log import log as logging
 from tempest_lib.services.compute.agents_client import AgentsClient
 from tempest_lib.services.compute.aggregates_client import AggregatesClient
+from tempest_lib.services.compute.availability_zone_client import \
+    AvailabilityZoneClient
 from tempest_lib.services.identity.v2.token_client import TokenClient
 from tempest_lib.services.identity.v3.token_client import V3TokenClient
 
@@ -29,8 +31,6 @@
 from tempest.services.baremetal.v1.json.baremetal_client import \
     BaremetalClient
 from tempest.services import botoclients
-from tempest.services.compute.json.availability_zone_client import \
-    AvailabilityZoneClient
 from tempest.services.compute.json.baremetal_nodes_client import \
     BaremetalNodesClient
 from tempest.services.compute.json.certificates_client import \
diff --git a/tempest/services/compute/json/availability_zone_client.py b/tempest/services/compute/json/availability_zone_client.py
deleted file mode 100644
index 0012637..0000000
--- a/tempest/services/compute/json/availability_zone_client.py
+++ /dev/null
@@ -1,35 +0,0 @@
-# Copyright 2013 NEC Corporation.
-# All Rights Reserved.
-#
-#    Licensed under the Apache License, Version 2.0 (the "License"); you may
-#    not use this file except in compliance with the License. You may obtain
-#    a copy of the License at
-#
-#         http://www.apache.org/licenses/LICENSE-2.0
-#
-#    Unless required by applicable law or agreed to in writing, software
-#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-#    License for the specific language governing permissions and limitations
-#    under the License.
-
-from oslo_serialization import jsonutils as json
-
-from tempest.api_schema.response.compute.v2_1 import availability_zone \
-    as schema
-from tempest.common import service_client
-
-
-class AvailabilityZoneClient(service_client.ServiceClient):
-
-    def list_availability_zones(self, detail=False):
-        url = 'os-availability-zone'
-        schema_list = schema.list_availability_zone_list
-        if detail:
-            url += '/detail'
-            schema_list = schema.list_availability_zone_list_detail
-
-        resp, body = self.get(url)
-        body = json.loads(body)
-        self.validate_response(schema_list, resp, body)
-        return service_client.ResponseBody(resp, body)
diff --git a/tempest/tests/common/test_service_clients.py b/tempest/tests/common/test_service_clients.py
index 4244616..45de762 100644
--- a/tempest/tests/common/test_service_clients.py
+++ b/tempest/tests/common/test_service_clients.py
@@ -17,7 +17,6 @@
 import six
 
 from tempest.services.baremetal.v1.json import baremetal_client
-from tempest.services.compute.json import availability_zone_client
 from tempest.services.compute.json import certificates_client
 from tempest.services.compute.json import extensions_client
 from tempest.services.compute.json import fixed_ips_client
@@ -107,7 +106,6 @@
     def test_service_client_creations_with_specified_args(self, mock_init):
         test_clients = [
             baremetal_client.BaremetalClient,
-            availability_zone_client.AvailabilityZoneClient,
             certificates_client.CertificatesClient,
             extensions_client.ExtensionsClient,
             fixed_ips_client.FixedIPsClient,
diff --git a/tempest/tests/services/compute/test_availability_zone_client.py b/tempest/tests/services/compute/test_availability_zone_client.py
deleted file mode 100644
index e1d94bc..0000000
--- a/tempest/tests/services/compute/test_availability_zone_client.py
+++ /dev/null
@@ -1,82 +0,0 @@
-# Copyright 2015 NEC Corporation.  All rights reserved.
-#
-#    Licensed under the Apache License, Version 2.0 (the "License"); you may
-#    not use this file except in compliance with the License. You may obtain
-#    a copy of the License at
-#
-#         http://www.apache.org/licenses/LICENSE-2.0
-#
-#    Unless required by applicable law or agreed to in writing, software
-#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-#    License for the specific language governing permissions and limitations
-#    under the License.
-
-import copy
-
-from tempest_lib.tests import fake_auth_provider
-
-from tempest.services.compute.json import availability_zone_client
-from tempest.tests.services.compute import base
-
-
-class TestAvailabilityZoneClient(base.BaseComputeServiceTest):
-
-    FAKE_AZ_INFO = {
-        "availabilityZoneInfo":
-        [
-            {
-                "zoneState": {
-                    "available": True
-                },
-                "hosts": None,
-                "zoneName": u'\xf4'
-            }
-        ]
-    }
-
-    FAKE_AZ_DETAILS = {
-        "testhost": {
-            "nova-compute": {
-                "available": True,
-                "active": True,
-                "updated_at": "2015-09-10T07:16:46.000000"
-            }
-        }
-    }
-
-    def setUp(self):
-        super(TestAvailabilityZoneClient, self).setUp()
-        fake_auth = fake_auth_provider.FakeAuthProvider()
-        self.client = availability_zone_client.AvailabilityZoneClient(
-            fake_auth, 'compute', 'regionOne')
-
-    def _test_availability_zones(self, to_utf=False):
-        self.check_service_client_function(
-            self.client.list_availability_zones,
-            'tempest.common.service_client.ServiceClient.get',
-            self.FAKE_AZ_INFO,
-            to_utf)
-
-    def _test_availability_zones_with_details(self, to_utf=False):
-        fake_az_details = copy.deepcopy(self.FAKE_AZ_INFO)
-        fake_az_details['availabilityZoneInfo'][0]['hosts'] = \
-            self.FAKE_AZ_DETAILS
-        self.check_service_client_function(
-            self.client.list_availability_zones,
-            'tempest.common.service_client.ServiceClient.get',
-            fake_az_details,
-            to_utf,
-            detail=True)
-
-    def test_list_availability_zones_with_str_body(self):
-        self._test_availability_zones()
-
-    def test_list_availability_zones_with_bytes_body(self):
-        self._test_availability_zones(True)
-
-    def test_list_availability_zones_with_str_body_and_details(self):
-        self._test_availability_zones_with_details()
-
-    def test_list_availability_zones_with_bytes_body_and_details(self):
-        self._test_availability_zones_with_details(True)