Merge "Cleanup tempest docs a bit"
diff --git a/tempest/api/compute/base.py b/tempest/api/compute/base.py
index a25a2af..2624fca 100644
--- a/tempest/api/compute/base.py
+++ b/tempest/api/compute/base.py
@@ -89,6 +89,7 @@
         cls.migrations_client = cls.os.migrations_client
         cls.security_group_default_rules_client = (
             cls.os.security_group_default_rules_client)
+        cls.versions_client = cls.os.compute_versions_client
 
     @classmethod
     def resource_setup(cls):
diff --git a/tempest/api/compute/servers/test_servers_negative.py b/tempest/api/compute/servers/test_servers_negative.py
index 17a9a29..d5b60da 100644
--- a/tempest/api/compute/servers/test_servers_negative.py
+++ b/tempest/api/compute/servers/test_servers_negative.py
@@ -243,22 +243,21 @@
     def test_update_name_of_non_existent_server(self):
         # Update name of a non-existent server
 
-        server_name = data_utils.rand_name('server')
+        nonexistent_server = data_utils.rand_uuid()
         new_name = data_utils.rand_name('server') + '_updated'
 
         self.assertRaises(lib_exc.NotFound, self.client.update_server,
-                          server_name, name=new_name)
+                          nonexistent_server, name=new_name)
 
     @test.attr(type=['negative'])
     @test.idempotent_id('38204696-17c6-44da-9590-40f87fb5a899')
     def test_update_server_set_empty_name(self):
         # Update name of the server to an empty string
 
-        server_name = data_utils.rand_name('server')
         new_name = ''
 
         self.assertRaises(lib_exc.BadRequest, self.client.update_server,
-                          server_name, name=new_name)
+                          self.server_id, name=new_name)
 
     @test.attr(type=['negative'])
     @test.idempotent_id('543d84c1-dd2e-4c6d-8cb2-b9da0efaa384')
diff --git a/tempest/api/compute/test_versions.py b/tempest/api/compute/test_versions.py
new file mode 100644
index 0000000..369cf31
--- /dev/null
+++ b/tempest/api/compute/test_versions.py
@@ -0,0 +1,24 @@
+# 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 tempest.api.compute import base
+from tempest import test
+
+
+class TestVersions(base.BaseComputeTest):
+
+    @test.idempotent_id('6c0a0990-43b6-4529-9b61-5fd8daf7c55c')
+    def test_list_api_versions(self):
+        result = self.versions_client.list_versions()
+        self.assertIsNotNone(result)
diff --git a/tempest/api/network/test_networks_negative.py b/tempest/api/network/test_networks_negative.py
index 5dc1c21..94c3f9a 100644
--- a/tempest/api/network/test_networks_negative.py
+++ b/tempest/api/network/test_networks_negative.py
@@ -26,35 +26,35 @@
     @test.attr(type=['negative'])
     @test.idempotent_id('9293e937-824d-42d2-8d5b-e985ea67002a')
     def test_show_non_existent_network(self):
-        non_exist_id = data_utils.rand_name('network')
+        non_exist_id = data_utils.rand_uuid()
         self.assertRaises(lib_exc.NotFound, self.client.show_network,
                           non_exist_id)
 
     @test.attr(type=['negative'])
     @test.idempotent_id('d746b40c-5e09-4043-99f7-cba1be8b70df')
     def test_show_non_existent_subnet(self):
-        non_exist_id = data_utils.rand_name('subnet')
+        non_exist_id = data_utils.rand_uuid()
         self.assertRaises(lib_exc.NotFound, self.client.show_subnet,
                           non_exist_id)
 
     @test.attr(type=['negative'])
     @test.idempotent_id('a954861d-cbfd-44e8-b0a9-7fab111f235d')
     def test_show_non_existent_port(self):
-        non_exist_id = data_utils.rand_name('port')
+        non_exist_id = data_utils.rand_uuid()
         self.assertRaises(lib_exc.NotFound, self.client.show_port,
                           non_exist_id)
 
     @test.attr(type=['negative'])
     @test.idempotent_id('98bfe4e3-574e-4012-8b17-b2647063de87')
     def test_update_non_existent_network(self):
