blob: 7f899141871edb2091f57547dd47981448e0d67a [file] [log] [blame]
ZhiQiang Fan39f97222013-09-20 04:49:44 +08001# Copyright 2012 OpenStack Foundation
Jay Pipes3f981df2012-03-27 18:59:44 -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
Ken'ichi Ohmichi4771cbc2015-01-19 23:45:23 +000016import copy
17
Doug Hellmann583ce2c2015-03-11 14:55:46 +000018from oslo_log import log as logging
Ken'ichi Ohmichi8e7a4f82015-09-16 21:26:19 +090019from tempest_lib.services.compute.agents_client import AgentsClient
ghanshyamd1dac392015-10-13 15:30:24 +090020from tempest_lib.services.compute.aggregates_client import AggregatesClient
ghanshyam384dc792015-10-13 16:03:13 +090021from tempest_lib.services.compute.availability_zone_client import \
22 AvailabilityZoneClient
ghanshyam9fab7cc2015-10-13 16:12:23 +090023from tempest_lib.services.compute.baremetal_nodes_client import \
24 BaremetalNodesClient
ghanshyam4328a962015-10-13 16:18:09 +090025from tempest_lib.services.compute.certificates_client import \
26 CertificatesClient
ghanshyam0805a9e2015-10-13 16:24:44 +090027from tempest_lib.services.compute.extensions_client import \
28 ExtensionsClient
ghanshyam969281e2015-10-14 14:17:57 +090029from tempest_lib.services.compute.fixed_ips_client import FixedIPsClient
ghanshyam2f6f5f12015-10-14 14:27:36 +090030from tempest_lib.services.compute.flavors_client import FlavorsClient
ghanshyambf9e6002015-10-14 14:32:30 +090031from tempest_lib.services.compute.floating_ip_pools_client import \
32 FloatingIPPoolsClient
ghanshyam1a286ab2015-10-14 14:37:07 +090033from tempest_lib.services.compute.floating_ips_bulk_client import \
34 FloatingIPsBulkClient
Ghanshyam9d53dc22015-12-21 11:48:12 +090035from tempest_lib.services.compute.floating_ips_client import \
36 FloatingIPsClient as ComputeFloatingIPsClient
ghanshyamc898a282015-10-14 14:44:06 +090037from tempest_lib.services.compute.hosts_client import HostsClient
ghanshyam7dd1b492015-10-14 14:47:25 +090038from tempest_lib.services.compute.hypervisor_client import \
39 HypervisorClient
Ken'ichi Ohmichi69dcf442015-11-30 11:48:01 +000040from tempest_lib.services.compute.images_client import ImagesClient \
41 as ComputeImagesClient
ghanshyame6ee3e42015-11-20 18:20:57 +090042from tempest_lib.services.compute.instance_usage_audit_log_client import \
43 InstanceUsagesAuditLogClient
Ken'ichi Ohmichic3f22ce2015-12-03 05:21:37 +000044from tempest_lib.services.compute.interfaces_client import InterfacesClient
ghanshyam54e55cc2015-11-20 18:26:15 +090045from tempest_lib.services.compute.limits_client import LimitsClient
ghanshyameb6e2212015-11-20 18:30:46 +090046from tempest_lib.services.compute.migrations_client import MigrationsClient
ghanshyam6ca351a2015-11-20 18:35:30 +090047from tempest_lib.services.compute.networks_client import NetworksClient \
48 as ComputeNetworksClient
ghanshyam1a6acef2015-11-24 13:37:33 +090049from tempest_lib.services.compute.quota_classes_client import \
50 QuotaClassesClient
ghanshyam2f0b2f92015-11-24 13:45:10 +090051from tempest_lib.services.compute.quotas_client import QuotasClient
ghanshyama478b512015-11-24 13:52:31 +090052from tempest_lib.services.compute.security_group_default_rules_client import \
53 SecurityGroupDefaultRulesClient
Ghanshyam3d067522015-12-21 12:13:49 +090054from tempest_lib.services.compute.security_group_rules_client import \
John Warren5cdbf422016-01-05 12:42:43 -050055 SecurityGroupRulesClient as ComputeSecurityGroupRulesClient
ghanshyam94ef6492015-11-25 16:43:26 +090056from tempest_lib.services.compute.security_groups_client import \
John Warrenf2345512015-12-10 13:39:30 -050057 SecurityGroupsClient as ComputeSecurityGroupsClient
Ghanshyam47d5f402015-12-21 12:59:04 +090058from tempest_lib.services.compute.server_groups_client import \
59 ServerGroupsClient
Ghanshyam4cc30d92015-12-21 14:17:59 +090060from tempest_lib.services.compute.servers_client import ServersClient
ghanshyamef23f222015-11-25 16:50:09 +090061from tempest_lib.services.compute.services_client import ServicesClient
ghanshyamef4ca252015-11-25 16:55:55 +090062from tempest_lib.services.compute.snapshots_client import \
63 SnapshotsClient as ComputeSnapshotsClient
ghanshyam06acc8e2015-11-25 17:06:52 +090064from tempest_lib.services.compute.tenant_networks_client import \
65 TenantNetworksClient
ghanshyama1f71702015-11-25 17:11:59 +090066from tempest_lib.services.compute.tenant_usages_client import \
67 TenantUsagesClient
ghanshyam30753462015-11-25 17:58:07 +090068from tempest_lib.services.compute.versions_client import VersionsClient
ghanshyam692d7c92015-11-25 21:16:52 +090069from tempest_lib.services.compute.volumes_client import \
70 VolumesClient as ComputeVolumesClient
Ken'ichi Ohmichi5f80ce32015-09-10 23:51:14 +000071from tempest_lib.services.identity.v2.token_client import TokenClient
72from tempest_lib.services.identity.v3.token_client import V3TokenClient
Ken'ichi Ohmichiea3c2212016-01-04 04:35:49 +000073from tempest_lib.services.network.floating_ips_client import FloatingIPsClient
Ken'ichi Ohmichi5a319512016-01-12 23:58:47 +000074from tempest_lib.services.network.metering_label_rules_client import \
75 MeteringLabelRulesClient
76from tempest_lib.services.network.metering_labels_client import \
77 MeteringLabelsClient
78from tempest_lib.services.network.networks_client import NetworksClient
79from tempest_lib.services.network.ports_client import PortsClient
80from tempest_lib.services.network.subnets_client import SubnetsClient
Doug Hellmann583ce2c2015-03-11 14:55:46 +000081
Ken'ichi Ohmichi42662682015-01-05 05:00:04 +000082from tempest.common import negative_rest_client
Jay Pipesf38eaac2012-06-21 13:37:35 -040083from tempest import config
Andrea Frittoli (andreaf)03e546f2015-05-13 12:44:47 +010084from tempest import exceptions
Andrea Frittolif9cde7e2014-02-18 09:57:04 +000085from tempest import manager
Ken'ichi Ohmichi884d1062015-01-23 03:24:41 +000086from tempest.services.baremetal.v1.json.baremetal_client import \
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +000087 BaremetalClient
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +000088from tempest.services.compute.json.keypairs_client import KeyPairsClient
Ken'ichi Ohmichidc5fe442015-02-13 04:00:47 +000089from tempest.services.data_processing.v1_1.data_processing_client import \
90 DataProcessingClient
Nikhil Manchandadd6886f2014-03-03 01:58:45 -080091from tempest.services.database.json.flavors_client import \
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +000092 DatabaseFlavorsClient
ravikumar-venkatesan9e81b442014-12-08 09:57:56 +000093from tempest.services.database.json.limits_client import \
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +000094 DatabaseLimitsClient
Peter Stachowski320f9c72014-04-21 16:13:23 -040095from tempest.services.database.json.versions_client import \
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +000096 DatabaseVersionsClient
Jamie Lennoxc429e6a2015-02-24 10:42:42 +110097from tempest.services.identity.v2.json.identity_client import \
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +000098 IdentityClient
Daniel Mellado6b16b922015-12-07 12:43:08 +000099from tempest.services.identity.v2.json.roles_client import \
100 RolesClient
Daniel Mellado72f24ec2015-12-21 10:26:42 +0000101from tempest.services.identity.v2.json.services_client import \
102 ServicesClient as ServicesV2Client
Daniel Melladob04da902015-11-20 17:43:12 +0100103from tempest.services.identity.v2.json.tenants_client import \
104 TenantsClient
Daniel Mellado82c83a52015-12-09 15:16:49 +0000105from tempest.services.identity.v2.json.users_client import \
106 UsersClient
nayna-patel914b4712013-07-16 08:29:05 +0000107from tempest.services.identity.v3.json.credentials_client import \
Yaroslav Lobankov425ea1e2015-11-20 12:28:39 +0300108 CredentialsClient as CredentialsV3Client
Sean Dague2416cf32013-04-10 08:29:07 -0400109from tempest.services.identity.v3.json.endpoints_client import \
Yaroslav Lobankov425ea1e2015-11-20 12:28:39 +0300110 EndPointClient as EndPointV3Client
111from tempest.services.identity.v3.json.groups_client import \
112 GroupsClient as GroupsV3Client
113from tempest.services.identity.v3.json.identity_client import IdentityV3Client
Yaroslav Lobankoved4d15c2015-12-18 11:30:10 +0300114from tempest.services.identity.v3.json.policies_client import \
115 PoliciesClient as PoliciesV3Client
Yaroslav Lobankov757d1a22015-12-18 11:43:02 +0300116from tempest.services.identity.v3.json.regions_client import \
117 RegionsClient as RegionsV3Client
Yaroslav Lobankov69d90562015-12-18 12:06:40 +0300118from tempest.services.identity.v3.json.services_client import \
119 ServicesClient as IdentityServicesV3Client
Ken'ichi Ohmichi69dcf442015-11-30 11:48:01 +0000120from tempest.services.image.v1.json.images_client import ImagesClient
121from tempest.services.image.v2.json.images_client import ImagesClientV2
Victoria Martínez de la Cruz1173b6e2014-09-22 18:32:13 -0300122from tempest.services.messaging.json.messaging_client import \
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000123 MessagingClient
Ken'ichi Ohmichi71860062015-12-15 08:20:13 +0000124from tempest.services.network.json.agents_client import AgentsClient \
125 as NetworkAgentsClient
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000126from tempest.services.network.json.network_client import NetworkClient
Ken'ichi Ohmichi756d8ff2015-12-15 09:47:54 +0000127from tempest.services.network.json.quotas_client import QuotasClient \
128 as NetworkQuotasClient
John Warren456d9ae2016-01-12 15:36:33 -0500129from tempest.services.network.json.security_group_rules_client import \
130 SecurityGroupRulesClient
John Warrenf9606e92015-12-10 12:12:42 -0500131from tempest.services.network.json.security_groups_client import \
132 SecurityGroupsClient
Ken'ichi Ohmichif3f8aba2015-12-15 08:11:00 +0000133from tempest.services.network.json.subnetpools_client import SubnetpoolsClient
dwalleck5d734432012-10-04 01:11:47 -0500134from tempest.services.object_storage.account_client import AccountClient
Attila Fazekas6968dd52013-02-15 17:05:53 +0100135from tempest.services.object_storage.container_client import ContainerClient
136from tempest.services.object_storage.object_client import ObjectClient
Steve Bakerc60e4e32013-05-06 15:22:41 +1200137from tempest.services.orchestration.json.orchestration_client import \
138 OrchestrationClient
liu-sheng67b730e2015-07-16 15:19:33 +0800139from tempest.services.telemetry.json.alarming_client import AlarmingClient
Nikolay Pliashechnikovb053aab2013-11-05 06:06:44 -0800140from tempest.services.telemetry.json.telemetry_client import \
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000141 TelemetryClient
Yaroslav Lobankovaef02982015-12-02 17:42:32 +0300142from tempest.services.volume.v1.json.admin.hosts_client import \
Yaroslav Lobankov4c237792015-12-02 18:43:48 +0300143 HostsClient as VolumeHostsClient
Yaroslav Lobankovaef02982015-12-02 17:42:32 +0300144from tempest.services.volume.v1.json.admin.quotas_client import \
Yaroslav Lobankov4c237792015-12-02 18:43:48 +0300145 QuotasClient as VolumeQuotasClient
Yaroslav Lobankovaef02982015-12-02 17:42:32 +0300146from tempest.services.volume.v1.json.admin.services_client import \
Yaroslav Lobankov4c237792015-12-02 18:43:48 +0300147 ServicesClient as VolumeServicesClient
Yaroslav Lobankovaef02982015-12-02 17:42:32 +0300148from tempest.services.volume.v1.json.admin.types_client import \
Yaroslav Lobankov4c237792015-12-02 18:43:48 +0300149 TypesClient as VolumeTypesClient
Yaroslav Lobankovdb4a2e12015-11-28 20:04:54 +0300150from tempest.services.volume.v1.json.availability_zone_client import \
Yaroslav Lobankov4c237792015-12-02 18:43:48 +0300151 AvailabilityZoneClient as VolumeAvailabilityZoneClient
Yaroslav Lobankovdb4a2e12015-11-28 20:04:54 +0300152from tempest.services.volume.v1.json.backups_client import BackupsClient
153from tempest.services.volume.v1.json.extensions_client import \
Yaroslav Lobankov4c237792015-12-02 18:43:48 +0300154 ExtensionsClient as VolumeExtensionsClient
Yaroslav Lobankovdb4a2e12015-11-28 20:04:54 +0300155from tempest.services.volume.v1.json.qos_client import QosSpecsClient
156from tempest.services.volume.v1.json.snapshots_client import SnapshotsClient
157from tempest.services.volume.v1.json.volumes_client import VolumesClient
Yaroslav Lobankovaef02982015-12-02 17:42:32 +0300158from tempest.services.volume.v2.json.admin.hosts_client import \
Yaroslav Lobankov4c237792015-12-02 18:43:48 +0300159 HostsClient as VolumeHostsV2Client
Yaroslav Lobankovaef02982015-12-02 17:42:32 +0300160from tempest.services.volume.v2.json.admin.quotas_client import \
Yaroslav Lobankov4c237792015-12-02 18:43:48 +0300161 QuotasClient as VolumeQuotasV2Client
Yaroslav Lobankovaef02982015-12-02 17:42:32 +0300162from tempest.services.volume.v2.json.admin.services_client import \
Yaroslav Lobankov4c237792015-12-02 18:43:48 +0300163 ServicesClient as VolumeServicesV2Client
Yaroslav Lobankovaef02982015-12-02 17:42:32 +0300164from tempest.services.volume.v2.json.admin.types_client import \
Yaroslav Lobankov4c237792015-12-02 18:43:48 +0300165 TypesClient as VolumeTypesV2Client
Zhi Kun Liu53395522014-07-18 16:05:52 +0800166from tempest.services.volume.v2.json.availability_zone_client import \
Yaroslav Lobankov4c237792015-12-02 18:43:48 +0300167 AvailabilityZoneClient as VolumeAvailabilityZoneV2Client
168from tempest.services.volume.v2.json.backups_client import \
169 BackupsClient as BackupsV2Client
Zhi Kun Liu53395522014-07-18 16:05:52 +0800170from tempest.services.volume.v2.json.extensions_client import \
Yaroslav Lobankov4c237792015-12-02 18:43:48 +0300171 ExtensionsClient as VolumeExtensionsV2Client
172from tempest.services.volume.v2.json.qos_client import \
173 QosSpecsClient as QosSpecsV2Client
Zhi Kun Liu38641c62014-07-10 20:12:48 +0800174from tempest.services.volume.v2.json.snapshots_client import \
Yaroslav Lobankov4c237792015-12-02 18:43:48 +0300175 SnapshotsClient as SnapshotsV2Client
176from tempest.services.volume.v2.json.volumes_client import \
177 VolumesClient as VolumesV2Client
Vincent Hou6b8a7b72012-08-25 01:24:33 +0800178
Sean Dague86bd8422013-12-20 09:56:44 -0500179CONF = config.CONF
Jay Pipes3f981df2012-03-27 18:59:44 -0400180LOG = logging.getLogger(__name__)
181
Vincent Hou6b8a7b72012-08-25 01:24:33 +0800182
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000183class Manager(manager.Manager):
Ken'ichi Ohmichi2e2ee192015-11-19 09:48:27 +0000184 """Top level manager for OpenStack tempest clients"""
Jay Pipes3f981df2012-03-27 18:59:44 -0400185
Ken'ichi Ohmichic2b11ce2015-01-16 07:17:29 +0000186 default_params = {
187 'disable_ssl_certificate_validation':
188 CONF.identity.disable_ssl_certificate_validation,
189 'ca_certs': CONF.identity.ca_certificates_file,
190 'trace_requests': CONF.debug.trace_requests
191 }
192
Ken'ichi Ohmichi737a6032015-01-21 07:04:42 +0000193 # NOTE: Tempest uses timeout values of compute API if project specific
194 # timeout values don't exist.
195 default_params_with_timeout_values = {
196 'build_interval': CONF.compute.build_interval,
197 'build_timeout': CONF.compute.build_timeout
198 }
199 default_params_with_timeout_values.update(default_params)
200
ghanshyam4e2be342015-11-27 18:07:46 +0900201 def __init__(self, credentials, service=None, api_microversions=None):
202 """Initialization of Manager class.
Brant Knudsonc7ca3342013-03-28 21:08:50 -0500203
ghanshyam4e2be342015-11-27 18:07:46 +0900204 Setup all services clients and make them available for tests cases.
205 :param credentials: type Credentials or TestResources
206 :param service: Service name
207 :param api_microversions: This is dict of services catalog type
208 and their microversion which will be set on respective
209 services clients.
210 {<service catalog type>: request_microversion}
211 Example :
212 {'compute': request_microversion}
213 - request_microversion will be set on all compute
214 service clients.
215 OR
216 {'compute': request_microversion,
217 'volume': request_microversion}
218 - request_microversion of compute will be set on all
219 compute service clients.
220 - request_microversion of volume will be set on all
221 volume service clients.
222 """
223 super(Manager, self).__init__(credentials=credentials)
224 self.api_microversions = api_microversions or {}
Ken'ichi Ohmichi80ec0b92015-01-16 06:43:10 +0000225 self._set_compute_clients()
ravikumar-venkatesan9e81b442014-12-08 09:57:56 +0000226 self._set_database_clients()
Ken'ichi Ohmichi80ec0b92015-01-16 06:43:10 +0000227 self._set_identity_clients()
228 self._set_volume_clients()
Ken'ichi Ohmichic95eb852015-01-22 01:57:57 +0000229 self._set_object_storage_clients()
Ken'ichi Ohmichicd4a51e2014-11-13 07:25:33 +0000230
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000231 self.baremetal_client = BaremetalClient(
Ken'ichi Ohmichi1f88ece2015-01-23 03:33:11 +0000232 self.auth_provider,
233 CONF.baremetal.catalog_type,
234 CONF.identity.region,
235 endpoint_type=CONF.baremetal.endpoint_type,
236 **self.default_params_with_timeout_values)
Ken'ichi Ohmichi71860062015-12-15 08:20:13 +0000237 self.network_agents_client = NetworkAgentsClient(
238 self.auth_provider,
239 CONF.network.catalog_type,
240 CONF.network.region or CONF.identity.region,
241 endpoint_type=CONF.network.endpoint_type,
242 build_interval=CONF.network.build_interval,
243 build_timeout=CONF.network.build_timeout,
244 **self.default_params)
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000245 self.network_client = NetworkClient(
Ken'ichi Ohmichia182e862015-01-21 01:16:37 +0000246 self.auth_provider,
247 CONF.network.catalog_type,
248 CONF.network.region or CONF.identity.region,
249 endpoint_type=CONF.network.endpoint_type,
250 build_interval=CONF.network.build_interval,
251 build_timeout=CONF.network.build_timeout,
252 **self.default_params)
John Warren94d8faf2015-09-15 12:22:24 -0400253 self.networks_client = NetworksClient(
254 self.auth_provider,
255 CONF.network.catalog_type,
256 CONF.network.region or CONF.identity.region,
257 endpoint_type=CONF.network.endpoint_type,
258 build_interval=CONF.network.build_interval,
259 build_timeout=CONF.network.build_timeout,
260 **self.default_params)
Ken'ichi Ohmichif3f8aba2015-12-15 08:11:00 +0000261 self.subnetpools_client = SubnetpoolsClient(
262 self.auth_provider,
263 CONF.network.catalog_type,
264 CONF.network.region or CONF.identity.region,
265 endpoint_type=CONF.network.endpoint_type,
266 build_interval=CONF.network.build_interval,
267 build_timeout=CONF.network.build_timeout,
268 **self.default_params)
John Warren3961acd2015-10-02 14:38:53 -0400269 self.subnets_client = SubnetsClient(
270 self.auth_provider,
271 CONF.network.catalog_type,
272 CONF.network.region or CONF.identity.region,
273 endpoint_type=CONF.network.endpoint_type,
274 build_interval=CONF.network.build_interval,
275 build_timeout=CONF.network.build_timeout,
276 **self.default_params)
John Warren49c0fe52015-10-22 12:35:54 -0400277 self.ports_client = PortsClient(
278 self.auth_provider,
279 CONF.network.catalog_type,
280 CONF.network.region or CONF.identity.region,
281 endpoint_type=CONF.network.endpoint_type,
282 build_interval=CONF.network.build_interval,
283 build_timeout=CONF.network.build_timeout,
284 **self.default_params)
Ken'ichi Ohmichi756d8ff2015-12-15 09:47:54 +0000285 self.network_quotas_client = NetworkQuotasClient(
286 self.auth_provider,
287 CONF.network.catalog_type,
288 CONF.network.region or CONF.identity.region,
289 endpoint_type=CONF.network.endpoint_type,
290 build_interval=CONF.network.build_interval,
291 build_timeout=CONF.network.build_timeout,
292 **self.default_params)
John Warrenfbf2a892015-11-17 12:36:14 -0500293 self.floating_ips_client = FloatingIPsClient(
294 self.auth_provider,
295 CONF.network.catalog_type,
296 CONF.network.region or CONF.identity.region,
297 endpoint_type=CONF.network.endpoint_type,
298 build_interval=CONF.network.build_interval,
299 build_timeout=CONF.network.build_timeout,
300 **self.default_params)
John Warren6d0083a2015-11-30 18:12:30 -0500301 self.metering_labels_client = MeteringLabelsClient(
302 self.auth_provider,
303 CONF.network.catalog_type,
304 CONF.network.region or CONF.identity.region,
305 endpoint_type=CONF.network.endpoint_type,
306 build_interval=CONF.network.build_interval,
307 build_timeout=CONF.network.build_timeout,
308 **self.default_params)
John Warrendd20b3e2015-12-03 13:11:28 -0500309 self.metering_label_rules_client = MeteringLabelRulesClient(
310 self.auth_provider,
311 CONF.network.catalog_type,
312 CONF.network.region or CONF.identity.region,
313 endpoint_type=CONF.network.endpoint_type,
314 build_interval=CONF.network.build_interval,
315 build_timeout=CONF.network.build_timeout,
316 **self.default_params)
John Warren456d9ae2016-01-12 15:36:33 -0500317 self.security_group_rules_client = SecurityGroupRulesClient(
318 self.auth_provider,
319 CONF.network.catalog_type,
320 CONF.network.region or CONF.identity.region,
321 endpoint_type=CONF.network.endpoint_type,
322 build_interval=CONF.network.build_interval,
323 build_timeout=CONF.network.build_timeout,
324 **self.default_params)
John Warrenf9606e92015-12-10 12:12:42 -0500325 self.security_groups_client = SecurityGroupsClient(
326 self.auth_provider,
327 CONF.network.catalog_type,
328 CONF.network.region or CONF.identity.region,
329 endpoint_type=CONF.network.endpoint_type,
330 build_interval=CONF.network.build_interval,
331 build_timeout=CONF.network.build_timeout,
332 **self.default_params)
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000333 self.messaging_client = MessagingClient(
Ken'ichi Ohmichi2183a652015-01-22 05:00:20 +0000334 self.auth_provider,
335 CONF.messaging.catalog_type,
336 CONF.identity.region,
337 **self.default_params_with_timeout_values)
Sean Daguef3c75912014-11-24 11:45:11 -0500338 if CONF.service_available.ceilometer:
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000339 self.telemetry_client = TelemetryClient(
Ken'ichi Ohmichid5dba1c2015-01-23 02:23:22 +0000340 self.auth_provider,
341 CONF.telemetry.catalog_type,
342 CONF.identity.region,
343 endpoint_type=CONF.telemetry.endpoint_type,
344 **self.default_params_with_timeout_values)
liu-sheng67b730e2015-07-16 15:19:33 +0800345 if CONF.service_available.aodh:
346 self.alarming_client = AlarmingClient(
347 self.auth_provider,
348 CONF.alarming.catalog_type,
349 CONF.identity.region,
350 endpoint_type=CONF.alarming.endpoint_type,
351 **self.default_params_with_timeout_values)
Sean Dague86bd8422013-12-20 09:56:44 -0500352 if CONF.service_available.glance:
Ken'ichi Ohmichi69dcf442015-11-30 11:48:01 +0000353 self.image_client = ImagesClient(
Masayuki Igawabc7e1892015-03-03 11:46:48 +0900354 self.auth_provider,
355 CONF.image.catalog_type,
356 CONF.image.region or CONF.identity.region,
357 endpoint_type=CONF.image.endpoint_type,
358 build_interval=CONF.image.build_interval,
359 build_timeout=CONF.image.build_timeout,
360 **self.default_params)
Ken'ichi Ohmichi69dcf442015-11-30 11:48:01 +0000361 self.image_client_v2 = ImagesClientV2(
Masayuki Igawabc7e1892015-03-03 11:46:48 +0900362 self.auth_provider,
363 CONF.image.catalog_type,
364 CONF.image.region or CONF.identity.region,
365 endpoint_type=CONF.image.endpoint_type,
366 build_interval=CONF.image.build_interval,
367 build_timeout=CONF.image.build_timeout,
368 **self.default_params)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000369 self.orchestration_client = OrchestrationClient(
Ken'ichi Ohmichic2b11ce2015-01-16 07:17:29 +0000370 self.auth_provider,
371 CONF.orchestration.catalog_type,
372 CONF.orchestration.region or CONF.identity.region,
373 endpoint_type=CONF.orchestration.endpoint_type,
374 build_interval=CONF.orchestration.build_interval,
375 build_timeout=CONF.orchestration.build_timeout,
376 **self.default_params)
Ken'ichi Ohmichi4e83b5e2015-02-13 04:07:34 +0000377 self.data_processing_client = DataProcessingClient(
378 self.auth_provider,
379 CONF.data_processing.catalog_type,
380 CONF.identity.region,
381 endpoint_type=CONF.data_processing.endpoint_type,
382 **self.default_params_with_timeout_values)
Ken'ichi Ohmichib38eb002015-01-23 02:35:01 +0000383 self.negative_client = negative_rest_client.NegativeRestClient(
David Kranz1e33e372015-03-20 09:42:56 -0400384 self.auth_provider, service, **self.default_params)
Ken'ichi Ohmichic2b11ce2015-01-16 07:17:29 +0000385
ghanshyam4e2be342015-11-27 18:07:46 +0900386 self._set_api_microversions()
387
Ken'ichi Ohmichi80ec0b92015-01-16 06:43:10 +0000388 def _set_compute_clients(self):
Ken'ichi Ohmichi4771cbc2015-01-19 23:45:23 +0000389 params = {
390 'service': CONF.compute.catalog_type,
391 'region': CONF.compute.region or CONF.identity.region,
392 'endpoint_type': CONF.compute.endpoint_type,
393 'build_interval': CONF.compute.build_interval,
394 'build_timeout': CONF.compute.build_timeout
395 }
396 params.update(self.default_params)
397
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000398 self.agents_client = AgentsClient(self.auth_provider, **params)
John Warren9487a182015-09-14 18:12:56 -0400399 self.compute_networks_client = ComputeNetworksClient(
400 self.auth_provider, **params)
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000401 self.migrations_client = MigrationsClient(self.auth_provider,
402 **params)
Ken'ichi Ohmichi65225ef2014-11-19 01:06:25 +0000403 self.security_group_default_rules_client = (
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000404 SecurityGroupDefaultRulesClient(self.auth_provider, **params))
405 self.certificates_client = CertificatesClient(self.auth_provider,
406 **params)
407 self.servers_client = ServersClient(
Masayuki Igawa8f9c0c82015-03-03 09:38:08 +0900408 self.auth_provider,
409 enable_instance_password=CONF.compute_feature_enabled
410 .enable_instance_password,
411 **params)
Ken'ichi Ohmichi7ca54b82015-07-07 01:10:26 +0000412 self.server_groups_client = ServerGroupsClient(
413 self.auth_provider, **params)
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000414 self.limits_client = LimitsClient(self.auth_provider, **params)
Ghanshyamae76c122015-12-22 13:41:35 +0900415 self.compute_images_client = ComputeImagesClient(self.auth_provider,
416 **params)
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000417 self.keypairs_client = KeyPairsClient(self.auth_provider, **params)
418 self.quotas_client = QuotasClient(self.auth_provider, **params)
419 self.quota_classes_client = QuotaClassesClient(self.auth_provider,
420 **params)
421 self.flavors_client = FlavorsClient(self.auth_provider, **params)
422 self.extensions_client = ExtensionsClient(self.auth_provider,
423 **params)
Ken'ichi Ohmichif5767702015-07-29 23:39:10 +0000424 self.floating_ip_pools_client = FloatingIPPoolsClient(
Ken'ichi Ohmichi03af1c52015-07-13 00:28:05 +0000425 self.auth_provider, **params)
Ken'ichi Ohmichif5767702015-07-29 23:39:10 +0000426 self.floating_ips_bulk_client = FloatingIPsBulkClient(
Ken'ichi Ohmichi2b26e752015-07-13 00:44:36 +0000427 self.auth_provider, **params)
John Warrene74890a2015-11-11 15:18:01 -0500428 self.compute_floating_ips_client = ComputeFloatingIPsClient(
429 self.auth_provider, **params)
John Warren5cdbf422016-01-05 12:42:43 -0500430 self.compute_security_group_rules_client = \
431 ComputeSecurityGroupRulesClient(self.auth_provider, **params)
John Warrenf2345512015-12-10 13:39:30 -0500432 self.compute_security_groups_client = ComputeSecurityGroupsClient(
Ken'ichi Ohmichi4771cbc2015-01-19 23:45:23 +0000433 self.auth_provider, **params)
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000434 self.interfaces_client = InterfacesClient(self.auth_provider,
435 **params)
436 self.fixed_ips_client = FixedIPsClient(self.auth_provider,
437 **params)
438 self.availability_zone_client = AvailabilityZoneClient(
Ken'ichi Ohmichi4771cbc2015-01-19 23:45:23 +0000439 self.auth_provider, **params)
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000440 self.aggregates_client = AggregatesClient(self.auth_provider,
441 **params)
442 self.services_client = ServicesClient(self.auth_provider, **params)
443 self.tenant_usages_client = TenantUsagesClient(self.auth_provider,
444 **params)
445 self.hosts_client = HostsClient(self.auth_provider, **params)
446 self.hypervisor_client = HypervisorClient(self.auth_provider,
447 **params)
Ken'ichi Ohmichicd4a51e2014-11-13 07:25:33 +0000448 self.instance_usages_audit_log_client = \
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000449 InstanceUsagesAuditLogClient(self.auth_provider, **params)
Ken'ichi Ohmichic3dfdb22015-01-22 04:39:58 +0000450 self.tenant_networks_client = \
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000451 TenantNetworksClient(self.auth_provider, **params)
452 self.baremetal_nodes_client = BaremetalNodesClient(
YuikoTakadaac0879a2015-01-22 02:40:03 +0000453 self.auth_provider, **params)
Ken'ichi Ohmichi4771cbc2015-01-19 23:45:23 +0000454
455 # NOTE: The following client needs special timeout values because
456 # the API is a proxy for the other component.
457 params_volume = copy.deepcopy(params)
458 params_volume.update({
459 'build_interval': CONF.volume.build_interval,
460 'build_timeout': CONF.volume.build_timeout
461 })
Ken'ichi Ohmichiea3f26a2015-09-29 00:18:39 +0000462 self.volumes_extensions_client = ComputeVolumesClient(
Ken'ichi Ohmichic4921782015-08-05 08:14:42 +0000463 self.auth_provider, **params_volume)
Ken'ichi Ohmichi2b6012b2015-09-03 01:56:19 +0000464 self.compute_versions_client = VersionsClient(self.auth_provider,
465 **params_volume)
Ken'ichi Ohmichib7e27302015-09-29 00:11:20 +0000466 self.snapshots_extensions_client = ComputeSnapshotsClient(
Gaozexub9c9d6e2015-09-10 17:08:04 +0800467 self.auth_provider, **params_volume)
Ken'ichi Ohmichicd4a51e2014-11-13 07:25:33 +0000468
ravikumar-venkatesan9e81b442014-12-08 09:57:56 +0000469 def _set_database_clients(self):
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000470 self.database_flavors_client = DatabaseFlavorsClient(
ravikumar-venkatesan9e81b442014-12-08 09:57:56 +0000471 self.auth_provider,
472 CONF.database.catalog_type,
473 CONF.identity.region,
474 **self.default_params_with_timeout_values)
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000475 self.database_limits_client = DatabaseLimitsClient(
ravikumar-venkatesan9e81b442014-12-08 09:57:56 +0000476 self.auth_provider,
477 CONF.database.catalog_type,
478 CONF.identity.region,
479 **self.default_params_with_timeout_values)
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000480 self.database_versions_client = DatabaseVersionsClient(
ravikumar-venkatesan9e81b442014-12-08 09:57:56 +0000481 self.auth_provider,
482 CONF.database.catalog_type,
483 CONF.identity.region,
484 **self.default_params_with_timeout_values)
485
Ken'ichi Ohmichi80ec0b92015-01-16 06:43:10 +0000486 def _set_identity_clients(self):
ghanshyamd26b5cd2015-02-09 14:48:58 +0900487 params = {
488 'service': CONF.identity.catalog_type,
Jane Zadorozhnac7862132015-07-10 14:34:50 +0300489 'region': CONF.identity.region
ghanshyamd26b5cd2015-02-09 14:48:58 +0900490 }
491 params.update(self.default_params_with_timeout_values)
Jane Zadorozhnac7862132015-07-10 14:34:50 +0300492 params_v2_admin = params.copy()
493 params_v2_admin['endpoint_type'] = CONF.identity.v2_admin_endpoint_type
494 # Client uses admin endpoint type of Keystone API v2
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000495 self.identity_client = IdentityClient(self.auth_provider,
Jane Zadorozhnac7862132015-07-10 14:34:50 +0300496 **params_v2_admin)
Daniel Melladob04da902015-11-20 17:43:12 +0100497 self.tenants_client = TenantsClient(self.auth_provider,
498 **params_v2_admin)
Daniel Mellado6b16b922015-12-07 12:43:08 +0000499 self.roles_client = RolesClient(self.auth_provider,
500 **params_v2_admin)
Daniel Mellado82c83a52015-12-09 15:16:49 +0000501 self.users_client = UsersClient(self.auth_provider,
502 **params_v2_admin)
Daniel Mellado72f24ec2015-12-21 10:26:42 +0000503 self.services_v2_client = ServicesV2Client(self.auth_provider,
504 **params_v2_admin)
Jane Zadorozhnac7862132015-07-10 14:34:50 +0300505 params_v2_public = params.copy()
506 params_v2_public['endpoint_type'] = (
507 CONF.identity.v2_public_endpoint_type)
508 # Client uses public endpoint type of Keystone API v2
509 self.identity_public_client = IdentityClient(self.auth_provider,
510 **params_v2_public)
Daniel Melladob04da902015-11-20 17:43:12 +0100511 self.tenants_public_client = TenantsClient(self.auth_provider,
512 **params_v2_public)
Daniel Mellado6b16b922015-12-07 12:43:08 +0000513 self.roles_public_client = RolesClient(self.auth_provider,
514 **params_v2_public)
Daniel Mellado82c83a52015-12-09 15:16:49 +0000515 self.users_public_client = UsersClient(self.auth_provider,
516 **params_v2_public)
Jane Zadorozhnac7862132015-07-10 14:34:50 +0300517 params_v3 = params.copy()
518 params_v3['endpoint_type'] = CONF.identity.v3_endpoint_type
Yaroslav Lobankov425ea1e2015-11-20 12:28:39 +0300519 # Clients below use the endpoint type of Keystone API v3
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000520 self.identity_v3_client = IdentityV3Client(self.auth_provider,
Jane Zadorozhnac7862132015-07-10 14:34:50 +0300521 **params_v3)
Yaroslav Lobankov425ea1e2015-11-20 12:28:39 +0300522 self.endpoints_client = EndPointV3Client(self.auth_provider,
523 **params_v3)
Yaroslav Lobankov69d90562015-12-18 12:06:40 +0300524 self.identity_services_client = IdentityServicesV3Client(
525 self.auth_provider, **params_v3)
Yaroslav Lobankoved4d15c2015-12-18 11:30:10 +0300526 self.policies_client = PoliciesV3Client(self.auth_provider,
527 **params_v3)
Yaroslav Lobankov757d1a22015-12-18 11:43:02 +0300528 self.regions_client = RegionsV3Client(self.auth_provider, **params_v3)
Yaroslav Lobankov425ea1e2015-11-20 12:28:39 +0300529 self.credentials_client = CredentialsV3Client(self.auth_provider,
530 **params_v3)
531 self.groups_client = GroupsV3Client(self.auth_provider, **params_v3)
Andrea Frittoli90012352015-02-25 21:58:02 +0000532 # Token clients do not use the catalog. They only need default_params.
Andrea Frittoli (andreaf)03e546f2015-05-13 12:44:47 +0100533 # They read auth_url, so they should only be set if the corresponding
534 # API version is marked as enabled
535 if CONF.identity_feature_enabled.api_v2:
536 if CONF.identity.uri:
Ken'ichi Ohmichi5f80ce32015-09-10 23:51:14 +0000537 self.token_client = TokenClient(
Andrea Frittoli (andreaf)03e546f2015-05-13 12:44:47 +0100538 CONF.identity.uri, **self.default_params)
539 else:
540 msg = 'Identity v2 API enabled, but no identity.uri set'
541 raise exceptions.InvalidConfiguration(msg)
Ken'ichi Ohmichi41951b02014-11-19 01:57:43 +0000542 if CONF.identity_feature_enabled.api_v3:
Andrea Frittoli (andreaf)03e546f2015-05-13 12:44:47 +0100543 if CONF.identity.uri_v3:
Ken'ichi Ohmichi5f80ce32015-09-10 23:51:14 +0000544 self.token_v3_client = V3TokenClient(
Andrea Frittoli (andreaf)03e546f2015-05-13 12:44:47 +0100545 CONF.identity.uri_v3, **self.default_params)
546 else:
547 msg = 'Identity v3 API enabled, but no identity.uri_v3 set'
548 raise exceptions.InvalidConfiguration(msg)
Ken'ichi Ohmichi41951b02014-11-19 01:57:43 +0000549
Ken'ichi Ohmichi80ec0b92015-01-16 06:43:10 +0000550 def _set_volume_clients(self):
Ken'ichi Ohmichif85e9bd2015-01-27 12:51:47 +0000551 params = {
552 'service': CONF.volume.catalog_type,
553 'region': CONF.volume.region or CONF.identity.region,
554 'endpoint_type': CONF.volume.endpoint_type,
555 'build_interval': CONF.volume.build_interval,
556 'build_timeout': CONF.volume.build_timeout
557 }
558 params.update(self.default_params)
559
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000560 self.volume_qos_client = QosSpecsClient(self.auth_provider,
561 **params)
562 self.volume_qos_v2_client = QosSpecsV2Client(
Ken'ichi Ohmichif85e9bd2015-01-27 12:51:47 +0000563 self.auth_provider, **params)
Yaroslav Lobankov4c237792015-12-02 18:43:48 +0300564 self.volume_services_client = VolumeServicesClient(
565 self.auth_provider, **params)
566 self.volume_services_v2_client = VolumeServicesV2Client(
Ken'ichi Ohmichif85e9bd2015-01-27 12:51:47 +0000567 self.auth_provider, **params)
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000568 self.backups_client = BackupsClient(self.auth_provider, **params)
Yaroslav Lobankov4c237792015-12-02 18:43:48 +0300569 self.backups_v2_client = BackupsV2Client(self.auth_provider,
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000570 **params)
571 self.snapshots_client = SnapshotsClient(self.auth_provider,
572 **params)
573 self.snapshots_v2_client = SnapshotsV2Client(self.auth_provider,
Ken'ichi Ohmichif85e9bd2015-01-27 12:51:47 +0000574 **params)
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000575 self.volumes_client = VolumesClient(
Ken'ichi Ohmichi234da802015-02-13 04:48:06 +0000576 self.auth_provider, default_volume_size=CONF.volume.volume_size,
577 **params)
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000578 self.volumes_v2_client = VolumesV2Client(
Ken'ichi Ohmichi234da802015-02-13 04:48:06 +0000579 self.auth_provider, default_volume_size=CONF.volume.volume_size,
580 **params)
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000581 self.volume_types_client = VolumeTypesClient(self.auth_provider,
582 **params)
Yaroslav Lobankov4c237792015-12-02 18:43:48 +0300583 self.volume_types_v2_client = VolumeTypesV2Client(
Ken'ichi Ohmichif85e9bd2015-01-27 12:51:47 +0000584 self.auth_provider, **params)
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000585 self.volume_hosts_client = VolumeHostsClient(self.auth_provider,
586 **params)
587 self.volume_hosts_v2_client = VolumeHostsV2Client(
Ken'ichi Ohmichif85e9bd2015-01-27 12:51:47 +0000588 self.auth_provider, **params)
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000589 self.volume_quotas_client = VolumeQuotasClient(self.auth_provider,
590 **params)
Ken'ichi Ohmichif85e9bd2015-01-27 12:51:47 +0000591 self.volume_quotas_v2_client = VolumeQuotasV2Client(self.auth_provider,
592 **params)
Yaroslav Lobankov4c237792015-12-02 18:43:48 +0300593 self.volumes_extension_client = VolumeExtensionsClient(
Ken'ichi Ohmichif85e9bd2015-01-27 12:51:47 +0000594 self.auth_provider, **params)
Yaroslav Lobankov4c237792015-12-02 18:43:48 +0300595 self.volumes_v2_extension_client = VolumeExtensionsV2Client(
Ken'ichi Ohmichif85e9bd2015-01-27 12:51:47 +0000596 self.auth_provider, **params)
Ken'ichi Ohmichi532ae922014-11-19 01:37:15 +0000597 self.volume_availability_zone_client = \
Ken'ichi Ohmichia6287072015-07-02 02:43:15 +0000598 VolumeAvailabilityZoneClient(self.auth_provider, **params)
Ken'ichi Ohmichi532ae922014-11-19 01:37:15 +0000599 self.volume_v2_availability_zone_client = \
Yaroslav Lobankov4c237792015-12-02 18:43:48 +0300600 VolumeAvailabilityZoneV2Client(self.auth_provider, **params)
Ken'ichi Ohmichi532ae922014-11-19 01:37:15 +0000601
Ken'ichi Ohmichic95eb852015-01-22 01:57:57 +0000602 def _set_object_storage_clients(self):
Ken'ichi Ohmichi564b2ad2015-01-22 02:08:59 +0000603 params = {
604 'service': CONF.object_storage.catalog_type,
605 'region': CONF.object_storage.region or CONF.identity.region,
606 'endpoint_type': CONF.object_storage.endpoint_type
607 }
608 params.update(self.default_params_with_timeout_values)
609
610 self.account_client = AccountClient(self.auth_provider, **params)
611 self.container_client = ContainerClient(self.auth_provider, **params)
612 self.object_client = ObjectClient(self.auth_provider, **params)
ghanshyam4e2be342015-11-27 18:07:46 +0900613
614 def _set_api_microversions(self):
615 service_clients = [x for x in self.__dict__ if x.endswith('_client')]
616 for client in service_clients:
617 client_obj = getattr(self, client)
618 microversion = self.api_microversions.get(client_obj.service)
619 if microversion:
620 if hasattr(client_obj, 'set_api_microversion'):
621 client_obj.set_api_microversion(microversion)
622 else:
623 LOG.debug("Need to implement set_api_microversion on %s"
624 % client)