Merge "Add hard reboot for outputting console log"
diff --git a/tempest/api/compute/base.py b/tempest/api/compute/base.py
index 4b6816b..a4a877c 100644
--- a/tempest/api/compute/base.py
+++ b/tempest/api/compute/base.py
@@ -233,6 +233,7 @@
         cls.images_client = cls.os.image_client
         cls.services_client = cls.os.services_v3_client
         cls.extensions_client = cls.os.extensions_v3_client
+        cls.availability_zone_client = cls.os.availability_zone_v3_client
 
     @classmethod
     def create_image_from_server(cls, server_id, **kwargs):
@@ -293,3 +294,5 @@
         cls.os_adm = os_adm
         cls.severs_admin_client = cls.os_adm.servers_v3_client
         cls.services_admin_client = cls.os_adm.services_v3_client
+        cls.availability_zone_admin_client = \
+            cls.os_adm.availability_zone_v3_client
diff --git a/tempest/api/compute/images/test_images_oneserver_negative.py b/tempest/api/compute/images/test_images_oneserver_negative.py
index db3acb5..b4e778c 100644
--- a/tempest/api/compute/images/test_images_oneserver_negative.py
+++ b/tempest/api/compute/images/test_images_oneserver_negative.py
@@ -19,8 +19,7 @@
 from tempest.api import compute
 from tempest.api.compute import base
 from tempest import clients
-from tempest.common.utils.data_utils import parse_image_id
-from tempest.common.utils.data_utils import rand_name
+from tempest.common.utils import data_utils
 from tempest import exceptions
 from tempest.openstack.common import log as logging
 from tempest.test import attr
@@ -86,7 +85,7 @@
     @attr(type=['negative', 'gate'])
     def test_create_image_specify_multibyte_character_image_name(self):
         # Return an error if the image name has multi-byte characters
-        snapshot_name = rand_name('\xef\xbb\xbf')
+        snapshot_name = data_utils.rand_name('\xef\xbb\xbf')
         self.assertRaises(exceptions.BadRequest,
                           self.client.create_image, self.server_id,
                           snapshot_name)
@@ -94,7 +93,7 @@
     @attr(type=['negative', 'gate'])
     def test_create_image_specify_invalid_metadata(self):
         # Return an error when creating image with invalid metadata
-        snapshot_name = rand_name('test-snap-')
+        snapshot_name = data_utils.rand_name('test-snap-')
         meta = {'': ''}
         self.assertRaises(exceptions.BadRequest, self.client.create_image,
                           self.server_id, snapshot_name, meta)
@@ -102,7 +101,7 @@
     @attr(type=['negative', 'gate'])
     def test_create_image_specify_metadata_over_limits(self):
         # Return an error when creating image with meta data over 256 chars
-        snapshot_name = rand_name('test-snap-')
+        snapshot_name = data_utils.rand_name('test-snap-')
         meta = {'a' * 260: 'b' * 260}
         self.assertRaises(exceptions.BadRequest, self.client.create_image,
                           self.server_id, snapshot_name, meta)
@@ -112,15 +111,15 @@
         # Disallow creating another image when first image is being saved
 
         # Create first snapshot
-        snapshot_name = rand_name('test-snap-')
+        snapshot_name = data_utils.rand_name('test-snap-')
         resp, body = self.client.create_image(self.server_id,
                                               snapshot_name)
         self.assertEqual(202, resp.status)
-        image_id = parse_image_id(resp['location'])
+        image_id = data_utils.parse_image_id(resp['location'])
         self.image_ids.append(image_id)
 
         # Create second snapshot
-        alt_snapshot_name = rand_name('test-snap-')
+        alt_snapshot_name = data_utils.rand_name('test-snap-')
         self.assertRaises(exceptions.Conflict, self.client.create_image,
                           self.server_id, alt_snapshot_name)
         self.client.wait_for_image_status(image_id, 'ACTIVE')
@@ -129,7 +128,7 @@
     def test_create_image_specify_name_over_256_chars(self):
         # Return an error if snapshot name over 256 characters is passed
 
-        snapshot_name = rand_name('a' * 260)
+        snapshot_name = data_utils.rand_name('a' * 260)
         self.assertRaises(exceptions.BadRequest, self.client.create_image,
                           self.server_id, snapshot_name)
 
@@ -137,10 +136,10 @@
     def test_delete_image_that_is_not_yet_active(self):
         # Return an error while trying to delete an image what is creating
 
-        snapshot_name = rand_name('test-snap-')
+        snapshot_name = data_utils.rand_name('test-snap-')
         resp, body = self.client.create_image(self.server_id, snapshot_name)
         self.assertEqual(202, resp.status)
