Merge "Use versions_client, versions from tempest-lib"
diff --git a/tempest/api_schema/response/compute/v2_1/versions.py b/tempest/api_schema/response/compute/v2_1/versions.py
deleted file mode 100644
index 08a9fab..0000000
--- a/tempest/api_schema/response/compute/v2_1/versions.py
+++ /dev/null
@@ -1,110 +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
-
-
-_version = {
-    'type': 'object',
-    'properties': {
-        'id': {'type': 'string'},
-        'links': {
-            'type': 'array',
-            'items': {
-                'type': 'object',
-                'properties': {
-                    'href': {'type': 'string', 'format': 'uri'},
-                    'rel': {'type': 'string'},
-                    'type': {'type': 'string'},
-                },
-                'required': ['href', 'rel'],
-                'additionalProperties': False
-            }
-        },
-        'status': {'type': 'string'},
-        'updated': {'type': 'string', 'format': 'date-time'},
-        'version': {'type': 'string'},
-        'min_version': {'type': 'string'},
-        'media-types': {
-            'type': 'array',
-            'properties': {
-                'base': {'type': 'string'},
-                'type': {'type': 'string'},
-            }
-        },
-    },
-    # NOTE: version and min_version have been added since Kilo,
-    # so they should not be required.
-    # NOTE(sdague): media-types only shows up in single version requests.
-    'required': ['id', 'links', 'status', 'updated'],
-    'additionalProperties': False
-}
-
-list_versions = {
-    'status_code': [200],
-    'response_body': {
-        'type': 'object',
-        'properties': {
-            'versions': {
-                'type': 'array',
-                'items': _version
-            }
-        },
-        'required': ['versions'],
-        'additionalProperties': False
-    }
-}
-
-
-_detail_get_version = copy.deepcopy(_version)
-_detail_get_version['properties'].pop('min_version')
-_detail_get_version['properties'].pop('version')
-_detail_get_version['properties'].pop('updated')
-_detail_get_version['properties']['media-types'] = {
-    'type': 'array',
-    'items': {
-        'type': 'object',
-        'properties': {
-            'base': {'type': 'string'},
-            'type': {'type': 'string'}
-        }
-    }
-}
-_detail_get_version['required'] = ['id', 'links', 'status', 'media-types']
-
-get_version = {
-    'status_code': [300],
-    'response_body': {
-        'type': 'object',
-        'properties': {
-            'choices': {
-                'type': 'array',
-                'items': _detail_get_version
-            }
-        },
-        'required': ['choices'],
-        'additionalProperties': False
-    }
-}
-
-get_one_version = {
-    'status_code': [200],
-    'response_body': {
-        'type': 'object',
-        'properties': {
-            'version': _version
-        },
-        'additionalProperties': False
-    }
-}
diff --git a/tempest/clients.py b/tempest/clients.py
index 5883ac7..b685bb7 100644
--- a/tempest/clients.py
+++ b/tempest/clients.py
@@ -56,6 +56,7 @@
     TenantNetworksClient
 from tempest_lib.services.compute.tenant_usages_client import \
     TenantUsagesClient
+from tempest_lib.services.compute.versions_client import VersionsClient
 from tempest_lib.services.identity.v2.token_client import TokenClient
 from tempest_lib.services.identity.v3.token_client import V3TokenClient
 
@@ -76,7 +77,6 @@
 from tempest.services.compute.json.server_groups_client import \
     ServerGroupsClient
 from tempest.services.compute.json.servers_client import ServersClient
-from tempest.services.compute.json.versions_client import VersionsClient
 from tempest.services.compute.json.volumes_client import \
     VolumesClient as ComputeVolumesClient
 from tempest.services.data_processing.v1_1.data_processing_client import \
diff --git a/tempest/services/compute/json/versions_client.py b/tempest/services/compute/json/versions_client.py
deleted file mode 100644
index 48c0e8d..0000000
--- a/tempest/services/compute/json/versions_client.py
+++ /dev/null
@@ -1,55 +0,0 @@
-# Copyright (c) 2015 Hewlett-Packard Development Company, L.P.
-#
-# 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 six.moves import urllib
-
-from tempest.api_schema.response.compute.v2_1 import versions as schema
-from tempest.common import service_client
-
-
-class VersionsClient(service_client.ServiceClient):
-
-    def _get_base_version_url(self):
-        # NOTE: The URL which is gotten from keystone's catalog contains
-        # API version and project-id like "v2/{project-id}", but we need
-        # to access the URL which doesn't contain them for getting API
-        # versions. For that, here should use raw_request() instead of
-        # get().
-        endpoint = self.base_url
-        url = urllib.parse.urlparse(endpoint)
-        return '%s://%s/' % (url.scheme, url.netloc)
-
-    def list_versions(self):
-        version_url = self._get_base_version_url()
-        resp, body = self.raw_request(version_url, 'GET')
-        body = json.loads(body)
-        self.validate_response(schema.list_versions, resp, body)
-        return service_client.ResponseBody(resp, body)
-
-    def get_version_by_url(self, version_url):
-        """Get the version document by url.
-
-        This gets the version document for a url, useful in testing
-        the contents of things like /v2/ or /v2.1/ in Nova. That
-        controller needs authenticated access, so we have to get
-        ourselves a token before making the request.
-
-        """
-        # we need a token for this request
-        resp, body = self.raw_request(version_url, 'GET',
-                                      {'X-Auth-Token': self.token})
-        body = json.loads(body)
-        self.validate_response(schema.get_one_version, resp, body)
-        return service_client.ResponseBody(resp, body)