-        non_exist_id = data_utils.rand_name('network')
+        non_exist_id = data_utils.rand_uuid()
         self.assertRaises(lib_exc.NotFound, self.client.update_network,
                           non_exist_id, name="new_name")
 
     @test.attr(type=['negative'])
     @test.idempotent_id('03795047-4a94-4120-a0a1-bd376e36fd4e')
     def test_delete_non_existent_network(self):
-        non_exist_id = data_utils.rand_name('network')
+        non_exist_id = data_utils.rand_uuid()
         self.assertRaises(lib_exc.NotFound, self.client.delete_network,
                           non_exist_id)
 
diff --git a/tempest/api/telemetry/base.py b/tempest/api/telemetry/base.py
index 5d1784f..8f07614 100644
--- a/tempest/api/telemetry/base.py
+++ b/tempest/api/telemetry/base.py
@@ -15,6 +15,7 @@
 from oslo_utils import timeutils
 from tempest_lib import exceptions as lib_exc
 
+from tempest.common import compute
 from tempest.common.utils import data_utils
 from tempest import config
 from tempest import exceptions
@@ -73,9 +74,11 @@
 
     @classmethod
     def create_server(cls):
-        body = cls.servers_client.create_server(
-            data_utils.rand_name('ceilometer-instance'),
-            CONF.compute.image_ref, CONF.compute.flavor_ref,
+        tenant_network = cls.get_tenant_network()
+        body, server = compute.create_test_server(
+            cls.os,
+            tenant_network=tenant_network,
+            name=data_utils.rand_name('ceilometer-instance'),
             wait_until='ACTIVE')
         cls.server_ids.append(body['id'])
         return body
diff --git a/tempest/api_schema/response/compute/v2_1/version.py b/tempest/api_schema/response/compute/v2_1/version.py
deleted file mode 100644
index 6579c63..0000000
--- a/tempest/api_schema/response/compute/v2_1/version.py
+++ /dev/null
@@ -1,59 +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.
-
-version = {
-    'status_code': [200],
-    'response_body': {
-        'type': 'object',
-        'properties': {
-            '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']
-                        }
-                    },
-                    'media-types': {
-                        'type': 'array',
-                        'items': {
-                            'type': 'object',
-                            'properties': {
-                                'base': {'type': 'string'},
-                                'type': {'type': 'string'}
-                            },
-                            'required': ['base', 'type']
-                        }
-                    },
-                    'status': {'type': 'string'},
-                    'updated': {'type': 'string', 'format': 'date-time'},
-                    'version': {'type': 'string'},
-                    'min_version': {'type': 'string'}
-                },
-                # NOTE: version and min_version have been added since Kilo,
-                # so they should not be required.
-                'required': ['id', 'links', 'media-types', 'status', 'updated']
-            }
-        },
-        'required': ['version']
-    }
-}
diff --git a/tempest/api_schema/response/compute/v2_1/versions.py b/tempest/api_schema/response/compute/v2_1/versions.py
new file mode 100644
index 0000000..a01dd41
--- /dev/null
+++ b/tempest/api_schema/response/compute/v2_1/versions.py
@@ -0,0 +1,54 @@
+# 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.
+
+list_versions = {
+    'status_code': [200],
+    'response_body': {
+        'type': 'object',
+        'properties': {
+            'versions': {
+                'type': 'array',
+                'items': {
+                    'type': 'object',
+                    'properties': {
+                        'id': {'type': 'string'},
+                        'links': {
+                            'type': 'array',
+                            'items': {
+                                'type': 'object',
+                                'properties': {
+                                    'href': {'type': 'string',
+                                             'format': 'uri'},
+                                    'rel': {'type': 'string'},
+                                },
+                                'required': ['href', 'rel'],
+                                'additionalProperties': False
+                            }
+                        },
+                        'status': {'type': 'string'},
+                        'updated': {'type': 'string', 'format': 'date-time'},
+                        'version': {'type': 'string'},
+                        'min_version': {'type': 'string'}
+                    },
+                    # NOTE: version and min_version have been added since Kilo,
+                    # so they should not be required.
+                    'required': ['id', 'links', 'status', 'updated'],
+                    'additionalProperties': False
+                }
+            }
+        },
+        'required': ['versions'],
+        'additionalProperties': False
+    }
+}
diff --git a/tempest/clients.py b/tempest/clients.py
index b9f7991..c0d4585 100644
--- a/tempest/clients.py
+++ b/tempest/clients.py
@@ -77,6 +77,7 @@
     TenantNetworksClient
 from tempest.services.compute.json.tenant_usages_client import \
     TenantUsagesClient
