Jay Pipes | 13b479b | 2012-06-11 14:52:27 -0400 | [diff] [blame] | 1 | # vim: tabstop=4 shiftwidth=4 softtabstop=4 |
| 2 | |
ZhiQiang Fan | 39f9722 | 2013-09-20 04:49:44 +0800 | [diff] [blame] | 3 | # Copyright 2012 OpenStack Foundation |
Jay Pipes | 13b479b | 2012-06-11 14:52:27 -0400 | [diff] [blame] | 4 | # All Rights Reserved. |
| 5 | # |
| 6 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 7 | # not use this file except in compliance with the License. You may obtain |
| 8 | # a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, software |
| 13 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 14 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 15 | # License for the specific language governing permissions and limitations |
| 16 | # under the License. |
| 17 | |
David Kranz | cf0040c | 2012-06-26 09:46:56 -0400 | [diff] [blame] | 18 | import time |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 19 | |
Sean Dague | 1937d09 | 2013-05-17 16:36:38 -0400 | [diff] [blame] | 20 | from tempest.api import compute |
Matthew Treinish | 481466b | 2012-12-20 17:16:01 -0500 | [diff] [blame] | 21 | from tempest import clients |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 22 | from tempest.common.utils import data_utils |
David Kranz | 3313831 | 2013-09-24 17:09:32 -0400 | [diff] [blame] | 23 | from tempest import exceptions |
Matthew Treinish | f4a9b0f | 2013-07-26 16:58:26 -0400 | [diff] [blame] | 24 | from tempest.openstack.common import log as logging |
Attila Fazekas | dc21642 | 2013-01-29 15:12:14 +0100 | [diff] [blame] | 25 | import tempest.test |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 26 | |
Tiago Mello | eda03b5 | 2012-08-22 23:47:29 -0300 | [diff] [blame] | 27 | |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 28 | LOG = logging.getLogger(__name__) |
Daryl Walleck | c725196 | 2012-03-12 17:26:54 -0500 | [diff] [blame] | 29 | |
| 30 | |
Attila Fazekas | dc21642 | 2013-01-29 15:12:14 +0100 | [diff] [blame] | 31 | class BaseComputeTest(tempest.test.BaseTestCase): |
Sean Dague | f237ccb | 2013-01-04 15:19:14 -0500 | [diff] [blame] | 32 | """Base test case class for all Compute API tests.""" |
Daryl Walleck | c725196 | 2012-03-12 17:26:54 -0500 | [diff] [blame] | 33 | |
Attila Fazekas | 9a63c94 | 2013-01-29 21:46:02 +0100 | [diff] [blame] | 34 | conclusion = compute.generic_setup_package() |
Attila Fazekas | 430dae3 | 2013-10-17 15:19:32 +0200 | [diff] [blame] | 35 | force_tenant_isolation = False |
Chris Yeoh | 8a79b9d | 2013-01-18 19:32:47 +1030 | [diff] [blame] | 36 | |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 37 | @classmethod |
| 38 | def setUpClass(cls): |
Attila Fazekas | f86fa31 | 2013-07-30 19:56:39 +0200 | [diff] [blame] | 39 | super(BaseComputeTest, cls).setUpClass() |
Matthew Treinish | 6b41e24 | 2013-07-19 16:49:28 -0400 | [diff] [blame] | 40 | if not cls.config.service_available.nova: |
| 41 | skip_msg = ("%s skipped as nova is not available" % cls.__name__) |
| 42 | raise cls.skipException(skip_msg) |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 43 | |
Ryan Hsu | 6c4bb3d | 2013-10-21 21:22:50 -0700 | [diff] [blame] | 44 | os = cls.get_client_manager() |
Daryl Walleck | c725196 | 2012-03-12 17:26:54 -0500 | [diff] [blame] | 45 | |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 46 | cls.os = os |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 47 | cls.build_interval = cls.config.compute.build_interval |
| 48 | cls.build_timeout = cls.config.compute.build_timeout |
| 49 | cls.ssh_user = cls.config.compute.ssh_user |
| 50 | cls.image_ref = cls.config.compute.image_ref |
| 51 | cls.image_ref_alt = cls.config.compute.image_ref_alt |
| 52 | cls.flavor_ref = cls.config.compute.flavor_ref |
| 53 | cls.flavor_ref_alt = cls.config.compute.flavor_ref_alt |
ivan-zhu | f2b0050 | 2013-10-18 10:06:52 +0800 | [diff] [blame] | 54 | cls.image_ssh_user = cls.config.compute.image_ssh_user |
| 55 | cls.image_ssh_password = cls.config.compute.image_ssh_password |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 56 | cls.servers = [] |
Sean Dague | d62bf1c | 2013-06-05 14:36:25 -0400 | [diff] [blame] | 57 | cls.images = [] |
Daryl Walleck | c725196 | 2012-03-12 17:26:54 -0500 | [diff] [blame] | 58 | |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 59 | @classmethod |
Jay Pipes | 444c3e6 | 2012-10-04 19:26:35 -0400 | [diff] [blame] | 60 | def clear_servers(cls): |
| 61 | for server in cls.servers: |
Dan Smith | 74e7bcb | 2012-08-21 09:18:26 -0700 | [diff] [blame] | 62 | try: |
| 63 | cls.servers_client.delete_server(server['id']) |
| 64 | except Exception: |
| 65 | pass |
| 66 | |
Jay Pipes | 444c3e6 | 2012-10-04 19:26:35 -0400 | [diff] [blame] | 67 | for server in cls.servers: |
Dan Smith | 74e7bcb | 2012-08-21 09:18:26 -0700 | [diff] [blame] | 68 | try: |
| 69 | cls.servers_client.wait_for_server_termination(server['id']) |
| 70 | except Exception: |
| 71 | pass |
| 72 | |
| 73 | @classmethod |
Sean Dague | d62bf1c | 2013-06-05 14:36:25 -0400 | [diff] [blame] | 74 | def clear_images(cls): |
| 75 | for image_id in cls.images: |
| 76 | try: |
| 77 | cls.images_client.delete_image(image_id) |
David Kranz | 3313831 | 2013-09-24 17:09:32 -0400 | [diff] [blame] | 78 | except exceptions.NotFound: |
| 79 | # The image may have already been deleted which is OK. |
| 80 | pass |
Sean Dague | d62bf1c | 2013-06-05 14:36:25 -0400 | [diff] [blame] | 81 | except Exception as exc: |
| 82 | LOG.info('Exception raised deleting image %s', image_id) |
| 83 | LOG.exception(exc) |
| 84 | pass |
| 85 | |
| 86 | @classmethod |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 87 | def tearDownClass(cls): |
Sean Dague | d62bf1c | 2013-06-05 14:36:25 -0400 | [diff] [blame] | 88 | cls.clear_images() |
Jay Pipes | 444c3e6 | 2012-10-04 19:26:35 -0400 | [diff] [blame] | 89 | cls.clear_servers() |
Ryan Hsu | 6c4bb3d | 2013-10-21 21:22:50 -0700 | [diff] [blame] | 90 | cls.clear_isolated_creds() |
Matthew Treinish | b86cda9 | 2013-07-29 11:22:23 -0400 | [diff] [blame] | 91 | super(BaseComputeTest, cls).tearDownClass() |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 92 | |
Jay Pipes | 444c3e6 | 2012-10-04 19:26:35 -0400 | [diff] [blame] | 93 | @classmethod |
Ken'ichi Ohmichi | cfc052e | 2013-10-23 11:50:04 +0900 | [diff] [blame] | 94 | def create_test_server(cls, **kwargs): |
Sean Dague | f237ccb | 2013-01-04 15:19:14 -0500 | [diff] [blame] | 95 | """Wrapper utility that returns a test server.""" |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 96 | name = data_utils.rand_name(cls.__name__ + "-instance") |
Sean Dague | 22897e1 | 2013-02-25 17:54:09 -0500 | [diff] [blame] | 97 | if 'name' in kwargs: |
| 98 | name = kwargs.pop('name') |
| 99 | flavor = kwargs.get('flavor', cls.flavor_ref) |
| 100 | image_id = kwargs.get('image_id', cls.image_ref) |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 101 | |
Andrea Frittoli | 938d151 | 2013-05-16 15:42:27 +0100 | [diff] [blame] | 102 | resp, body = cls.servers_client.create_server( |
Sean Dague | 22897e1 | 2013-02-25 17:54:09 -0500 | [diff] [blame] | 103 | name, image_id, flavor, **kwargs) |
Andrea Frittoli | 938d151 | 2013-05-16 15:42:27 +0100 | [diff] [blame] | 104 | |
| 105 | # handle the case of multiple servers |
| 106 | servers = [body] |
| 107 | if 'min_count' in kwargs or 'max_count' in kwargs: |
| 108 | # Get servers created which name match with name param. |
| 109 | r, b = cls.servers_client.list_servers() |
| 110 | servers = [s for s in b['servers'] if s['name'].startswith(name)] |
| 111 | |
| 112 | cls.servers.extend(servers) |
David Kranz | cf0040c | 2012-06-26 09:46:56 -0400 | [diff] [blame] | 113 | |
Sean Dague | 22897e1 | 2013-02-25 17:54:09 -0500 | [diff] [blame] | 114 | if 'wait_until' in kwargs: |
Andrea Frittoli | 938d151 | 2013-05-16 15:42:27 +0100 | [diff] [blame] | 115 | for server in servers: |
| 116 | cls.servers_client.wait_for_server_status( |
| 117 | server['id'], kwargs['wait_until']) |
Sean Dague | 9b669e3 | 2012-12-13 18:40:08 -0500 | [diff] [blame] | 118 | |
Andrea Frittoli | 938d151 | 2013-05-16 15:42:27 +0100 | [diff] [blame] | 119 | return resp, body |
Sean Dague | 9b669e3 | 2012-12-13 18:40:08 -0500 | [diff] [blame] | 120 | |
David Kranz | cf0040c | 2012-06-26 09:46:56 -0400 | [diff] [blame] | 121 | def wait_for(self, condition): |
Sean Dague | f237ccb | 2013-01-04 15:19:14 -0500 | [diff] [blame] | 122 | """Repeatedly calls condition() until a timeout.""" |
David Kranz | cf0040c | 2012-06-26 09:46:56 -0400 | [diff] [blame] | 123 | start_time = int(time.time()) |
| 124 | while True: |
| 125 | try: |
| 126 | condition() |
Matthew Treinish | 05d9fb9 | 2012-12-07 16:14:05 -0500 | [diff] [blame] | 127 | except Exception: |
David Kranz | cf0040c | 2012-06-26 09:46:56 -0400 | [diff] [blame] | 128 | pass |
| 129 | else: |
| 130 | return |
| 131 | if int(time.time()) - start_time >= self.build_timeout: |
| 132 | condition() |
| 133 | return |
| 134 | time.sleep(self.build_interval) |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 135 | |
| 136 | |
ivan-zhu | f2b0050 | 2013-10-18 10:06:52 +0800 | [diff] [blame] | 137 | class BaseV2ComputeTest(BaseComputeTest): |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 138 | |
| 139 | @classmethod |
| 140 | def setUpClass(cls): |
ivan-zhu | f2b0050 | 2013-10-18 10:06:52 +0800 | [diff] [blame] | 141 | super(BaseV2ComputeTest, cls).setUpClass() |
| 142 | cls.servers_client = cls.os.servers_client |
| 143 | cls.flavors_client = cls.os.flavors_client |
| 144 | cls.images_client = cls.os.images_client |
| 145 | cls.extensions_client = cls.os.extensions_client |
| 146 | cls.floating_ips_client = cls.os.floating_ips_client |
| 147 | cls.keypairs_client = cls.os.keypairs_client |
| 148 | cls.security_groups_client = cls.os.security_groups_client |
| 149 | cls.quotas_client = cls.os.quotas_client |
| 150 | cls.limits_client = cls.os.limits_client |
| 151 | cls.volumes_extensions_client = cls.os.volumes_extensions_client |
| 152 | cls.volumes_client = cls.os.volumes_client |
| 153 | cls.interfaces_client = cls.os.interfaces_client |
| 154 | cls.fixed_ips_client = cls.os.fixed_ips_client |
| 155 | cls.availability_zone_client = cls.os.availability_zone_client |
| 156 | cls.aggregates_client = cls.os.aggregates_client |
| 157 | cls.services_client = cls.os.services_client |
ivan-zhu | ef7a1bd | 2013-10-22 17:56:46 +0800 | [diff] [blame] | 158 | cls.instance_usages_audit_log_client = \ |
| 159 | cls.os.instance_usages_audit_log_client |
ivan-zhu | f2b0050 | 2013-10-18 10:06:52 +0800 | [diff] [blame] | 160 | cls.hypervisor_client = cls.os.hypervisor_client |
| 161 | cls.servers_client_v3_auth = cls.os.servers_client_v3_auth |
ivan-zhu | d57f3cf | 2013-11-06 16:59:52 +0800 | [diff] [blame] | 162 | cls.certificates_client = cls.os.certificates_client |
ivan-zhu | f2b0050 | 2013-10-18 10:06:52 +0800 | [diff] [blame] | 163 | |
ivan-zhu | 8f992be | 2013-07-31 14:56:58 +0800 | [diff] [blame] | 164 | @classmethod |
| 165 | def create_image_from_server(cls, server_id, **kwargs): |
| 166 | """Wrapper utility that returns an image created from the server.""" |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 167 | name = data_utils.rand_name(cls.__name__ + "-image") |
ivan-zhu | 8f992be | 2013-07-31 14:56:58 +0800 | [diff] [blame] | 168 | if 'name' in kwargs: |
| 169 | name = kwargs.pop('name') |
| 170 | |
| 171 | resp, image = cls.images_client.create_image( |
| 172 | server_id, name) |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 173 | image_id = data_utils.parse_image_id(resp['location']) |
ivan-zhu | 8f992be | 2013-07-31 14:56:58 +0800 | [diff] [blame] | 174 | cls.images.append(image_id) |
| 175 | |
| 176 | if 'wait_until' in kwargs: |
| 177 | cls.images_client.wait_for_image_status(image_id, |
| 178 | kwargs['wait_until']) |
| 179 | resp, image = cls.images_client.get_image(image_id) |
| 180 | |
| 181 | return resp, image |
| 182 | |
| 183 | @classmethod |
Matthew Treinish | 2cd19a4 | 2013-12-02 21:54:42 +0000 | [diff] [blame] | 184 | def rebuild_server(cls, server_id, **kwargs): |
ivan-zhu | 8f992be | 2013-07-31 14:56:58 +0800 | [diff] [blame] | 185 | # Destroy an existing server and creates a new one |
Matthew Treinish | 2cd19a4 | 2013-12-02 21:54:42 +0000 | [diff] [blame] | 186 | if server_id: |
| 187 | try: |
| 188 | cls.servers_client.delete_server(server_id) |
| 189 | cls.servers_client.wait_for_server_termination(server_id) |
| 190 | except Exception as exc: |
| 191 | LOG.exception(exc) |
| 192 | pass |
Ken'ichi Ohmichi | cfc052e | 2013-10-23 11:50:04 +0900 | [diff] [blame] | 193 | resp, server = cls.create_test_server(wait_until='ACTIVE', **kwargs) |
ivan-zhu | 8f992be | 2013-07-31 14:56:58 +0800 | [diff] [blame] | 194 | cls.password = server['adminPass'] |
Matthew Treinish | 2cd19a4 | 2013-12-02 21:54:42 +0000 | [diff] [blame] | 195 | return server['id'] |
ivan-zhu | 8f992be | 2013-07-31 14:56:58 +0800 | [diff] [blame] | 196 | |
ivan-zhu | f2b0050 | 2013-10-18 10:06:52 +0800 | [diff] [blame] | 197 | |
| 198 | class BaseV2ComputeAdminTest(BaseV2ComputeTest): |
| 199 | """Base test case class for Compute Admin V2 API tests.""" |
| 200 | |
| 201 | @classmethod |
| 202 | def setUpClass(cls): |
| 203 | super(BaseV2ComputeAdminTest, cls).setUpClass() |
Attila Fazekas | 4ba3658 | 2013-02-12 08:26:17 +0100 | [diff] [blame] | 204 | admin_username = cls.config.compute_admin.username |
| 205 | admin_password = cls.config.compute_admin.password |
| 206 | admin_tenant = cls.config.compute_admin.tenant_name |
Attila Fazekas | 4ba3658 | 2013-02-12 08:26:17 +0100 | [diff] [blame] | 207 | if not (admin_username and admin_password and admin_tenant): |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 208 | msg = ("Missing Compute Admin API credentials " |
| 209 | "in configuration.") |
ivan-zhu | 1feeb38 | 2013-01-24 10:14:39 +0800 | [diff] [blame] | 210 | raise cls.skipException(msg) |
Attila Fazekas | 430dae3 | 2013-10-17 15:19:32 +0200 | [diff] [blame] | 211 | if (cls.config.compute.allow_tenant_isolation or |
| 212 | cls.force_tenant_isolation is True): |
Matthew Treinish | b86cda9 | 2013-07-29 11:22:23 -0400 | [diff] [blame] | 213 | creds = cls.isolated_creds.get_admin_creds() |
Matthew Treinish | 47ff791 | 2013-07-22 17:09:55 -0400 | [diff] [blame] | 214 | admin_username, admin_tenant_name, admin_password = creds |
| 215 | cls.os_adm = clients.Manager(username=admin_username, |
| 216 | password=admin_password, |
| 217 | tenant_name=admin_tenant_name, |
| 218 | interface=cls._interface) |
| 219 | else: |
| 220 | cls.os_adm = clients.ComputeAdminManager(interface=cls._interface) |
ivan-zhu | 8f992be | 2013-07-31 14:56:58 +0800 | [diff] [blame] | 221 | |
| 222 | |
| 223 | class BaseV3ComputeTest(BaseComputeTest): |
| 224 | |
| 225 | @classmethod |
| 226 | def setUpClass(cls): |
| 227 | super(BaseV3ComputeTest, cls).setUpClass() |
| 228 | if not cls.config.compute_feature_enabled.api_v3: |
armando-migliaccio | 3e2a028 | 2013-11-22 14:47:16 -0800 | [diff] [blame] | 229 | cls.tearDownClass() |
ivan-zhu | 8f992be | 2013-07-31 14:56:58 +0800 | [diff] [blame] | 230 | skip_msg = ("%s skipped as nova v3 api is not available" % |
| 231 | cls.__name__) |
| 232 | raise cls.skipException(skip_msg) |
| 233 | |
| 234 | cls.servers_client = cls.os.servers_v3_client |
| 235 | cls.images_client = cls.os.image_client |
ivan-zhu | 5c86ae6 | 2013-08-20 21:09:01 +0800 | [diff] [blame] | 236 | cls.services_client = cls.os.services_v3_client |
ivan-zhu | 31d9848 | 2013-08-22 10:51:48 +0800 | [diff] [blame] | 237 | cls.extensions_client = cls.os.extensions_v3_client |
ivan-zhu | ac7b380 | 2013-08-21 16:03:53 +0800 | [diff] [blame] | 238 | cls.availability_zone_client = cls.os.availability_zone_v3_client |
ivan-zhu | 91feab9 | 2013-08-15 18:25:33 +0800 | [diff] [blame] | 239 | cls.interfaces_client = cls.os.interfaces_v3_client |
ivan-zhu | 6f5f9e9 | 2013-08-21 22:16:37 +0800 | [diff] [blame] | 240 | cls.hypervisor_client = cls.os.hypervisor_v3_client |
ivan-zhu | bec84a3 | 2013-08-21 15:32:05 +0800 | [diff] [blame] | 241 | cls.tenant_usages_client = cls.os.tenant_usages_v3_client |
ivan-zhu | 8f992be | 2013-07-31 14:56:58 +0800 | [diff] [blame] | 242 | |
| 243 | @classmethod |
| 244 | def create_image_from_server(cls, server_id, **kwargs): |
| 245 | """Wrapper utility that returns an image created from the server.""" |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 246 | name = data_utils.rand_name(cls.__name__ + "-image") |
ivan-zhu | 8f992be | 2013-07-31 14:56:58 +0800 | [diff] [blame] | 247 | if 'name' in kwargs: |
| 248 | name = kwargs.pop('name') |
| 249 | |
| 250 | resp, image = cls.servers_client.create_image( |
| 251 | server_id, name) |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 252 | image_id = data_utils.parse_image_id(resp['location']) |
ivan-zhu | 8f992be | 2013-07-31 14:56:58 +0800 | [diff] [blame] | 253 | cls.images.append(image_id) |
| 254 | |
| 255 | if 'wait_until' in kwargs: |
| 256 | cls.images_client.wait_for_image_status(image_id, |
| 257 | kwargs['wait_until']) |
| 258 | resp, image = cls.images_client.get_image_meta(image_id) |
| 259 | |
| 260 | return resp, image |
| 261 | |
| 262 | @classmethod |
Matthew Treinish | 2cd19a4 | 2013-12-02 21:54:42 +0000 | [diff] [blame] | 263 | def rebuild_server(cls, server_id, **kwargs): |
ivan-zhu | 8f992be | 2013-07-31 14:56:58 +0800 | [diff] [blame] | 264 | # Destroy an existing server and creates a new one |
| 265 | try: |
Matthew Treinish | 2cd19a4 | 2013-12-02 21:54:42 +0000 | [diff] [blame] | 266 | cls.servers_client.delete_server(server_id) |
| 267 | cls.servers_client.wait_for_server_termination(server_id) |
ivan-zhu | 8f992be | 2013-07-31 14:56:58 +0800 | [diff] [blame] | 268 | except Exception as exc: |
| 269 | LOG.exception(exc) |
| 270 | pass |
Ken'ichi Ohmichi | cfc052e | 2013-10-23 11:50:04 +0900 | [diff] [blame] | 271 | resp, server = cls.create_test_server(wait_until='ACTIVE', **kwargs) |
Ken'ichi Ohmichi | e985ca8 | 2013-11-12 15:10:35 +0900 | [diff] [blame] | 272 | cls.password = server['admin_password'] |
Matthew Treinish | 2cd19a4 | 2013-12-02 21:54:42 +0000 | [diff] [blame] | 273 | return server['id'] |
ivan-zhu | 8f992be | 2013-07-31 14:56:58 +0800 | [diff] [blame] | 274 | |
| 275 | |
| 276 | class BaseV3ComputeAdminTest(BaseV3ComputeTest): |
| 277 | """Base test case class for all Compute Admin API V3 tests.""" |
| 278 | |
| 279 | @classmethod |
| 280 | def setUpClass(cls): |
| 281 | super(BaseV3ComputeAdminTest, cls).setUpClass() |
| 282 | admin_username = cls.config.compute_admin.username |
| 283 | admin_password = cls.config.compute_admin.password |
| 284 | admin_tenant = cls.config.compute_admin.tenant_name |
| 285 | if not (admin_username and admin_password and admin_tenant): |
| 286 | msg = ("Missing Compute Admin API credentials " |
| 287 | "in configuration.") |
| 288 | raise cls.skipException(msg) |
| 289 | if cls.config.compute.allow_tenant_isolation: |
| 290 | creds = cls.isolated_creds.get_admin_creds() |
| 291 | admin_username, admin_tenant_name, admin_password = creds |
| 292 | os_adm = clients.Manager(username=admin_username, |
| 293 | password=admin_password, |
| 294 | tenant_name=admin_tenant_name, |
| 295 | interface=cls._interface) |
| 296 | else: |
| 297 | os_adm = clients.ComputeAdminManager(interface=cls._interface) |
| 298 | |
| 299 | cls.os_adm = os_adm |
| 300 | cls.severs_admin_client = cls.os_adm.servers_v3_client |
ivan-zhu | 5c86ae6 | 2013-08-20 21:09:01 +0800 | [diff] [blame] | 301 | cls.services_admin_client = cls.os_adm.services_v3_client |
ivan-zhu | ac7b380 | 2013-08-21 16:03:53 +0800 | [diff] [blame] | 302 | cls.availability_zone_admin_client = \ |
| 303 | cls.os_adm.availability_zone_v3_client |
ivan-zhu | 6f5f9e9 | 2013-08-21 22:16:37 +0800 | [diff] [blame] | 304 | cls.hypervisor_admin_client = cls.os_adm.hypervisor_v3_client |
ivan-zhu | bec84a3 | 2013-08-21 15:32:05 +0800 | [diff] [blame] | 305 | cls.tenant_usages_admin_client = cls.os_adm.tenant_usages_v3_client |