-        image_id = parse_image_id(resp['location'])
+        image_id = data_utils.parse_image_id(resp['location'])
         self.image_ids.append(image_id)
 
         # Do not wait, attempt to delete the image, ensure it's successful
diff --git a/tempest/api/compute/v3/admin/test_availability_zone.py b/tempest/api/compute/v3/admin/test_availability_zone.py
index d6488c4..ff2765c 100644
--- a/tempest/api/compute/v3/admin/test_availability_zone.py
+++ b/tempest/api/compute/v3/admin/test_availability_zone.py
@@ -20,7 +20,7 @@
 from tempest.test import attr
 
 
-class AvailabilityZoneAdminTestJSON(base.BaseV2ComputeAdminTest):
+class AvailabilityZoneAdminV3TestJSON(base.BaseV3ComputeAdminTest):
 
     """
     Tests Availability Zone API List that require admin privileges
@@ -30,8 +30,8 @@
 
     @classmethod
     def setUpClass(cls):
-        super(AvailabilityZoneAdminTestJSON, cls).setUpClass()
-        cls.client = cls.os_adm.availability_zone_client
+        super(AvailabilityZoneAdminV3TestJSON, cls).setUpClass()
+        cls.client = cls.availability_zone_admin_client
         cls.non_adm_client = cls.availability_zone_client
 
     @attr(type='gate')
@@ -66,5 +66,5 @@
             self.non_adm_client.get_availability_zone_list_detail)
 
 
-class AvailabilityZoneAdminTestXML(AvailabilityZoneAdminTestJSON):
+class AvailabilityZoneAdminV3TestXML(AvailabilityZoneAdminV3TestJSON):
     _interface = 'xml'
diff --git a/tempest/api/compute/v3/servers/test_list_server_filters.py b/tempest/api/compute/v3/servers/test_list_server_filters.py
index 5f14460..d333a1d 100644
--- a/tempest/api/compute/v3/servers/test_list_server_filters.py
+++ b/tempest/api/compute/v3/servers/test_list_server_filters.py
@@ -17,7 +17,7 @@
 
 from tempest.api.compute import base
 from tempest.api import utils
-from tempest.common.utils.data_utils import rand_name
+from tempest.common.utils import data_utils
 from tempest import config
 from tempest import exceptions
 from tempest.test import attr
@@ -57,16 +57,16 @@
             raise RuntimeError("Image %s (image_ref_alt) was not found!" %
                                cls.image_ref_alt)
 
-        cls.s1_name = rand_name(cls.__name__ + '-instance')
+        cls.s1_name = data_utils.rand_name(cls.__name__ + '-instance')
         resp, cls.s1 = cls.create_test_server(name=cls.s1_name,
                                               wait_until='ACTIVE')
 
-        cls.s2_name = rand_name(cls.__name__ + '-instance')
+        cls.s2_name = data_utils.rand_name(cls.__name__ + '-instance')
         resp, cls.s2 = cls.create_test_server(name=cls.s2_name,
                                               image_id=cls.image_ref_alt,
                                               wait_until='ACTIVE')
 
-        cls.s3_name = rand_name(cls.__name__ + '-instance')
+        cls.s3_name = data_utils.rand_name(cls.__name__ + '-instance')
         resp, cls.s3 = cls.create_test_server(name=cls.s3_name,
                                               flavor=cls.flavor_ref_alt,
                                               wait_until='ACTIVE')
diff --git a/tempest/api/network/admin/test_l3_agent_scheduler.py b/tempest/api/network/admin/test_l3_agent_scheduler.py
index 5b04cbb..9c187fd 100644
--- a/tempest/api/network/admin/test_l3_agent_scheduler.py
+++ b/tempest/api/network/admin/test_l3_agent_scheduler.py
@@ -15,7 +15,7 @@
 #    under the License.
 
 from tempest.api.network import base
-from tempest.common.utils.data_utils import rand_name
+from tempest.common.utils import data_utils
 from tempest.test import attr
 
 
@@ -50,7 +50,7 @@
 
     @attr(type='smoke')
     def test_list_l3_agents_hosting_router(self):
-        name = rand_name('router-')
+        name = data_utils.rand_name('router-')
         resp, router = self.client.create_router(name)
         self.assertEqual('201', resp['status'])
         resp, body = self.admin_client.list_l3_agents_hosting_router(
diff --git a/tempest/clients.py b/tempest/clients.py
index 9029d5f..b2399c7 100644
--- a/tempest/clients.py
+++ b/tempest/clients.py
@@ -50,12 +50,16 @@
     TenantUsagesClientJSON
 from tempest.services.compute.json.volumes_extensions_client import \
     VolumesExtensionsClientJSON
+from tempest.services.compute.v3.json.availability_zone_client import \
+    AvailabilityZoneV3ClientJSON
 from tempest.services.compute.v3.json.extensions_client import \
     ExtensionsV3ClientJSON
 from tempest.services.compute.v3.json.servers_client import \
     ServersV3ClientJSON
 from tempest.services.compute.v3.json.services_client import \
     ServicesV3ClientJSON
+from tempest.services.compute.v3.xml.availability_zone_client import \
+    AvailabilityZoneV3ClientXML
 from tempest.services.compute.v3.xml.extensions_client import \
     ExtensionsV3ClientXML
 from tempest.services.compute.v3.xml.servers_client import ServersV3ClientXML
@@ -209,6 +213,8 @@
             self.interfaces_client = InterfacesClientXML(*client_args)
             self.endpoints_client = EndPointClientXML(*client_args)
             self.fixed_ips_client = FixedIPsClientXML(*client_args)
+            self.availability_zone_v3_client = AvailabilityZoneV3ClientXML(
+                *client_args)
             self.availability_zone_client = AvailabilityZoneClientXML(
                 *client_args)
             self.services_v3_client = ServicesV3ClientXML(*client_args)
@@ -253,6 +259,8 @@
             self.interfaces_client = InterfacesClientJSON(*client_args)
             self.endpoints_client = EndPointClientJSON(*client_args)
             self.fixed_ips_client = FixedIPsClientJSON(*client_args)
+            self.availability_zone_v3_client = AvailabilityZoneV3ClientJSON(
+                *client_args)
             self.availability_zone_client = AvailabilityZoneClientJSON(
                 *client_args)
             self.services_v3_client = ServicesV3ClientJSON(*client_args)
diff --git a/tempest/common/isolated_creds.py b/tempest/common/isolated_creds.py
index 9459590..5dbb3a7 100644
--- a/tempest/common/isolated_creds.py
+++ b/tempest/common/isolated_creds.py
@@ -412,7 +412,11 @@
                 resp_body = self.network_admin_client.list_ports()
             self.ports = resp_body['ports']
         ports_to_delete = [
-            port for port in self.ports if port['network_id'] == network_id]
+            port
+            for port in self.ports
+            if (port['network_id'] == network_id and
+                port['device_owner'] != 'network:router_interface')
+        ]
         for port in ports_to_delete:
             try:
                 LOG.info('Cleaning up port id %s, name %s' %
diff --git a/tempest/services/compute/v3/json/availability_zone_client.py b/tempest/services/compute/v3/json/availability_zone_client.py
index b11871b..9a3fe8b 100644
--- a/tempest/services/compute/v3/json/availability_zone_client.py
+++ b/tempest/services/compute/v3/json/availability_zone_client.py
@@ -20,20 +20,20 @@
 from tempest.common.rest_client import RestClient
 
 
-class AvailabilityZoneClientJSON(RestClient):
+class AvailabilityZoneV3ClientJSON(RestClient):
 
     def __init__(self, config, username, password, auth_url, tenant_name=None):
-        super(AvailabilityZoneClientJSON, self).__init__(config, username,
-                                                         password, auth_url,
-                                                         tenant_name)
-        self.service = self.config.compute.catalog_type
+        super(AvailabilityZoneV3ClientJSON, self).__init__(config, username,
+                                                           password, auth_url,
+                                                           tenant_name)
+        self.service = self.config.compute.catalog_v3_type
 
     def get_availability_zone_list(self):
         resp, body = self.get('os-availability-zone')
         body = json.loads(body)
-        return resp, body['availabilityZoneInfo']
+        return resp, body['availability_zone_info']
 
     def get_availability_zone_list_detail(self):
         resp, body = self.get('os-availability-zone/detail')
         body = json.loads(body)
-        return resp, body['availabilityZoneInfo']
+        return resp, body['availability_zone_info']
diff --git a/tempest/services/compute/v3/xml/availability_zone_client.py b/tempest/services/compute/v3/xml/availability_zone_client.py
index ae93774..35fb2b1 100644
--- a/tempest/services/compute/v3/xml/availability_zone_client.py
+++ b/tempest/services/compute/v3/xml/availability_zone_client.py
@@ -21,13 +21,13 @@
 from tempest.services.compute.xml.common import xml_to_json
 
 
-class AvailabilityZoneClientXML(RestClientXML):
+class AvailabilityZoneV3ClientXML(RestClientXML):
 
     def __init__(self, config, username, password, auth_url, tenant_name=None):
-        super(AvailabilityZoneClientXML, self).__init__(config, username,
-                                                        password, auth_url,
-                                                        tenant_name)
-        self.service = self.config.compute.catalog_type
+        super(AvailabilityZoneV3ClientXML, self).__init__(config, username,
+                                                          password, auth_url,
+                                                          tenant_name)
+        self.service = self.config.compute.catalog_v3_type
 
     def _parse_array(self, node):
         return [xml_to_json(x) for x in node]