+from tempest.services.compute.json.versions_client import VersionsClient
 from tempest.services.compute.json.volumes_extensions_client import \
     VolumesExtensionsClient
 from tempest.services.data_processing.v1_1.data_processing_client import \
@@ -322,6 +323,8 @@
         })
         self.volumes_extensions_client = VolumesExtensionsClient(
             self.auth_provider, **params_volume)
+        self.compute_versions_client = VersionsClient(self.auth_provider,
+                                                      **params_volume)
 
     def _set_database_clients(self):
         self.database_flavors_client = DatabaseFlavorsClient(
diff --git a/tempest/common/compute.py b/tempest/common/compute.py
index 05ea393..5c4d8af 100644
--- a/tempest/common/compute.py
+++ b/tempest/common/compute.py
@@ -27,7 +27,7 @@
 
 
 def create_test_server(clients, validatable=False, validation_resources=None,
-                       tenant_network=None, **kwargs):
+                       tenant_network=None, wait_until=None, **kwargs):
     """Common wrapper utility returning a test server.
 
     This method is a common wrapper returning a test server that can be
@@ -37,6 +37,9 @@
     :param validatable: Whether the server will be pingable or sshable.
     :param validation_resources: Resources created for the connection to the
     server. Include a keypair, a security group and an IP.
+    :param tenant_network: Tenant network to be used for creating a server.
+    :param wait_until: Server status to wait for the server to reach after
+    its creation.
     :returns a tuple
     """
 
@@ -78,8 +81,8 @@
                 LOG.debug("No key provided.")
 
         if CONF.validation.connect_method == 'floating':
-            if 'wait_until' not in kwargs:
-                kwargs['wait_until'] = 'ACTIVE'
+            if wait_until is None:
+                wait_until = 'ACTIVE'
 
     body = clients.servers_client.create_server(name, image_id, flavor,
                                                 **kwargs)
@@ -96,11 +99,11 @@
     # long for PEP8 compliance so:
     assoc = clients.floating_ips_client.associate_floating_ip_to_server
 
-    if 'wait_until' in kwargs:
+    if wait_until:
         for server in servers:
             try:
                 waiters.wait_for_server_status(
-                    clients.servers_client, server['id'], kwargs['wait_until'])
+                    clients.servers_client, server['id'], wait_until)
 
                 # Multiple validatable servers are not supported for now. Their
                 # creation will fail with the condition above (l.58).
diff --git a/tempest/scenario/test_volume_boot_pattern.py b/tempest/scenario/test_volume_boot_pattern.py
index 5a14a94..82f8b4c 100644
--- a/tempest/scenario/test_volume_boot_pattern.py
+++ b/tempest/scenario/test_volume_boot_pattern.py
@@ -100,14 +100,7 @@
 
     def _ssh_to_server(self, server, keypair):
         if CONF.compute.use_floatingip_for_ssh:
-            floating_ip = (self.floating_ips_client.create_floating_ip()
-                           ['floating_ip'])
-            self.addCleanup(self.delete_wrapper,
-                            self.floating_ips_client.delete_floating_ip,
-                            floating_ip['id'])
-            self.floating_ips_client.associate_floating_ip_to_server(
-                floating_ip['ip'], server['id'])
-            ip = floating_ip['ip']
+            ip = self.create_floating_ip(server)['ip']
         else:
             ip = server
 
diff --git a/tempest/services/compute/json/versions_client.py b/tempest/services/compute/json/versions_client.py
new file mode 100644
index 0000000..cbad02c
--- /dev/null
+++ b/tempest/services/compute/json/versions_client.py
@@ -0,0 +1,37 @@
+# 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 list_versions(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)
+        version_url = '%s://%s/' % (url.scheme, url.netloc)
+
+        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)