blob: 165f565ac5bb277259fce1794bc739294b73297f [file] [log] [blame]
ZhiQiang Fan39f97222013-09-20 04:49:44 +08001# Copyright 2012 OpenStack Foundation
Jay Pipes13b479b2012-06-11 14:52:27 -04002# 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
David Kranzcf0040c2012-06-26 09:46:56 -040016import time
Jay Pipesf38eaac2012-06-21 13:37:35 -040017
Doug Hellmann583ce2c2015-03-11 14:55:46 +000018from oslo_log import log as logging
Matthew Treinish01472ff2015-02-20 17:26:52 -050019from tempest_lib import exceptions as lib_exc
20
Ken'ichi Ohmichi4d237e72015-11-05 06:32:33 +000021from tempest.common import api_version_utils
Joseph Lanouxb3e1f872015-01-30 11:13:07 +000022from tempest.common import compute
Fei Long Wangd39431f2015-05-14 11:30:48 +120023from tempest.common.utils import data_utils
Ken'ichi Ohmichi8b9c7802015-07-08 05:57:37 +000024from tempest.common import waiters
Matthew Treinishb0a78fc2014-01-29 16:49:12 +000025from tempest import config
Attila Fazekasdc216422013-01-29 15:12:14 +010026import tempest.test
Jay Pipesf38eaac2012-06-21 13:37:35 -040027
Matthew Treinishb0a78fc2014-01-29 16:49:12 +000028CONF = config.CONF
Tiago Melloeda03b52012-08-22 23:47:29 -030029
Jay Pipesf38eaac2012-06-21 13:37:35 -040030LOG = logging.getLogger(__name__)
Daryl Walleckc7251962012-03-12 17:26:54 -050031
32
Ken'ichi Ohmichi4d237e72015-11-05 06:32:33 +000033class BaseV2ComputeTest(api_version_utils.BaseMicroversionTest,
34 tempest.test.BaseTestCase):
Sean Daguef237ccb2013-01-04 15:19:14 -050035 """Base test case class for all Compute API tests."""
Daryl Walleckc7251962012-03-12 17:26:54 -050036
Attila Fazekas430dae32013-10-17 15:19:32 +020037 force_tenant_isolation = False
Chris Yeoh8a79b9d2013-01-18 19:32:47 +103038
Andrea Frittolib21de6c2015-02-06 20:12:38 +000039 # TODO(andreaf) We should care also for the alt_manager here
40 # but only once client lazy load in the manager is done
41 credentials = ['primary']
42
Jay Pipesf38eaac2012-06-21 13:37:35 -040043 @classmethod
Emily Hugenbruche7991d92014-12-12 16:53:36 +000044 def skip_checks(cls):
Ken'ichi Ohmichi02a8ccd2015-11-05 06:05:29 +000045 super(BaseV2ComputeTest, cls).skip_checks()
Matthew Treinishf8ff3582015-08-25 12:41:56 -040046 if not CONF.service_available.nova:
47 raise cls.skipException("Nova is not available")
Ken'ichi Ohmichi4d237e72015-11-05 06:32:33 +000048 cfg_min_version = CONF.compute_feature_enabled.min_microversion
49 cfg_max_version = CONF.compute_feature_enabled.max_microversion
50 api_version_utils.check_skip_with_microversion(cls.min_microversion,
51 cls.max_microversion,
52 cfg_min_version,
53 cfg_max_version)
Jay Pipesf38eaac2012-06-21 13:37:35 -040054
Emily Hugenbruche7991d92014-12-12 16:53:36 +000055 @classmethod
56 def setup_credentials(cls):
57 cls.set_network_resources()
ghanshyam4e2be342015-11-27 18:07:46 +090058 cls.request_microversion = (
59 api_version_utils.select_request_microversion(
60 cls.min_microversion,
61 CONF.compute_feature_enabled.min_microversion))
62 if cls.request_microversion:
63 cls.services_microversion = {
64 CONF.compute.catalog_type: cls.request_microversion}
Ken'ichi Ohmichi02a8ccd2015-11-05 06:05:29 +000065 super(BaseV2ComputeTest, cls).setup_credentials()
Daryl Walleckc7251962012-03-12 17:26:54 -050066
Emily Hugenbruche7991d92014-12-12 16:53:36 +000067 @classmethod
68 def setup_clients(cls):
Ken'ichi Ohmichi02a8ccd2015-11-05 06:05:29 +000069 super(BaseV2ComputeTest, cls).setup_clients()
Emily Hugenbruche7991d92014-12-12 16:53:36 +000070 cls.servers_client = cls.os.servers_client
Ken'ichi Ohmichi7ca54b82015-07-07 01:10:26 +000071 cls.server_groups_client = cls.os.server_groups_client
Emily Hugenbruche7991d92014-12-12 16:53:36 +000072 cls.flavors_client = cls.os.flavors_client
73 cls.images_client = cls.os.images_client
74 cls.extensions_client = cls.os.extensions_client
Ken'ichi Ohmichi03af1c52015-07-13 00:28:05 +000075 cls.floating_ip_pools_client = cls.os.floating_ip_pools_client
John Warrene74890a2015-11-11 15:18:01 -050076 cls.floating_ips_client = cls.os.compute_floating_ips_client
Emily Hugenbruche7991d92014-12-12 16:53:36 +000077 cls.keypairs_client = cls.os.keypairs_client
Ken'ichi Ohmichi685cd172015-07-13 01:29:57 +000078 cls.security_group_rules_client = cls.os.security_group_rules_client
John Warrenf2345512015-12-10 13:39:30 -050079 cls.security_groups_client = cls.os.compute_security_groups_client
Emily Hugenbruche7991d92014-12-12 16:53:36 +000080 cls.quotas_client = cls.os.quotas_client
Emily Hugenbruche7991d92014-12-12 16:53:36 +000081 cls.quota_classes_client = cls.os.quota_classes_client
John Warren9487a182015-09-14 18:12:56 -040082 cls.compute_networks_client = cls.os.compute_networks_client
Emily Hugenbruche7991d92014-12-12 16:53:36 +000083 cls.limits_client = cls.os.limits_client
84 cls.volumes_extensions_client = cls.os.volumes_extensions_client
Gaozexub9c9d6e2015-09-10 17:08:04 +080085 cls.snapshots_extensions_client = cls.os.snapshots_extensions_client
Emily Hugenbruche7991d92014-12-12 16:53:36 +000086 cls.interfaces_client = cls.os.interfaces_client
87 cls.fixed_ips_client = cls.os.fixed_ips_client
88 cls.availability_zone_client = cls.os.availability_zone_client
89 cls.agents_client = cls.os.agents_client
90 cls.aggregates_client = cls.os.aggregates_client
91 cls.services_client = cls.os.services_client
92 cls.instance_usages_audit_log_client = (
93 cls.os.instance_usages_audit_log_client)
94 cls.hypervisor_client = cls.os.hypervisor_client
95 cls.certificates_client = cls.os.certificates_client
96 cls.migrations_client = cls.os.migrations_client
97 cls.security_group_default_rules_client = (
98 cls.os.security_group_default_rules_client)
Ken'ichi Ohmichi2b6012b2015-09-03 01:56:19 +000099 cls.versions_client = cls.os.compute_versions_client
Emily Hugenbruche7991d92014-12-12 16:53:36 +0000100
Ivan Kolodyazhnybcfc32e2015-08-06 13:31:36 +0300101 if CONF.volume_feature_enabled.api_v1:
102 cls.volumes_client = cls.os.volumes_client
103 else:
104 cls.volumes_client = cls.os.volumes_v2_client
105
Emily Hugenbruche7991d92014-12-12 16:53:36 +0000106 @classmethod
107 def resource_setup(cls):
Ken'ichi Ohmichi02a8ccd2015-11-05 06:05:29 +0000108 super(BaseV2ComputeTest, cls).resource_setup()
Matthew Treinishb0a78fc2014-01-29 16:49:12 +0000109 cls.build_interval = CONF.compute.build_interval
110 cls.build_timeout = CONF.compute.build_timeout
Matthew Treinishb0a78fc2014-01-29 16:49:12 +0000111 cls.image_ref = CONF.compute.image_ref
112 cls.image_ref_alt = CONF.compute.image_ref_alt
113 cls.flavor_ref = CONF.compute.flavor_ref
114 cls.flavor_ref_alt = CONF.compute.flavor_ref_alt
lanoux283273b2015-12-04 03:01:54 -0800115 cls.ssh_user = CONF.validation.image_ssh_user
116 cls.image_ssh_user = CONF.validation.image_ssh_user
117 cls.image_ssh_password = CONF.validation.image_ssh_password
Jay Pipesf38eaac2012-06-21 13:37:35 -0400118 cls.servers = []
Sean Dagued62bf1c2013-06-05 14:36:25 -0400119 cls.images = []
Zhi Kun Liu02e7a7b2014-01-08 16:08:32 +0800120 cls.security_groups = []
Abhijeet.Jain87dd4452014-04-23 15:51:23 +0530121 cls.server_groups = []
Matthew Treinishf7fca6a2013-12-09 16:27:23 +0000122
Emily Hugenbruche7991d92014-12-12 16:53:36 +0000123 @classmethod
124 def resource_cleanup(cls):
125 cls.clear_images()
126 cls.clear_servers()
127 cls.clear_security_groups()
128 cls.clear_server_groups()
Ken'ichi Ohmichi02a8ccd2015-11-05 06:05:29 +0000129 super(BaseV2ComputeTest, cls).resource_cleanup()
Ken'ichi Ohmichi543a5d42014-05-02 08:44:15 +0900130
Matthew Treinishf7fca6a2013-12-09 16:27:23 +0000131 @classmethod
Jay Pipes444c3e62012-10-04 19:26:35 -0400132 def clear_servers(cls):
Salvatore1422a9a2014-10-08 15:53:25 +0200133 LOG.debug('Clearing servers: %s', ','.join(
134 server['id'] for server in cls.servers))
Jay Pipes444c3e62012-10-04 19:26:35 -0400135 for server in cls.servers:
Dan Smith74e7bcb2012-08-21 09:18:26 -0700136 try:
137 cls.servers_client.delete_server(server['id'])
Masayuki Igawabfa07602015-01-20 18:47:17 +0900138 except lib_exc.NotFound:
Joe Gordon0c335792014-09-23 12:36:11 -0700139 # Something else already cleaned up the server, nothing to be
140 # worried about
Dan Smith74e7bcb2012-08-21 09:18:26 -0700141 pass
Joe Gordon0c335792014-09-23 12:36:11 -0700142 except Exception:
143 LOG.exception('Deleting server %s failed' % server['id'])
Dan Smith74e7bcb2012-08-21 09:18:26 -0700144
Jay Pipes444c3e62012-10-04 19:26:35 -0400145 for server in cls.servers:
Dan Smith74e7bcb2012-08-21 09:18:26 -0700146 try:
Ken'ichi Ohmichie91a0c62015-08-13 02:09:16 +0000147 waiters.wait_for_server_termination(cls.servers_client,
148 server['id'])
Dan Smith74e7bcb2012-08-21 09:18:26 -0700149 except Exception:
Joe Gordon0c335792014-09-23 12:36:11 -0700150 LOG.exception('Waiting for deletion of server %s failed'
151 % server['id'])
Dan Smith74e7bcb2012-08-21 09:18:26 -0700152
153 @classmethod
Attila Fazekas305e65b2013-10-29 13:23:07 +0100154 def server_check_teardown(cls):
155 """Checks is the shared server clean enough for subsequent test.
Ken'ichi Ohmichi88363cb2015-11-19 08:00:54 +0000156
Attila Fazekas305e65b2013-10-29 13:23:07 +0100157 Method will delete the server when it's dirty.
158 The setUp method is responsible for creating a new server.
159 Exceptions raised in tearDown class are fails the test case,
Marian Horban6afb0232015-11-10 22:47:12 -0500160 This method supposed to use only by tearDown methods, when
Attila Fazekas305e65b2013-10-29 13:23:07 +0100161 the shared server_id is stored in the server_id of the class.
162 """
163 if getattr(cls, 'server_id', None) is not None:
164 try:
Ken'ichi Ohmichi0eb153c2015-07-13 02:18:25 +0000165 waiters.wait_for_server_status(cls.servers_client,
166 cls.server_id, 'ACTIVE')
Attila Fazekas305e65b2013-10-29 13:23:07 +0100167 except Exception as exc:
168 LOG.exception(exc)
169 cls.servers_client.delete_server(cls.server_id)
Ken'ichi Ohmichie91a0c62015-08-13 02:09:16 +0000170 waiters.wait_for_server_termination(cls.servers_client,
171 cls.server_id)
Attila Fazekas305e65b2013-10-29 13:23:07 +0100172 cls.server_id = None
173 raise
174
175 @classmethod
Sean Dagued62bf1c2013-06-05 14:36:25 -0400176 def clear_images(cls):
Salvatore1422a9a2014-10-08 15:53:25 +0200177 LOG.debug('Clearing images: %s', ','.join(cls.images))
Sean Dagued62bf1c2013-06-05 14:36:25 -0400178 for image_id in cls.images:
179 try:
180 cls.images_client.delete_image(image_id)
Masayuki Igawabfa07602015-01-20 18:47:17 +0900181 except lib_exc.NotFound:
David Kranz33138312013-09-24 17:09:32 -0400182 # The image may have already been deleted which is OK.
183 pass
Yair Frieda039f872014-01-02 12:11:10 +0200184 except Exception:
185 LOG.exception('Exception raised deleting image %s' % image_id)
Sean Dagued62bf1c2013-06-05 14:36:25 -0400186
187 @classmethod
Zhi Kun Liu02e7a7b2014-01-08 16:08:32 +0800188 def clear_security_groups(cls):
Salvatore1422a9a2014-10-08 15:53:25 +0200189 LOG.debug('Clearing security groups: %s', ','.join(
190 str(sg['id']) for sg in cls.security_groups))
Zhi Kun Liu02e7a7b2014-01-08 16:08:32 +0800191 for sg in cls.security_groups:
192 try:
David Kranz9964b4e2015-02-06 15:45:29 -0500193 cls.security_groups_client.delete_security_group(sg['id'])
Masayuki Igawabfa07602015-01-20 18:47:17 +0900194 except lib_exc.NotFound:
Zhi Kun Liu02e7a7b2014-01-08 16:08:32 +0800195 # The security group may have already been deleted which is OK.
196 pass
197 except Exception as exc:
198 LOG.info('Exception raised deleting security group %s',
199 sg['id'])
200 LOG.exception(exc)
Zhi Kun Liu02e7a7b2014-01-08 16:08:32 +0800201
202 @classmethod
Abhijeet.Jain87dd4452014-04-23 15:51:23 +0530203 def clear_server_groups(cls):
Salvatore1422a9a2014-10-08 15:53:25 +0200204 LOG.debug('Clearing server groups: %s', ','.join(cls.server_groups))
Abhijeet.Jain87dd4452014-04-23 15:51:23 +0530205 for server_group_id in cls.server_groups:
206 try:
Ken'ichi Ohmichi7ca54b82015-07-07 01:10:26 +0000207 cls.server_groups_client.delete_server_group(server_group_id)
Masayuki Igawabfa07602015-01-20 18:47:17 +0900208 except lib_exc.NotFound:
Abhijeet.Jain87dd4452014-04-23 15:51:23 +0530209 # The server-group may have already been deleted which is OK.
210 pass
211 except Exception:
212 LOG.exception('Exception raised deleting server-group %s',
213 server_group_id)
214
215 @classmethod
Joe Gordon8843f0f2015-03-17 15:07:34 -0700216 def create_test_server(cls, validatable=False, volume_backed=False,
217 **kwargs):
Joseph Lanouxb3e1f872015-01-30 11:13:07 +0000218 """Wrapper utility that returns a test server.
Rohit Karajgidc300b22012-05-04 08:11:00 -0700219
Joseph Lanouxb3e1f872015-01-30 11:13:07 +0000220 This wrapper utility calls the common create test server and
221 returns a test server. The purpose of this wrapper is to minimize
222 the impact on the code of the tests already using this
223 function.
Joe Gordon8843f0f2015-03-17 15:07:34 -0700224
225 :param validatable: Whether the server will be pingable or sshable.
226 :param volume_backed: Whether the instance is volume backed or not.
Joseph Lanouxb3e1f872015-01-30 11:13:07 +0000227 """
228 tenant_network = cls.get_tenant_network()
229 body, servers = compute.create_test_server(
230 cls.os,
231 validatable,
232 validation_resources=cls.validation_resources,
233 tenant_network=tenant_network,
Joe Gordon8843f0f2015-03-17 15:07:34 -0700234 volume_backed=volume_backed,
Joseph Lanouxb3e1f872015-01-30 11:13:07 +0000235 **kwargs)
Ken'ichi Ohmichi51c8c262013-12-21 03:30:37 +0900236
237 cls.servers.extend(servers)
Sean Dague9b669e32012-12-13 18:40:08 -0500238
David Kranz0fb14292015-02-11 15:55:20 -0500239 return body
Sean Dague9b669e32012-12-13 18:40:08 -0500240
Zhi Kun Liu02e7a7b2014-01-08 16:08:32 +0800241 @classmethod
242 def create_security_group(cls, name=None, description=None):
243 if name is None:
244 name = data_utils.rand_name(cls.__name__ + "-securitygroup")
245 if description is None:
Ken'ichi Ohmichi4937f562015-03-23 00:15:01 +0000246 description = data_utils.rand_name('description')
ghanshyamb610b772015-08-24 17:29:38 +0900247 body = cls.security_groups_client.create_security_group(
248 name=name, description=description)['security_group']
Zhi Kun Liu02e7a7b2014-01-08 16:08:32 +0800249 cls.security_groups.append(body)
250
David Kranz9964b4e2015-02-06 15:45:29 -0500251 return body
Zhi Kun Liu02e7a7b2014-01-08 16:08:32 +0800252
Abhijeet.Jain87dd4452014-04-23 15:51:23 +0530253 @classmethod
Ghanshyam2a180b82014-06-16 13:54:22 +0900254 def create_test_server_group(cls, name="", policy=None):
Abhijeet.Jain87dd4452014-04-23 15:51:23 +0530255 if not name:
256 name = data_utils.rand_name(cls.__name__ + "-Server-Group")
Ghanshyam2a180b82014-06-16 13:54:22 +0900257 if policy is None:
Abhijeet.Jain87dd4452014-04-23 15:51:23 +0530258 policy = ['affinity']
Ken'ichi Ohmichi1f36daa2015-09-30 01:41:34 +0000259 body = cls.server_groups_client.create_server_group(
260 name=name, policies=policy)['server_group']
David Kranzda5d4ec2014-06-24 16:04:57 -0400261 cls.server_groups.append(body['id'])
David Kranzae99b9a2015-02-16 13:37:01 -0500262 return body
Abhijeet.Jain87dd4452014-04-23 15:51:23 +0530263
David Kranzcf0040c2012-06-26 09:46:56 -0400264 def wait_for(self, condition):
Sean Daguef237ccb2013-01-04 15:19:14 -0500265 """Repeatedly calls condition() until a timeout."""
David Kranzcf0040c2012-06-26 09:46:56 -0400266 start_time = int(time.time())
267 while True:
268 try:
269 condition()
Matthew Treinish05d9fb92012-12-07 16:14:05 -0500270 except Exception:
David Kranzcf0040c2012-06-26 09:46:56 -0400271 pass
272 else:
273 return
274 if int(time.time()) - start_time >= self.build_timeout:
275 condition()
276 return
277 time.sleep(self.build_interval)
Jay Pipesf38eaac2012-06-21 13:37:35 -0400278
Matt Riedemann807d0562014-01-27 12:03:10 -0800279 @staticmethod
280 def _delete_volume(volumes_client, volume_id):
281 """Deletes the given volume and waits for it to be gone."""
282 try:
Joseph Lanoux6809bab2014-12-18 14:57:18 +0000283 volumes_client.delete_volume(volume_id)
Matt Riedemann807d0562014-01-27 12:03:10 -0800284 # TODO(mriedem): We should move the wait_for_resource_deletion
285 # into the delete_volume method as a convenience to the caller.
286 volumes_client.wait_for_resource_deletion(volume_id)
Masayuki Igawabfa07602015-01-20 18:47:17 +0900287 except lib_exc.NotFound:
Matt Riedemann807d0562014-01-27 12:03:10 -0800288 LOG.warn("Unable to delete volume '%s' since it was not found. "
289 "Maybe it was already deleted?" % volume_id)
290
Attila Fazekas423834d2014-03-14 17:33:13 +0100291 @classmethod
292 def prepare_instance_network(cls):
Joseph Lanouxffe09dd2015-03-18 16:45:33 +0000293 if (CONF.validation.auth_method != 'disabled' and
294 CONF.validation.connect_method == 'floating'):
Attila Fazekas423834d2014-03-14 17:33:13 +0100295 cls.set_network_resources(network=True, subnet=True, router=True,
296 dhcp=True)
297
ivan-zhu8f992be2013-07-31 14:56:58 +0800298 @classmethod
299 def create_image_from_server(cls, server_id, **kwargs):
300 """Wrapper utility that returns an image created from the server."""
Masayuki Igawa259c1132013-10-31 17:48:44 +0900301 name = data_utils.rand_name(cls.__name__ + "-image")
ivan-zhu8f992be2013-07-31 14:56:58 +0800302 if 'name' in kwargs:
303 name = kwargs.pop('name')
304
Ken'ichi Ohmichi28f18672015-07-17 10:00:38 +0000305 image = cls.images_client.create_image(server_id, name=name)
David Kranza5299eb2015-01-15 17:24:05 -0500306 image_id = data_utils.parse_image_id(image.response['location'])
ivan-zhu8f992be2013-07-31 14:56:58 +0800307 cls.images.append(image_id)
308
309 if 'wait_until' in kwargs:
Ken'ichi Ohmichi8b9c7802015-07-08 05:57:37 +0000310 waiters.wait_for_image_status(cls.images_client,
311 image_id, kwargs['wait_until'])
ghanshyam1756e0b2015-08-18 19:19:05 +0900312 image = cls.images_client.show_image(image_id)['image']
ivan-zhu8f992be2013-07-31 14:56:58 +0800313
Bob Ball621e4602013-12-06 19:53:43 +0000314 if kwargs['wait_until'] == 'ACTIVE':
315 if kwargs.get('wait_for_server', True):
Ken'ichi Ohmichi0eb153c2015-07-13 02:18:25 +0000316 waiters.wait_for_server_status(cls.servers_client,
317 server_id, 'ACTIVE')
David Kranza5299eb2015-01-15 17:24:05 -0500318 return image
ivan-zhu8f992be2013-07-31 14:56:58 +0800319
320 @classmethod
Joseph Lanouxffe09dd2015-03-18 16:45:33 +0000321 def rebuild_server(cls, server_id, validatable=False, **kwargs):
ivan-zhu8f992be2013-07-31 14:56:58 +0800322 # Destroy an existing server and creates a new one
Matthew Treinish2cd19a42013-12-02 21:54:42 +0000323 if server_id:
324 try:
325 cls.servers_client.delete_server(server_id)
Ken'ichi Ohmichie91a0c62015-08-13 02:09:16 +0000326 waiters.wait_for_server_termination(cls.servers_client,
327 server_id)
Yair Frieda039f872014-01-02 12:11:10 +0200328 except Exception:
329 LOG.exception('Failed to delete server %s' % server_id)
Joseph Lanouxffe09dd2015-03-18 16:45:33 +0000330
331 server = cls.create_test_server(
332 validatable,
333 wait_until='ACTIVE',
334 **kwargs)
Ken'ichi Ohmichi9f5adf82014-12-12 04:01:32 +0000335 cls.password = server['adminPass']
Matthew Treinish2cd19a42013-12-02 21:54:42 +0000336 return server['id']
ivan-zhu8f992be2013-07-31 14:56:58 +0800337
Matt Riedemann5dc594c2014-01-27 11:40:28 -0800338 @classmethod
Jesse Keating613b4982015-05-04 15:05:19 -0700339 def delete_server(cls, server_id):
340 """Deletes an existing server and waits for it to be gone."""
341 try:
342 cls.servers_client.delete_server(server_id)
Ken'ichi Ohmichie91a0c62015-08-13 02:09:16 +0000343 waiters.wait_for_server_termination(cls.servers_client,
344 server_id)
Jesse Keating613b4982015-05-04 15:05:19 -0700345 except Exception:
346 LOG.exception('Failed to delete server %s' % server_id)
347
348 @classmethod
Matt Riedemann5dc594c2014-01-27 11:40:28 -0800349 def delete_volume(cls, volume_id):
350 """Deletes the given volume and waits for it to be gone."""
Ken'ichi Ohmichi9f5adf82014-12-12 04:01:32 +0000351 cls._delete_volume(cls.volumes_extensions_client, volume_id)
Ken'ichi Ohmichi543a5d42014-05-02 08:44:15 +0900352
Joseph Lanouxffe09dd2015-03-18 16:45:33 +0000353 @classmethod
354 def get_server_ip(cls, server):
355 """Get the server fixed or floating IP.
356
357 For the floating IP, the address created by the validation resources
358 is returned.
359 For the fixed IP, the server is returned and the current mechanism of
360 address extraction in the remote_client is followed.
361 """
362 if CONF.validation.connect_method == 'floating':
363 ip_or_server = cls.validation_resources['floating_ip']['ip']
364 elif CONF.validation.connect_method == 'fixed':
365 ip_or_server = server
366 return ip_or_server
367
Ken'ichi Ohmichi543a5d42014-05-02 08:44:15 +0900368
Ken'ichi Ohmichi02a8ccd2015-11-05 06:05:29 +0000369class BaseV2ComputeAdminTest(BaseV2ComputeTest):
Ken'ichi Ohmichibcefa3d2014-05-09 08:14:05 +0900370 """Base test case class for Compute Admin API tests."""
ivan-zhuf2b00502013-10-18 10:06:52 +0800371
Andrea Frittolib21de6c2015-02-06 20:12:38 +0000372 credentials = ['primary', 'admin']
Emily Hugenbruche7991d92014-12-12 16:53:36 +0000373
374 @classmethod
375 def setup_clients(cls):
Ken'ichi Ohmichi02a8ccd2015-11-05 06:05:29 +0000376 super(BaseV2ComputeAdminTest, cls).setup_clients()
Ken'ichi Ohmichi9f5adf82014-12-12 04:01:32 +0000377 cls.availability_zone_admin_client = (
378 cls.os_adm.availability_zone_client)