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 | |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 16 | from tempest import config |
Andrea Frittoli (andreaf) | 2395014 | 2016-06-13 12:39:29 +0100 | [diff] [blame] | 17 | from tempest.lib import auth |
Andrea Frittoli (andreaf) | de5fb0c | 2016-06-13 12:15:00 +0100 | [diff] [blame] | 18 | from tempest.lib import exceptions as lib_exc |
Andrea Frittoli (andreaf) | e07579c | 2016-08-05 07:27:02 +0100 | [diff] [blame] | 19 | from tempest.lib.services import clients |
Vincent Hou | 6b8a7b7 | 2012-08-25 01:24:33 +0800 | [diff] [blame] | 20 | |
Sean Dague | 86bd842 | 2013-12-20 09:56:44 -0500 | [diff] [blame] | 21 | CONF = config.CONF |
Jay Pipes | 3f981df | 2012-03-27 18:59:44 -0400 | [diff] [blame] | 22 | |
Vincent Hou | 6b8a7b7 | 2012-08-25 01:24:33 +0800 | [diff] [blame] | 23 | |
Andrea Frittoli (andreaf) | e07579c | 2016-08-05 07:27:02 +0100 | [diff] [blame] | 24 | class Manager(clients.ServiceClients): |
Ken'ichi Ohmichi | 2e2ee19 | 2015-11-19 09:48:27 +0000 | [diff] [blame] | 25 | """Top level manager for OpenStack tempest clients""" |
Jay Pipes | 3f981df | 2012-03-27 18:59:44 -0400 | [diff] [blame] | 26 | |
Jordan Pittier | e4be907 | 2017-01-04 19:17:35 +0100 | [diff] [blame] | 27 | def __init__(self, credentials, scope='project'): |
ghanshyam | 4e2be34 | 2015-11-27 18:07:46 +0900 | [diff] [blame] | 28 | """Initialization of Manager class. |
Brant Knudson | c7ca334 | 2013-03-28 21:08:50 -0500 | [diff] [blame] | 29 | |
ghanshyam | 4e2be34 | 2015-11-27 18:07:46 +0900 | [diff] [blame] | 30 | Setup all services clients and make them available for tests cases. |
| 31 | :param credentials: type Credentials or TestResources |
Andrea Frittoli (andreaf) | 3e82af7 | 2016-05-05 22:53:38 +0100 | [diff] [blame] | 32 | :param scope: default scope for tokens produced by the auth provider |
ghanshyam | 4e2be34 | 2015-11-27 18:07:46 +0900 | [diff] [blame] | 33 | """ |
Andrea Frittoli (andreaf) | 2395014 | 2016-06-13 12:39:29 +0100 | [diff] [blame] | 34 | _, identity_uri = get_auth_provider_class(credentials) |
| 35 | super(Manager, self).__init__( |
| 36 | credentials=credentials, identity_uri=identity_uri, scope=scope, |
Andrea Frittoli | 7ae56bb | 2017-05-24 10:56:46 +0100 | [diff] [blame] | 37 | region=CONF.identity.region) |
Andrea Frittoli (andreaf) | de5fb0c | 2016-06-13 12:15:00 +0100 | [diff] [blame] | 38 | # TODO(andreaf) When clients are initialised without the right |
| 39 | # parameters available, the calls below will trigger a KeyError. |
| 40 | # We should catch that and raise a better error. |
Ken'ichi Ohmichi | 80ec0b9 | 2015-01-16 06:43:10 +0000 | [diff] [blame] | 41 | self._set_compute_clients() |
| 42 | self._set_identity_clients() |
| 43 | self._set_volume_clients() |
Ken'ichi Ohmichi | c95eb85 | 2015-01-22 01:57:57 +0000 | [diff] [blame] | 44 | self._set_object_storage_clients() |
Andrea Frittoli (andreaf) | 591e854 | 2016-06-07 18:31:39 +0100 | [diff] [blame] | 45 | self._set_image_clients() |
Andrea Frittoli (andreaf) | 11e1e88 | 2016-06-07 18:35:58 +0100 | [diff] [blame] | 46 | self._set_network_clients() |
Andrea Frittoli | f082079 | 2017-08-16 13:02:20 +0100 | [diff] [blame] | 47 | # TODO(andreaf) This is maintained for backward compatibility |
| 48 | # with plugins, but it should removed eventually, since it was |
| 49 | # never a stable interface and it's not useful anyways |
| 50 | self.default_params = config.service_client_config() |
Ken'ichi Ohmichi | cd4a51e | 2014-11-13 07:25:33 +0000 | [diff] [blame] | 51 | |
Andrea Frittoli (andreaf) | 11e1e88 | 2016-06-07 18:35:58 +0100 | [diff] [blame] | 52 | def _set_network_clients(self): |
Andrea Frittoli (andreaf) | 127c102 | 2016-07-05 23:19:50 +0100 | [diff] [blame] | 53 | self.network_agents_client = self.network.AgentsClient() |
| 54 | self.network_extensions_client = self.network.ExtensionsClient() |
| 55 | self.networks_client = self.network.NetworksClient() |
| 56 | self.subnetpools_client = self.network.SubnetpoolsClient() |
| 57 | self.subnets_client = self.network.SubnetsClient() |
| 58 | self.ports_client = self.network.PortsClient() |
| 59 | self.network_quotas_client = self.network.QuotasClient() |
| 60 | self.floating_ips_client = self.network.FloatingIPsClient() |
| 61 | self.metering_labels_client = self.network.MeteringLabelsClient() |
| 62 | self.metering_label_rules_client = ( |
| 63 | self.network.MeteringLabelRulesClient()) |
| 64 | self.routers_client = self.network.RoutersClient() |
| 65 | self.security_group_rules_client = ( |
| 66 | self.network.SecurityGroupRulesClient()) |
| 67 | self.security_groups_client = self.network.SecurityGroupsClient() |
| 68 | self.network_versions_client = self.network.NetworkVersionsClient() |
Jordan Pittier | e579463 | 2016-07-21 17:34:32 +0200 | [diff] [blame] | 69 | self.service_providers_client = self.network.ServiceProvidersClient() |
Felipe Monteiro | 1177942 | 2017-05-18 06:10:26 +0100 | [diff] [blame] | 70 | self.tags_client = self.network.TagsClient() |
Andrea Frittoli (andreaf) | 11e1e88 | 2016-06-07 18:35:58 +0100 | [diff] [blame] | 71 | |
Andrea Frittoli (andreaf) | 591e854 | 2016-06-07 18:31:39 +0100 | [diff] [blame] | 72 | def _set_image_clients(self): |
Andrea Frittoli (andreaf) | 591e854 | 2016-06-07 18:31:39 +0100 | [diff] [blame] | 73 | if CONF.service_available.glance: |
Andrea Frittoli (andreaf) | e6a9b3f | 2016-06-30 16:24:32 +0100 | [diff] [blame] | 74 | self.image_client = self.image_v1.ImagesClient() |
| 75 | self.image_member_client = self.image_v1.ImageMembersClient() |
| 76 | self.image_client_v2 = self.image_v2.ImagesClient() |
| 77 | self.image_member_client_v2 = self.image_v2.ImageMembersClient() |
| 78 | self.namespaces_client = self.image_v2.NamespacesClient() |
| 79 | self.resource_types_client = self.image_v2.ResourceTypesClient() |
Li Wei | 37aff3c | 2016-10-20 19:50:02 +0800 | [diff] [blame] | 80 | self.namespace_objects_client = \ |
| 81 | self.image_v2.NamespaceObjectsClient() |
Andrea Frittoli (andreaf) | e6a9b3f | 2016-06-30 16:24:32 +0100 | [diff] [blame] | 82 | self.schemas_client = self.image_v2.SchemasClient() |
guo yunxian | 753e90a | 2016-11-17 20:12:22 +0800 | [diff] [blame] | 83 | self.namespace_properties_client = \ |
| 84 | self.image_v2.NamespacePropertiesClient() |
guo yunxian | 4f67d82 | 2016-11-29 11:12:58 +0800 | [diff] [blame] | 85 | self.namespace_tags_client = \ |
| 86 | self.image_v2.NamespaceTagsClient() |
Ken'ichi Ohmichi | f72343e | 2017-03-10 12:53:14 -0800 | [diff] [blame] | 87 | self.image_versions_client = \ |
| 88 | self.image_v2.VersionsClient() |
Andrea Frittoli (andreaf) | 591e854 | 2016-06-07 18:31:39 +0100 | [diff] [blame] | 89 | |
Ken'ichi Ohmichi | 80ec0b9 | 2015-01-16 06:43:10 +0000 | [diff] [blame] | 90 | def _set_compute_clients(self): |
Andrea Frittoli (andreaf) | 142d819 | 2016-07-05 23:19:05 +0100 | [diff] [blame] | 91 | self.agents_client = self.compute.AgentsClient() |
| 92 | self.compute_networks_client = self.compute.NetworksClient() |
| 93 | self.migrations_client = self.compute.MigrationsClient() |
Ken'ichi Ohmichi | 65225ef | 2014-11-19 01:06:25 +0000 | [diff] [blame] | 94 | self.security_group_default_rules_client = ( |
Andrea Frittoli (andreaf) | 142d819 | 2016-07-05 23:19:05 +0100 | [diff] [blame] | 95 | self.compute.SecurityGroupDefaultRulesClient()) |
| 96 | self.certificates_client = self.compute.CertificatesClient() |
| 97 | eip = CONF.compute_feature_enabled.enable_instance_password |
| 98 | self.servers_client = self.compute.ServersClient( |
| 99 | enable_instance_password=eip) |
| 100 | self.server_groups_client = self.compute.ServerGroupsClient() |
| 101 | self.limits_client = self.compute.LimitsClient() |
| 102 | self.compute_images_client = self.compute.ImagesClient() |
| 103 | self.keypairs_client = self.compute.KeyPairsClient() |
| 104 | self.quotas_client = self.compute.QuotasClient() |
| 105 | self.quota_classes_client = self.compute.QuotaClassesClient() |
| 106 | self.flavors_client = self.compute.FlavorsClient() |
| 107 | self.extensions_client = self.compute.ExtensionsClient() |
| 108 | self.floating_ip_pools_client = self.compute.FloatingIPPoolsClient() |
| 109 | self.floating_ips_bulk_client = self.compute.FloatingIPsBulkClient() |
| 110 | self.compute_floating_ips_client = self.compute.FloatingIPsClient() |
Andrea Frittoli (andreaf) | 76a4b4e | 2016-06-14 23:28:16 +0100 | [diff] [blame] | 111 | self.compute_security_group_rules_client = ( |
Andrea Frittoli (andreaf) | 142d819 | 2016-07-05 23:19:05 +0100 | [diff] [blame] | 112 | self.compute.SecurityGroupRulesClient()) |
| 113 | self.compute_security_groups_client = ( |
| 114 | self.compute.SecurityGroupsClient()) |
| 115 | self.interfaces_client = self.compute.InterfacesClient() |
| 116 | self.fixed_ips_client = self.compute.FixedIPsClient() |
| 117 | self.availability_zone_client = self.compute.AvailabilityZoneClient() |
| 118 | self.aggregates_client = self.compute.AggregatesClient() |
| 119 | self.services_client = self.compute.ServicesClient() |
| 120 | self.tenant_usages_client = self.compute.TenantUsagesClient() |
| 121 | self.hosts_client = self.compute.HostsClient() |
| 122 | self.hypervisor_client = self.compute.HypervisorClient() |
Andrea Frittoli (andreaf) | 76a4b4e | 2016-06-14 23:28:16 +0100 | [diff] [blame] | 123 | self.instance_usages_audit_log_client = ( |
Andrea Frittoli (andreaf) | 142d819 | 2016-07-05 23:19:05 +0100 | [diff] [blame] | 124 | self.compute.InstanceUsagesAuditLogClient()) |
| 125 | self.tenant_networks_client = self.compute.TenantNetworksClient() |
Ken'ichi Ohmichi | 4771cbc | 2015-01-19 23:45:23 +0000 | [diff] [blame] | 126 | |
| 127 | # NOTE: The following client needs special timeout values because |
| 128 | # the API is a proxy for the other component. |
Andrea Frittoli | 2032257 | 2017-04-09 19:13:13 +0200 | [diff] [blame] | 129 | params_volume = { |
| 130 | 'build_interval': CONF.volume.build_interval, |
| 131 | 'build_timeout': CONF.volume.build_timeout |
| 132 | } |
Andrea Frittoli (andreaf) | 142d819 | 2016-07-05 23:19:05 +0100 | [diff] [blame] | 133 | self.volumes_extensions_client = self.compute.VolumesClient( |
| 134 | **params_volume) |
| 135 | self.compute_versions_client = self.compute.VersionsClient( |
| 136 | **params_volume) |
| 137 | self.snapshots_extensions_client = self.compute.SnapshotsClient( |
| 138 | **params_volume) |
Ken'ichi Ohmichi | cd4a51e | 2014-11-13 07:25:33 +0000 | [diff] [blame] | 139 | |
Ken'ichi Ohmichi | 80ec0b9 | 2015-01-16 06:43:10 +0000 | [diff] [blame] | 140 | def _set_identity_clients(self): |
Yaroslav Lobankov | cd97fea | 2016-01-13 19:59:52 +0300 | [diff] [blame] | 141 | # Clients below use the admin endpoint type of Keystone API v2 |
ghanshyam | 68227d6 | 2016-12-22 16:17:42 +0900 | [diff] [blame] | 142 | params_v2_admin = { |
| 143 | 'endpoint_type': CONF.identity.v2_admin_endpoint_type} |
| 144 | self.endpoints_client = self.identity_v2.EndpointsClient( |
| 145 | **params_v2_admin) |
| 146 | self.identity_client = self.identity_v2.IdentityClient( |
| 147 | **params_v2_admin) |
| 148 | self.tenants_client = self.identity_v2.TenantsClient( |
| 149 | **params_v2_admin) |
| 150 | self.roles_client = self.identity_v2.RolesClient(**params_v2_admin) |
| 151 | self.users_client = self.identity_v2.UsersClient(**params_v2_admin) |
| 152 | self.identity_services_client = self.identity_v2.ServicesClient( |
| 153 | **params_v2_admin) |
Yaroslav Lobankov | cd97fea | 2016-01-13 19:59:52 +0300 | [diff] [blame] | 154 | |
| 155 | # Clients below use the public endpoint type of Keystone API v2 |
ghanshyam | 68227d6 | 2016-12-22 16:17:42 +0900 | [diff] [blame] | 156 | params_v2_public = { |
| 157 | 'endpoint_type': CONF.identity.v2_public_endpoint_type} |
| 158 | self.identity_public_client = self.identity_v2.IdentityClient( |
| 159 | **params_v2_public) |
| 160 | self.tenants_public_client = self.identity_v2.TenantsClient( |
| 161 | **params_v2_public) |
| 162 | self.users_public_client = self.identity_v2.UsersClient( |
| 163 | **params_v2_public) |
Yaroslav Lobankov | cd97fea | 2016-01-13 19:59:52 +0300 | [diff] [blame] | 164 | |
Andrea Frittoli (andreaf) | de5fb0c | 2016-06-13 12:15:00 +0100 | [diff] [blame] | 165 | # Clients below use the endpoint type of Keystone API v3, which is set |
| 166 | # in endpoint_type |
ghanshyam | 68227d6 | 2016-12-22 16:17:42 +0900 | [diff] [blame] | 167 | params_v3 = {'endpoint_type': CONF.identity.v3_endpoint_type} |
| 168 | self.domains_client = self.identity_v3.DomainsClient(**params_v3) |
| 169 | self.identity_v3_client = self.identity_v3.IdentityClient(**params_v3) |
| 170 | self.trusts_client = self.identity_v3.TrustsClient(**params_v3) |
| 171 | self.users_v3_client = self.identity_v3.UsersClient(**params_v3) |
| 172 | self.endpoints_v3_client = self.identity_v3.EndPointsClient( |
| 173 | **params_v3) |
| 174 | self.roles_v3_client = self.identity_v3.RolesClient(**params_v3) |
| 175 | self.inherited_roles_client = self.identity_v3.InheritedRolesClient( |
| 176 | **params_v3) |
| 177 | self.role_assignments_client = self.identity_v3.RoleAssignmentsClient( |
| 178 | **params_v3) |
| 179 | self.identity_services_v3_client = self.identity_v3.ServicesClient( |
| 180 | **params_v3) |
| 181 | self.policies_client = self.identity_v3.PoliciesClient(**params_v3) |
| 182 | self.projects_client = self.identity_v3.ProjectsClient(**params_v3) |
| 183 | self.regions_client = self.identity_v3.RegionsClient(**params_v3) |
| 184 | self.credentials_client = self.identity_v3.CredentialsClient( |
| 185 | **params_v3) |
| 186 | self.groups_client = self.identity_v3.GroupsClient(**params_v3) |
Ken'ichi Ohmichi | da26b16 | 2017-03-03 15:53:46 -0800 | [diff] [blame] | 187 | self.identity_versions_v3_client = self.identity_v3.VersionsClient( |
| 188 | **params_v3) |
Nicolas Helgeson | 8e2d403 | 2017-02-14 09:36:37 -0800 | [diff] [blame] | 189 | self.oauth_consumers_client = self.identity_v3.OAUTHConsumerClient( |
| 190 | **params_v3) |
Hemanth Nakkina | d9594f5 | 2017-04-19 11:14:40 +0530 | [diff] [blame] | 191 | self.oauth_token_client = self.identity_v3.OAUTHTokenClient( |
| 192 | **params_v3) |
Felipe Monteiro | 94d8577 | 2017-04-03 22:04:06 +0100 | [diff] [blame] | 193 | self.domain_config_client = self.identity_v3.DomainConfigurationClient( |
| 194 | **params_v3) |
Pradeep Kumar KS | 5d52d3a | 2017-03-18 11:41:15 +0530 | [diff] [blame] | 195 | self.endpoint_filter_client = \ |
| 196 | self.identity_v3.EndPointsFilterClient(**params_v3) |
Chi Lo | d0ed8b0 | 2017-04-22 05:35:53 -0500 | [diff] [blame] | 197 | self.endpoint_groups_client = self.identity_v3.EndPointGroupsClient( |
| 198 | **params_v3) |
Megan Guiney | d029516 | 2017-05-23 23:57:53 -0700 | [diff] [blame] | 199 | self.catalog_client = self.identity_v3.CatalogClient(**params_v3) |
Felipe Monteiro | a3b2d8e | 2018-03-15 04:47:52 +0000 | [diff] [blame] | 200 | self.project_tags_client = self.identity_v3.ProjectTagsClient( |
| 201 | **params_v3) |
Colleen Murphy | 0e52d4e | 2018-02-17 21:29:40 +0100 | [diff] [blame] | 202 | self.application_credentials_client = \ |
| 203 | self.identity_v3.ApplicationCredentialsClient(**params_v3) |
Yaroslav Lobankov | cd97fea | 2016-01-13 19:59:52 +0300 | [diff] [blame] | 204 | |
Andrea Frittoli | 9001235 | 2015-02-25 21:58:02 +0000 | [diff] [blame] | 205 | # 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] | 206 | # They read auth_url, so they should only be set if the corresponding |
| 207 | # API version is marked as enabled |
| 208 | if CONF.identity_feature_enabled.api_v2: |
| 209 | if CONF.identity.uri: |
Andrea Frittoli | 8b8db53 | 2016-12-22 11:21:47 +0000 | [diff] [blame] | 210 | self.token_client = self.identity_v2.TokenClient( |
| 211 | auth_url=CONF.identity.uri) |
Andrea Frittoli (andreaf) | 03e546f | 2015-05-13 12:44:47 +0100 | [diff] [blame] | 212 | else: |
| 213 | msg = 'Identity v2 API enabled, but no identity.uri set' |
Matthew Treinish | 4217a70 | 2016-10-07 17:27:11 -0400 | [diff] [blame] | 214 | raise lib_exc.InvalidConfiguration(msg) |
Ken'ichi Ohmichi | 41951b0 | 2014-11-19 01:57:43 +0000 | [diff] [blame] | 215 | if CONF.identity_feature_enabled.api_v3: |
Andrea Frittoli (andreaf) | 03e546f | 2015-05-13 12:44:47 +0100 | [diff] [blame] | 216 | if CONF.identity.uri_v3: |
Andrea Frittoli | 8b8db53 | 2016-12-22 11:21:47 +0000 | [diff] [blame] | 217 | self.token_v3_client = self.identity_v3.V3TokenClient( |
| 218 | auth_url=CONF.identity.uri_v3) |
Andrea Frittoli (andreaf) | 03e546f | 2015-05-13 12:44:47 +0100 | [diff] [blame] | 219 | else: |
| 220 | msg = 'Identity v3 API enabled, but no identity.uri_v3 set' |
Matthew Treinish | 4217a70 | 2016-10-07 17:27:11 -0400 | [diff] [blame] | 221 | raise lib_exc.InvalidConfiguration(msg) |
Ken'ichi Ohmichi | 41951b0 | 2014-11-19 01:57:43 +0000 | [diff] [blame] | 222 | |
Ken'ichi Ohmichi | 80ec0b9 | 2015-01-16 06:43:10 +0000 | [diff] [blame] | 223 | def _set_volume_clients(self): |
Ken'ichi Ohmichi | f85e9bd | 2015-01-27 12:51:47 +0000 | [diff] [blame] | 224 | |
Sean McGinnis | ff5f0c1 | 2017-07-07 16:39:24 -0500 | [diff] [blame] | 225 | if CONF.volume_feature_enabled.api_v1: |
| 226 | self.backups_client = self.volume_v1.BackupsClient() |
| 227 | self.encryption_types_client = \ |
| 228 | self.volume_v1.EncryptionTypesClient() |
| 229 | self.snapshots_client = self.volume_v1.SnapshotsClient() |
| 230 | self.volume_availability_zone_client = \ |
| 231 | self.volume_v1.AvailabilityZoneClient() |
| 232 | self.volume_hosts_client = self.volume_v1.HostsClient() |
| 233 | self.volume_limits_client = self.volume_v1.LimitsClient() |
| 234 | self.volume_qos_client = self.volume_v1.QosSpecsClient() |
| 235 | self.volume_quotas_client = self.volume_v1.QuotasClient() |
| 236 | self.volume_services_client = self.volume_v1.ServicesClient() |
| 237 | self.volume_types_client = self.volume_v1.TypesClient() |
| 238 | self.volumes_client = self.volume_v1.VolumesClient() |
| 239 | self.volumes_extension_client = self.volume_v1.ExtensionsClient() |
| 240 | |
zhufl | 15292a3 | 2018-01-02 15:18:39 +0800 | [diff] [blame] | 241 | # if only api_v3 is enabled, all these clients should be available |
| 242 | if (CONF.volume_feature_enabled.api_v2 or |
| 243 | CONF.volume_feature_enabled.api_v3): |
Sean McGinnis | ff5f0c1 | 2017-07-07 16:39:24 -0500 | [diff] [blame] | 244 | self.backups_v2_client = self.volume_v2.BackupsClient() |
| 245 | self.encryption_types_v2_client = \ |
| 246 | self.volume_v2.EncryptionTypesClient() |
| 247 | self.snapshot_manage_v2_client = \ |
| 248 | self.volume_v2.SnapshotManageClient() |
| 249 | self.snapshots_v2_client = self.volume_v2.SnapshotsClient() |
| 250 | self.volume_capabilities_v2_client = \ |
| 251 | self.volume_v2.CapabilitiesClient() |
| 252 | self.volume_manage_v2_client = self.volume_v2.VolumeManageClient() |
| 253 | self.volume_qos_v2_client = self.volume_v2.QosSpecsClient() |
| 254 | self.volume_services_v2_client = self.volume_v2.ServicesClient() |
| 255 | self.volume_types_v2_client = self.volume_v2.TypesClient() |
| 256 | self.volume_hosts_v2_client = self.volume_v2.HostsClient() |
| 257 | self.volume_quotas_v2_client = self.volume_v2.QuotasClient() |
| 258 | self.volume_quota_classes_v2_client = \ |
| 259 | self.volume_v2.QuotaClassesClient() |
| 260 | self.volume_scheduler_stats_v2_client = \ |
| 261 | self.volume_v2.SchedulerStatsClient() |
| 262 | self.volume_transfers_v2_client = \ |
| 263 | self.volume_v2.TransfersClient() |
| 264 | self.volume_v2_availability_zone_client = \ |
| 265 | self.volume_v2.AvailabilityZoneClient() |
| 266 | self.volume_v2_limits_client = self.volume_v2.LimitsClient() |
| 267 | self.volumes_v2_client = self.volume_v2.VolumesClient() |
| 268 | self.volumes_v2_extension_client = \ |
| 269 | self.volume_v2.ExtensionsClient() |
| 270 | |
| 271 | # Set default client for users that don't need explicit version |
| 272 | self.volumes_client_latest = self.volumes_v2_client |
Andrea Frittoli | a6b3015 | 2017-08-04 10:46:10 +0100 | [diff] [blame] | 273 | self.snapshots_client_latest = self.snapshots_v2_client |
lkuchlan | e20e6a8 | 2018-05-08 11:28:46 +0300 | [diff] [blame] | 274 | self.backups_client_latest = self.backups_v2_client |
Sean McGinnis | ff5f0c1 | 2017-07-07 16:39:24 -0500 | [diff] [blame] | 275 | |
| 276 | if CONF.volume_feature_enabled.api_v3: |
| 277 | self.backups_v3_client = self.volume_v3.BackupsClient() |
| 278 | self.group_types_v3_client = self.volume_v3.GroupTypesClient() |
| 279 | self.groups_v3_client = self.volume_v3.GroupsClient() |
xing-yang | 41ed715 | 2017-05-03 06:52:56 -0400 | [diff] [blame] | 280 | self.group_snapshots_v3_client = \ |
| 281 | self.volume_v3.GroupSnapshotsClient() |
| 282 | self.snapshots_v3_client = self.volume_v3.SnapshotsClient() |
Sean McGinnis | ff5f0c1 | 2017-07-07 16:39:24 -0500 | [diff] [blame] | 283 | self.volume_v3_messages_client = self.volume_v3.MessagesClient() |
| 284 | self.volume_v3_versions_client = self.volume_v3.VersionsClient() |
| 285 | self.volumes_v3_client = self.volume_v3.VolumesClient() |
| 286 | |
| 287 | # Set default client for users that don't need explicit version |
| 288 | self.volumes_client_latest = self.volumes_v3_client |
Andrea Frittoli | a6b3015 | 2017-08-04 10:46:10 +0100 | [diff] [blame] | 289 | self.snapshots_client_latest = self.snapshots_v3_client |
lkuchlan | e20e6a8 | 2018-05-08 11:28:46 +0300 | [diff] [blame] | 290 | self.backups_client_latest = self.backups_v3_client |
Ken'ichi Ohmichi | 532ae92 | 2014-11-19 01:37:15 +0000 | [diff] [blame] | 291 | |
Ken'ichi Ohmichi | c95eb85 | 2015-01-22 01:57:57 +0000 | [diff] [blame] | 292 | def _set_object_storage_clients(self): |
Andrea Frittoli | 986407d | 2017-10-11 10:23:17 +0000 | [diff] [blame] | 293 | self.account_client = self.object_storage.AccountClient() |
| 294 | self.bulk_client = self.object_storage.BulkMiddlewareClient() |
| 295 | self.capabilities_client = self.object_storage.CapabilitiesClient() |
| 296 | self.container_client = self.object_storage.ContainerClient() |
| 297 | self.object_client = self.object_storage.ObjectClient() |
Andrea Frittoli (andreaf) | 2395014 | 2016-06-13 12:39:29 +0100 | [diff] [blame] | 298 | |
| 299 | |
| 300 | def get_auth_provider_class(credentials): |
| 301 | if isinstance(credentials, auth.KeystoneV3Credentials): |
| 302 | return auth.KeystoneV3AuthProvider, CONF.identity.uri_v3 |
| 303 | else: |
| 304 | return auth.KeystoneV2AuthProvider, CONF.identity.uri |
| 305 | |
| 306 | |
| 307 | def get_auth_provider(credentials, pre_auth=False, scope='project'): |
Andrea Frittoli (andreaf) | de5fb0c | 2016-06-13 12:15:00 +0100 | [diff] [blame] | 308 | # kwargs for auth provider match the common ones used by service clients |
| 309 | default_params = config.service_client_config() |
Andrea Frittoli (andreaf) | 2395014 | 2016-06-13 12:39:29 +0100 | [diff] [blame] | 310 | if credentials is None: |
guo yunxian | 654a921 | 2016-11-02 17:26:42 +0800 | [diff] [blame] | 311 | raise lib_exc.InvalidCredentials( |
Andrea Frittoli (andreaf) | 2395014 | 2016-06-13 12:39:29 +0100 | [diff] [blame] | 312 | 'Credentials must be specified') |
| 313 | auth_provider_class, auth_url = get_auth_provider_class( |
| 314 | credentials) |
| 315 | _auth_provider = auth_provider_class(credentials, auth_url, |
| 316 | scope=scope, |
| 317 | **default_params) |
| 318 | if pre_auth: |
| 319 | _auth_provider.set_auth() |
| 320 | return _auth_provider |