ZhiQiang Fan | 39f9722 | 2013-09-20 04:49:44 +0800 | [diff] [blame] | 1 | # Copyright 2012 OpenStack Foundation |
Jay Pipes | 3f981df | 2012-03-27 18:59:44 -0400 | [diff] [blame] | 2 | # 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 | |
Doug Hellmann | 583ce2c | 2015-03-11 14:55:46 +0000 | [diff] [blame] | 16 | from oslo_log import log as logging |
ChangBo Guo(gcb) | 9f14789 | 2016-09-21 14:01:32 +0800 | [diff] [blame] | 17 | |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 18 | from tempest import config |
Andrea Frittoli (andreaf) | 2395014 | 2016-06-13 12:39:29 +0100 | [diff] [blame] | 19 | from tempest.lib import auth |
Andrea Frittoli (andreaf) | de5fb0c | 2016-06-13 12:15:00 +0100 | [diff] [blame] | 20 | from tempest.lib import exceptions as lib_exc |
Andrea Frittoli (andreaf) | e07579c | 2016-08-05 07:27:02 +0100 | [diff] [blame] | 21 | from tempest.lib.services import clients |
Martin Kopec | 7dcd797 | 2016-12-13 11:04:03 +0900 | [diff] [blame] | 22 | from tempest.lib.services import identity |
Andrea Frittoli (andreaf) | 9a22543 | 2016-06-17 12:16:22 +0100 | [diff] [blame] | 23 | from tempest.services import object_storage |
Andrea Frittoli (andreaf) | c33486f | 2016-06-17 12:22:08 +0100 | [diff] [blame] | 24 | from tempest.services import orchestration |
Vincent Hou | 6b8a7b7 | 2012-08-25 01:24:33 +0800 | [diff] [blame] | 25 | |
Sean Dague | 86bd842 | 2013-12-20 09:56:44 -0500 | [diff] [blame] | 26 | CONF = config.CONF |
Jay Pipes | 3f981df | 2012-03-27 18:59:44 -0400 | [diff] [blame] | 27 | LOG = logging.getLogger(__name__) |
| 28 | |
Vincent Hou | 6b8a7b7 | 2012-08-25 01:24:33 +0800 | [diff] [blame] | 29 | |
Andrea Frittoli (andreaf) | e07579c | 2016-08-05 07:27:02 +0100 | [diff] [blame] | 30 | class Manager(clients.ServiceClients): |
Ken'ichi Ohmichi | 2e2ee19 | 2015-11-19 09:48:27 +0000 | [diff] [blame] | 31 | """Top level manager for OpenStack tempest clients""" |
Jay Pipes | 3f981df | 2012-03-27 18:59:44 -0400 | [diff] [blame] | 32 | |
Andrea Frittoli (andreaf) | de5fb0c | 2016-06-13 12:15:00 +0100 | [diff] [blame] | 33 | default_params = config.service_client_config() |
Ken'ichi Ohmichi | c2b11ce | 2015-01-16 07:17:29 +0000 | [diff] [blame] | 34 | |
Jordan Pittier | d96a3af | 2016-12-19 17:04:25 +0100 | [diff] [blame] | 35 | # TODO(jordanP): remove this once no Tempest plugin use that class |
| 36 | # variable. |
| 37 | default_params_with_timeout_values = { |
| 38 | 'build_interval': CONF.compute.build_interval, |
| 39 | 'build_timeout': CONF.compute.build_timeout |
| 40 | } |
| 41 | default_params_with_timeout_values.update(default_params) |
| 42 | |
Jordan Pittier | e4be907 | 2017-01-04 19:17:35 +0100 | [diff] [blame] | 43 | def __init__(self, credentials, scope='project'): |
ghanshyam | 4e2be34 | 2015-11-27 18:07:46 +0900 | [diff] [blame] | 44 | """Initialization of Manager class. |
Brant Knudson | c7ca334 | 2013-03-28 21:08:50 -0500 | [diff] [blame] | 45 | |
ghanshyam | 4e2be34 | 2015-11-27 18:07:46 +0900 | [diff] [blame] | 46 | Setup all services clients and make them available for tests cases. |
| 47 | :param credentials: type Credentials or TestResources |
Andrea Frittoli (andreaf) | 3e82af7 | 2016-05-05 22:53:38 +0100 | [diff] [blame] | 48 | :param scope: default scope for tokens produced by the auth provider |
ghanshyam | 4e2be34 | 2015-11-27 18:07:46 +0900 | [diff] [blame] | 49 | """ |
Andrea Frittoli (andreaf) | 2395014 | 2016-06-13 12:39:29 +0100 | [diff] [blame] | 50 | _, identity_uri = get_auth_provider_class(credentials) |
| 51 | super(Manager, self).__init__( |
| 52 | credentials=credentials, identity_uri=identity_uri, scope=scope, |
Andrea Frittoli (andreaf) | de5fb0c | 2016-06-13 12:15:00 +0100 | [diff] [blame] | 53 | region=CONF.identity.region, |
| 54 | client_parameters=self._prepare_configuration()) |
| 55 | # TODO(andreaf) When clients are initialised without the right |
| 56 | # parameters available, the calls below will trigger a KeyError. |
| 57 | # We should catch that and raise a better error. |
Ken'ichi Ohmichi | 80ec0b9 | 2015-01-16 06:43:10 +0000 | [diff] [blame] | 58 | self._set_compute_clients() |
| 59 | self._set_identity_clients() |
| 60 | self._set_volume_clients() |
Ken'ichi Ohmichi | c95eb85 | 2015-01-22 01:57:57 +0000 | [diff] [blame] | 61 | self._set_object_storage_clients() |
Andrea Frittoli (andreaf) | 591e854 | 2016-06-07 18:31:39 +0100 | [diff] [blame] | 62 | self._set_image_clients() |
Andrea Frittoli (andreaf) | 11e1e88 | 2016-06-07 18:35:58 +0100 | [diff] [blame] | 63 | self._set_network_clients() |
Ken'ichi Ohmichi | cd4a51e | 2014-11-13 07:25:33 +0000 | [diff] [blame] | 64 | |
Andrea Frittoli (andreaf) | c33486f | 2016-06-17 12:22:08 +0100 | [diff] [blame] | 65 | self.orchestration_client = orchestration.OrchestrationClient( |
Ken'ichi Ohmichi | c2b11ce | 2015-01-16 07:17:29 +0000 | [diff] [blame] | 66 | self.auth_provider, |
| 67 | CONF.orchestration.catalog_type, |
| 68 | CONF.orchestration.region or CONF.identity.region, |
| 69 | endpoint_type=CONF.orchestration.endpoint_type, |
| 70 | build_interval=CONF.orchestration.build_interval, |
| 71 | build_timeout=CONF.orchestration.build_timeout, |
| 72 | **self.default_params) |
| 73 | |
Andrea Frittoli (andreaf) | de5fb0c | 2016-06-13 12:15:00 +0100 | [diff] [blame] | 74 | def _prepare_configuration(self): |
| 75 | """Map values from CONF into Manager parameters |
| 76 | |
| 77 | This uses `config.service_client_config` for all services to collect |
| 78 | most configuration items needed to init the clients. |
| 79 | """ |
Andrea Frittoli (andreaf) | 8420abe | 2016-07-27 11:47:43 +0100 | [diff] [blame] | 80 | # NOTE(andreaf) Once all service clients in Tempest are migrated |
| 81 | # to tempest.lib, their configuration will be picked up from the |
| 82 | # registry, and this method will become redundant. |
Andrea Frittoli (andreaf) | de5fb0c | 2016-06-13 12:15:00 +0100 | [diff] [blame] | 83 | |
| 84 | configuration = {} |
| 85 | |
Andrea Frittoli (andreaf) | 8420abe | 2016-07-27 11:47:43 +0100 | [diff] [blame] | 86 | # Setup the parameters for all Tempest services which are not in lib. |
Andrea Frittoli (andreaf) | de5fb0c | 2016-06-13 12:15:00 +0100 | [diff] [blame] | 87 | # NOTE(andreaf) Since client.py is an internal module of Tempest, |
| 88 | # it doesn't have to consider plugin configuration. |
Andrea Frittoli (andreaf) | 8420abe | 2016-07-27 11:47:43 +0100 | [diff] [blame] | 89 | for service in clients._tempest_internal_modules(): |
Andrea Frittoli (andreaf) | de5fb0c | 2016-06-13 12:15:00 +0100 | [diff] [blame] | 90 | try: |
| 91 | # NOTE(andreaf) Use the unversioned service name to fetch |
| 92 | # the configuration since configuration is not versioned. |
| 93 | service_for_config = service.split('.')[0] |
| 94 | if service_for_config not in configuration: |
| 95 | configuration[service_for_config] = ( |
| 96 | config.service_client_config(service_for_config)) |
| 97 | except lib_exc.UnknownServiceClient: |
Cao Xuan Hoang | 738ffcb | 2016-09-26 15:35:23 +0700 | [diff] [blame] | 98 | LOG.warning( |
Jordan Pittier | 525ec71 | 2016-12-07 17:51:26 +0100 | [diff] [blame] | 99 | 'Could not load configuration for service %s', service) |
Andrea Frittoli (andreaf) | de5fb0c | 2016-06-13 12:15:00 +0100 | [diff] [blame] | 100 | |
| 101 | return configuration |
| 102 | |
Andrea Frittoli (andreaf) | 11e1e88 | 2016-06-07 18:35:58 +0100 | [diff] [blame] | 103 | def _set_network_clients(self): |
Andrea Frittoli (andreaf) | 127c102 | 2016-07-05 23:19:50 +0100 | [diff] [blame] | 104 | self.network_agents_client = self.network.AgentsClient() |
| 105 | self.network_extensions_client = self.network.ExtensionsClient() |
| 106 | self.networks_client = self.network.NetworksClient() |
| 107 | self.subnetpools_client = self.network.SubnetpoolsClient() |
| 108 | self.subnets_client = self.network.SubnetsClient() |
| 109 | self.ports_client = self.network.PortsClient() |
| 110 | self.network_quotas_client = self.network.QuotasClient() |
| 111 | self.floating_ips_client = self.network.FloatingIPsClient() |
| 112 | self.metering_labels_client = self.network.MeteringLabelsClient() |
| 113 | self.metering_label_rules_client = ( |
| 114 | self.network.MeteringLabelRulesClient()) |
| 115 | self.routers_client = self.network.RoutersClient() |
| 116 | self.security_group_rules_client = ( |
| 117 | self.network.SecurityGroupRulesClient()) |
| 118 | self.security_groups_client = self.network.SecurityGroupsClient() |
| 119 | self.network_versions_client = self.network.NetworkVersionsClient() |
Jordan Pittier | e579463 | 2016-07-21 17:34:32 +0200 | [diff] [blame] | 120 | self.service_providers_client = self.network.ServiceProvidersClient() |
Andrea Frittoli (andreaf) | 11e1e88 | 2016-06-07 18:35:58 +0100 | [diff] [blame] | 121 | |
Andrea Frittoli (andreaf) | 591e854 | 2016-06-07 18:31:39 +0100 | [diff] [blame] | 122 | def _set_image_clients(self): |
Andrea Frittoli (andreaf) | 591e854 | 2016-06-07 18:31:39 +0100 | [diff] [blame] | 123 | if CONF.service_available.glance: |
Andrea Frittoli (andreaf) | e6a9b3f | 2016-06-30 16:24:32 +0100 | [diff] [blame] | 124 | self.image_client = self.image_v1.ImagesClient() |
| 125 | self.image_member_client = self.image_v1.ImageMembersClient() |
| 126 | self.image_client_v2 = self.image_v2.ImagesClient() |
| 127 | self.image_member_client_v2 = self.image_v2.ImageMembersClient() |
| 128 | self.namespaces_client = self.image_v2.NamespacesClient() |
| 129 | self.resource_types_client = self.image_v2.ResourceTypesClient() |
Li Wei | 37aff3c | 2016-10-20 19:50:02 +0800 | [diff] [blame] | 130 | self.namespace_objects_client = \ |
| 131 | self.image_v2.NamespaceObjectsClient() |
Andrea Frittoli (andreaf) | e6a9b3f | 2016-06-30 16:24:32 +0100 | [diff] [blame] | 132 | self.schemas_client = self.image_v2.SchemasClient() |
guo yunxian | 753e90a | 2016-11-17 20:12:22 +0800 | [diff] [blame] | 133 | self.namespace_properties_client = \ |
| 134 | self.image_v2.NamespacePropertiesClient() |
Andrea Frittoli (andreaf) | 591e854 | 2016-06-07 18:31:39 +0100 | [diff] [blame] | 135 | |
Ken'ichi Ohmichi | 80ec0b9 | 2015-01-16 06:43:10 +0000 | [diff] [blame] | 136 | def _set_compute_clients(self): |
Andrea Frittoli (andreaf) | 142d819 | 2016-07-05 23:19:05 +0100 | [diff] [blame] | 137 | self.agents_client = self.compute.AgentsClient() |
| 138 | self.compute_networks_client = self.compute.NetworksClient() |
| 139 | self.migrations_client = self.compute.MigrationsClient() |
Ken'ichi Ohmichi | 65225ef | 2014-11-19 01:06:25 +0000 | [diff] [blame] | 140 | self.security_group_default_rules_client = ( |
Andrea Frittoli (andreaf) | 142d819 | 2016-07-05 23:19:05 +0100 | [diff] [blame] | 141 | self.compute.SecurityGroupDefaultRulesClient()) |
| 142 | self.certificates_client = self.compute.CertificatesClient() |
| 143 | eip = CONF.compute_feature_enabled.enable_instance_password |
| 144 | self.servers_client = self.compute.ServersClient( |
| 145 | enable_instance_password=eip) |
| 146 | self.server_groups_client = self.compute.ServerGroupsClient() |
| 147 | self.limits_client = self.compute.LimitsClient() |
| 148 | self.compute_images_client = self.compute.ImagesClient() |
| 149 | self.keypairs_client = self.compute.KeyPairsClient() |
| 150 | self.quotas_client = self.compute.QuotasClient() |
| 151 | self.quota_classes_client = self.compute.QuotaClassesClient() |
| 152 | self.flavors_client = self.compute.FlavorsClient() |
| 153 | self.extensions_client = self.compute.ExtensionsClient() |
| 154 | self.floating_ip_pools_client = self.compute.FloatingIPPoolsClient() |
| 155 | self.floating_ips_bulk_client = self.compute.FloatingIPsBulkClient() |
| 156 | self.compute_floating_ips_client = self.compute.FloatingIPsClient() |
Andrea Frittoli (andreaf) | 76a4b4e | 2016-06-14 23:28:16 +0100 | [diff] [blame] | 157 | self.compute_security_group_rules_client = ( |
Andrea Frittoli (andreaf) | 142d819 | 2016-07-05 23:19:05 +0100 | [diff] [blame] | 158 | self.compute.SecurityGroupRulesClient()) |
| 159 | self.compute_security_groups_client = ( |
| 160 | self.compute.SecurityGroupsClient()) |
| 161 | self.interfaces_client = self.compute.InterfacesClient() |
| 162 | self.fixed_ips_client = self.compute.FixedIPsClient() |
| 163 | self.availability_zone_client = self.compute.AvailabilityZoneClient() |
| 164 | self.aggregates_client = self.compute.AggregatesClient() |
| 165 | self.services_client = self.compute.ServicesClient() |
| 166 | self.tenant_usages_client = self.compute.TenantUsagesClient() |
| 167 | self.hosts_client = self.compute.HostsClient() |
| 168 | self.hypervisor_client = self.compute.HypervisorClient() |
Andrea Frittoli (andreaf) | 76a4b4e | 2016-06-14 23:28:16 +0100 | [diff] [blame] | 169 | self.instance_usages_audit_log_client = ( |
Andrea Frittoli (andreaf) | 142d819 | 2016-07-05 23:19:05 +0100 | [diff] [blame] | 170 | self.compute.InstanceUsagesAuditLogClient()) |
| 171 | self.tenant_networks_client = self.compute.TenantNetworksClient() |
Ken'ichi Ohmichi | 4771cbc | 2015-01-19 23:45:23 +0000 | [diff] [blame] | 172 | |
| 173 | # NOTE: The following client needs special timeout values because |
| 174 | # the API is a proxy for the other component. |
Andrea Frittoli (andreaf) | 142d819 | 2016-07-05 23:19:05 +0100 | [diff] [blame] | 175 | params_volume = {} |
Andrea Frittoli (andreaf) | de5fb0c | 2016-06-13 12:15:00 +0100 | [diff] [blame] | 176 | for _key in ('build_interval', 'build_timeout'): |
| 177 | _value = self.parameters['volume'].get(_key) |
| 178 | if _value: |
| 179 | params_volume[_key] = _value |
Andrea Frittoli (andreaf) | 142d819 | 2016-07-05 23:19:05 +0100 | [diff] [blame] | 180 | self.volumes_extensions_client = self.compute.VolumesClient( |
| 181 | **params_volume) |
| 182 | self.compute_versions_client = self.compute.VersionsClient( |
| 183 | **params_volume) |
| 184 | self.snapshots_extensions_client = self.compute.SnapshotsClient( |
| 185 | **params_volume) |
Ken'ichi Ohmichi | cd4a51e | 2014-11-13 07:25:33 +0000 | [diff] [blame] | 186 | |
Ken'ichi Ohmichi | 80ec0b9 | 2015-01-16 06:43:10 +0000 | [diff] [blame] | 187 | def _set_identity_clients(self): |
Yaroslav Lobankov | cd97fea | 2016-01-13 19:59:52 +0300 | [diff] [blame] | 188 | # Clients below use the admin endpoint type of Keystone API v2 |
ghanshyam | 68227d6 | 2016-12-22 16:17:42 +0900 | [diff] [blame] | 189 | params_v2_admin = { |
| 190 | 'endpoint_type': CONF.identity.v2_admin_endpoint_type} |
| 191 | self.endpoints_client = self.identity_v2.EndpointsClient( |
| 192 | **params_v2_admin) |
| 193 | self.identity_client = self.identity_v2.IdentityClient( |
| 194 | **params_v2_admin) |
| 195 | self.tenants_client = self.identity_v2.TenantsClient( |
| 196 | **params_v2_admin) |
| 197 | self.roles_client = self.identity_v2.RolesClient(**params_v2_admin) |
| 198 | self.users_client = self.identity_v2.UsersClient(**params_v2_admin) |
| 199 | self.identity_services_client = self.identity_v2.ServicesClient( |
| 200 | **params_v2_admin) |
Yaroslav Lobankov | cd97fea | 2016-01-13 19:59:52 +0300 | [diff] [blame] | 201 | |
| 202 | # Clients below use the public endpoint type of Keystone API v2 |
ghanshyam | 68227d6 | 2016-12-22 16:17:42 +0900 | [diff] [blame] | 203 | params_v2_public = { |
| 204 | 'endpoint_type': CONF.identity.v2_public_endpoint_type} |
| 205 | self.identity_public_client = self.identity_v2.IdentityClient( |
| 206 | **params_v2_public) |
| 207 | self.tenants_public_client = self.identity_v2.TenantsClient( |
| 208 | **params_v2_public) |
| 209 | self.users_public_client = self.identity_v2.UsersClient( |
| 210 | **params_v2_public) |
Yaroslav Lobankov | cd97fea | 2016-01-13 19:59:52 +0300 | [diff] [blame] | 211 | |
Andrea Frittoli (andreaf) | de5fb0c | 2016-06-13 12:15:00 +0100 | [diff] [blame] | 212 | # Clients below use the endpoint type of Keystone API v3, which is set |
| 213 | # in endpoint_type |
ghanshyam | 68227d6 | 2016-12-22 16:17:42 +0900 | [diff] [blame] | 214 | params_v3 = {'endpoint_type': CONF.identity.v3_endpoint_type} |
| 215 | self.domains_client = self.identity_v3.DomainsClient(**params_v3) |
| 216 | self.identity_v3_client = self.identity_v3.IdentityClient(**params_v3) |
| 217 | self.trusts_client = self.identity_v3.TrustsClient(**params_v3) |
| 218 | self.users_v3_client = self.identity_v3.UsersClient(**params_v3) |
| 219 | self.endpoints_v3_client = self.identity_v3.EndPointsClient( |
| 220 | **params_v3) |
| 221 | self.roles_v3_client = self.identity_v3.RolesClient(**params_v3) |
| 222 | self.inherited_roles_client = self.identity_v3.InheritedRolesClient( |
| 223 | **params_v3) |
| 224 | self.role_assignments_client = self.identity_v3.RoleAssignmentsClient( |
| 225 | **params_v3) |
| 226 | self.identity_services_v3_client = self.identity_v3.ServicesClient( |
| 227 | **params_v3) |
| 228 | self.policies_client = self.identity_v3.PoliciesClient(**params_v3) |
| 229 | self.projects_client = self.identity_v3.ProjectsClient(**params_v3) |
| 230 | self.regions_client = self.identity_v3.RegionsClient(**params_v3) |
| 231 | self.credentials_client = self.identity_v3.CredentialsClient( |
| 232 | **params_v3) |
| 233 | self.groups_client = self.identity_v3.GroupsClient(**params_v3) |
Yaroslav Lobankov | cd97fea | 2016-01-13 19:59:52 +0300 | [diff] [blame] | 234 | |
Andrea Frittoli | 9001235 | 2015-02-25 21:58:02 +0000 | [diff] [blame] | 235 | # Token clients do not use the catalog. They only need default_params. |
Andrea Frittoli (andreaf) | 03e546f | 2015-05-13 12:44:47 +0100 | [diff] [blame] | 236 | # They read auth_url, so they should only be set if the corresponding |
| 237 | # API version is marked as enabled |
| 238 | if CONF.identity_feature_enabled.api_v2: |
| 239 | if CONF.identity.uri: |
Andrea Frittoli (andreaf) | 6cb6b13 | 2016-06-17 11:39:10 +0100 | [diff] [blame] | 240 | self.token_client = identity.v2.TokenClient( |
Andrea Frittoli (andreaf) | 03e546f | 2015-05-13 12:44:47 +0100 | [diff] [blame] | 241 | CONF.identity.uri, **self.default_params) |
| 242 | else: |
| 243 | msg = 'Identity v2 API enabled, but no identity.uri set' |
Matthew Treinish | 4217a70 | 2016-10-07 17:27:11 -0400 | [diff] [blame] | 244 | raise lib_exc.InvalidConfiguration(msg) |
Ken'ichi Ohmichi | 41951b0 | 2014-11-19 01:57:43 +0000 | [diff] [blame] | 245 | if CONF.identity_feature_enabled.api_v3: |
Andrea Frittoli (andreaf) | 03e546f | 2015-05-13 12:44:47 +0100 | [diff] [blame] | 246 | if CONF.identity.uri_v3: |
Andrea Frittoli (andreaf) | 6cb6b13 | 2016-06-17 11:39:10 +0100 | [diff] [blame] | 247 | self.token_v3_client = identity.v3.V3TokenClient( |
Andrea Frittoli (andreaf) | 03e546f | 2015-05-13 12:44:47 +0100 | [diff] [blame] | 248 | CONF.identity.uri_v3, **self.default_params) |
| 249 | else: |
| 250 | msg = 'Identity v3 API enabled, but no identity.uri_v3 set' |
Matthew Treinish | 4217a70 | 2016-10-07 17:27:11 -0400 | [diff] [blame] | 251 | raise lib_exc.InvalidConfiguration(msg) |
Ken'ichi Ohmichi | 41951b0 | 2014-11-19 01:57:43 +0000 | [diff] [blame] | 252 | |
Ken'ichi Ohmichi | 80ec0b9 | 2015-01-16 06:43:10 +0000 | [diff] [blame] | 253 | def _set_volume_clients(self): |
Ken'ichi Ohmichi | f85e9bd | 2015-01-27 12:51:47 +0000 | [diff] [blame] | 254 | |
lkuchlan | 3fce7fb | 2016-10-31 15:40:35 +0200 | [diff] [blame] | 255 | self.volume_qos_client = self.volume_v1.QosSpecsClient() |
| 256 | self.volume_qos_v2_client = self.volume_v2.QosSpecsClient() |
| 257 | self.volume_services_client = self.volume_v1.ServicesClient() |
| 258 | self.volume_services_v2_client = self.volume_v2.ServicesClient() |
| 259 | self.backups_client = self.volume_v1.BackupsClient() |
| 260 | self.backups_v2_client = self.volume_v2.BackupsClient() |
| 261 | self.encryption_types_client = self.volume_v1.EncryptionTypesClient() |
| 262 | self.encryption_types_v2_client = \ |
| 263 | self.volume_v2.EncryptionTypesClient() |
lkuchlan | cb2f859 | 2016-07-17 15:18:01 +0300 | [diff] [blame] | 264 | self.snapshot_manage_v2_client = self.volume_v2.SnapshotManageClient() |
lkuchlan | 3fce7fb | 2016-10-31 15:40:35 +0200 | [diff] [blame] | 265 | self.snapshots_client = self.volume_v1.SnapshotsClient() |
| 266 | self.snapshots_v2_client = self.volume_v2.SnapshotsClient() |
| 267 | self.volumes_client = self.volume_v1.VolumesClient() |
| 268 | self.volumes_v2_client = self.volume_v2.VolumesClient() |
Benny Kopilov | 37b2bee | 2016-11-06 09:07:19 +0200 | [diff] [blame] | 269 | self.volume_v3_messages_client = self.volume_v3.MessagesClient() |
lkuchlan | 3fce7fb | 2016-10-31 15:40:35 +0200 | [diff] [blame] | 270 | self.volume_types_client = self.volume_v1.TypesClient() |
| 271 | self.volume_types_v2_client = self.volume_v2.TypesClient() |
| 272 | self.volume_hosts_client = self.volume_v1.HostsClient() |
| 273 | self.volume_hosts_v2_client = self.volume_v2.HostsClient() |
| 274 | self.volume_quotas_client = self.volume_v1.QuotasClient() |
| 275 | self.volume_quotas_v2_client = self.volume_v2.QuotasClient() |
| 276 | self.volumes_extension_client = self.volume_v1.ExtensionsClient() |
| 277 | self.volumes_v2_extension_client = self.volume_v2.ExtensionsClient() |
Ken'ichi Ohmichi | 532ae92 | 2014-11-19 01:37:15 +0000 | [diff] [blame] | 278 | self.volume_availability_zone_client = \ |
lkuchlan | 3fce7fb | 2016-10-31 15:40:35 +0200 | [diff] [blame] | 279 | self.volume_v1.AvailabilityZoneClient() |
Ken'ichi Ohmichi | 532ae92 | 2014-11-19 01:37:15 +0000 | [diff] [blame] | 280 | self.volume_v2_availability_zone_client = \ |
lkuchlan | 3fce7fb | 2016-10-31 15:40:35 +0200 | [diff] [blame] | 281 | self.volume_v2.AvailabilityZoneClient() |
bkopilov | 1419308 | 2016-05-31 10:01:28 +0300 | [diff] [blame] | 282 | self.volume_limits_client = self.volume_v1.LimitsClient() |
| 283 | self.volume_v2_limits_client = self.volume_v2.LimitsClient() |
lkuchlan | 7bba16c | 2016-09-04 12:36:04 +0300 | [diff] [blame] | 284 | self.volume_capabilities_v2_client = \ |
| 285 | self.volume_v2.CapabilitiesClient() |
| 286 | self.volume_scheduler_stats_v2_client = \ |
| 287 | self.volume_v2.SchedulerStatsClient() |
Ken'ichi Ohmichi | 532ae92 | 2014-11-19 01:37:15 +0000 | [diff] [blame] | 288 | |
Ken'ichi Ohmichi | c95eb85 | 2015-01-22 01:57:57 +0000 | [diff] [blame] | 289 | def _set_object_storage_clients(self): |
Andrea Frittoli (andreaf) | de5fb0c | 2016-06-13 12:15:00 +0100 | [diff] [blame] | 290 | # Mandatory parameters (always defined) |
| 291 | params = self.parameters['object-storage'] |
Ken'ichi Ohmichi | 564b2ad | 2015-01-22 02:08:59 +0000 | [diff] [blame] | 292 | |
Andrea Frittoli (andreaf) | 9a22543 | 2016-06-17 12:16:22 +0100 | [diff] [blame] | 293 | self.account_client = object_storage.AccountClient(self.auth_provider, |
| 294 | **params) |
ghanshyam | f29831d | 2016-12-12 18:45:23 +0900 | [diff] [blame] | 295 | self.capabilities_client = object_storage.CapabilitiesClient( |
| 296 | self.auth_provider, **params) |
Andrea Frittoli (andreaf) | 9a22543 | 2016-06-17 12:16:22 +0100 | [diff] [blame] | 297 | self.container_client = object_storage.ContainerClient( |
| 298 | self.auth_provider, **params) |
| 299 | self.object_client = object_storage.ObjectClient(self.auth_provider, |
| 300 | **params) |
Andrea Frittoli (andreaf) | 2395014 | 2016-06-13 12:39:29 +0100 | [diff] [blame] | 301 | |
| 302 | |
| 303 | def get_auth_provider_class(credentials): |
| 304 | if isinstance(credentials, auth.KeystoneV3Credentials): |
| 305 | return auth.KeystoneV3AuthProvider, CONF.identity.uri_v3 |
| 306 | else: |
| 307 | return auth.KeystoneV2AuthProvider, CONF.identity.uri |
| 308 | |
| 309 | |
| 310 | def get_auth_provider(credentials, pre_auth=False, scope='project'): |
Andrea Frittoli (andreaf) | de5fb0c | 2016-06-13 12:15:00 +0100 | [diff] [blame] | 311 | # kwargs for auth provider match the common ones used by service clients |
| 312 | default_params = config.service_client_config() |
Andrea Frittoli (andreaf) | 2395014 | 2016-06-13 12:39:29 +0100 | [diff] [blame] | 313 | if credentials is None: |
guo yunxian | 654a921 | 2016-11-02 17:26:42 +0800 | [diff] [blame] | 314 | raise lib_exc.InvalidCredentials( |
Andrea Frittoli (andreaf) | 2395014 | 2016-06-13 12:39:29 +0100 | [diff] [blame] | 315 | 'Credentials must be specified') |
| 316 | auth_provider_class, auth_url = get_auth_provider_class( |
| 317 | credentials) |
| 318 | _auth_provider = auth_provider_class(credentials, auth_url, |
| 319 | scope=scope, |
| 320 | **default_params) |
| 321 | if pre_auth: |
| 322 | _auth_provider.set_auth() |
| 323 | return _auth_provider |