blob: 276b7022028b174250336109890a3e69164e5978 [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
Andrea Frittolif9cde7e2014-02-18 09:57:04 +000016import keystoneclient.exceptions
17import keystoneclient.v2_0.client
Andrea Frittolif9cde7e2014-02-18 09:57:04 +000018
Andrea Frittoli422fbdf2014-03-20 10:05:18 +000019from tempest import auth
Matthew Treinish5c660ab2014-05-18 21:14:36 -040020from tempest.common import rest_client
Jay Pipesf38eaac2012-06-21 13:37:35 -040021from tempest import config
Daryl Walleck587385b2012-03-03 13:00:26 -060022from tempest import exceptions
Andrea Frittolif9cde7e2014-02-18 09:57:04 +000023from tempest import manager
Matthew Treinishf4a9b0f2013-07-26 16:58:26 -040024from tempest.openstack.common import log as logging
Roman Prykhodchenko62b1ed12013-10-16 21:51:47 +030025from tempest.services.baremetal.v1.client_json import BaremetalClientJSON
Attila Fazekas1aed6202013-02-11 14:47:45 +010026from tempest.services import botoclients
Yuiko Takada420f2eb2014-04-02 19:53:38 +090027from tempest.services.compute.json.agents_client import \
28 AgentsClientJSON
Mitsuhiko Yamazaki74f07072013-04-02 11:52:31 +090029from tempest.services.compute.json.aggregates_client import \
30 AggregatesClientJSON
Leo Toyodaa5278912013-04-16 15:40:12 +090031from tempest.services.compute.json.availability_zone_client import \
32 AvailabilityZoneClientJSON
ivan-zhud57f3cf2013-11-06 16:59:52 +080033from tempest.services.compute.json.certificates_client import \
34 CertificatesClientJSON
dwallecke62b9f02012-10-10 23:34:42 -050035from tempest.services.compute.json.extensions_client import \
harika-vakadi1a9ad612012-12-14 19:12:08 +053036 ExtensionsClientJSON
Sean Dague2416cf32013-04-10 08:29:07 -040037from tempest.services.compute.json.fixed_ips_client import FixedIPsClientJSON
dwallecke62b9f02012-10-10 23:34:42 -050038from tempest.services.compute.json.flavors_client import FlavorsClientJSON
39from tempest.services.compute.json.floating_ips_client import \
harika-vakadi1a9ad612012-12-14 19:12:08 +053040 FloatingIPsClientJSON
Attila Fazekas8e99b992013-02-24 09:53:23 +010041from tempest.services.compute.json.hosts_client import HostsClientJSON
Tony Yang3d5f1632013-06-06 14:17:57 +080042from tempest.services.compute.json.hypervisor_client import \
43 HypervisorClientJSON
dwallecke62b9f02012-10-10 23:34:42 -050044from tempest.services.compute.json.images_client import ImagesClientJSON
ivan-zhuef7a1bd2013-10-22 17:56:46 +080045from tempest.services.compute.json.instance_usage_audit_log_client import \
46 InstanceUsagesAuditLogClientJSON
Sean Dague2416cf32013-04-10 08:29:07 -040047from tempest.services.compute.json.interfaces_client import \
48 InterfacesClientJSON
Attila Fazekas6968dd52013-02-15 17:05:53 +010049from tempest.services.compute.json.keypairs_client import KeyPairsClientJSON
dwallecke62b9f02012-10-10 23:34:42 -050050from tempest.services.compute.json.limits_client import LimitsClientJSON
Ken'ichi Ohmichi2fdc1822014-03-18 09:10:57 +090051from tempest.services.compute.json.migrations_client import \
52 MigrationsClientJSON
Matt Riedemann848805f2014-06-16 13:23:51 -070053from tempest.services.compute.json.quotas_client import QuotaClassesClientJSON
Attila Fazekas6968dd52013-02-15 17:05:53 +010054from tempest.services.compute.json.quotas_client import QuotasClientJSON
Matthew Treinisha83a16e2012-12-07 13:44:02 -050055from tempest.services.compute.json.security_groups_client import \
harika-vakadi1a9ad612012-12-14 19:12:08 +053056 SecurityGroupsClientJSON
Attila Fazekas6968dd52013-02-15 17:05:53 +010057from tempest.services.compute.json.servers_client import ServersClientJSON
Leo Toyoda3ae31e12013-04-19 11:19:57 +090058from tempest.services.compute.json.services_client import ServicesClientJSON
Leo Toyodad80b6a02013-05-08 12:15:13 +090059from tempest.services.compute.json.tenant_usages_client import \
60 TenantUsagesClientJSON
Matthew Treinisha83a16e2012-12-07 13:44:02 -050061from tempest.services.compute.json.volumes_extensions_client import \
harika-vakadi1a9ad612012-12-14 19:12:08 +053062 VolumesExtensionsClientJSON
YuikoTakada8a2ec112014-02-18 21:13:51 +000063from tempest.services.compute.v3.json.agents_client import AgentsV3ClientJSON
ivan-zhu00fe64f2013-08-20 19:35:51 +080064from tempest.services.compute.v3.json.aggregates_client import \
65 AggregatesV3ClientJSON
ivan-zhuac7b3802013-08-21 16:03:53 +080066from tempest.services.compute.v3.json.availability_zone_client import \
67 AvailabilityZoneV3ClientJSON
ivan-zhu0e062922013-12-17 16:14:12 +080068from tempest.services.compute.v3.json.certificates_client import \
69 CertificatesV3ClientJSON
ivan-zhu31d98482013-08-22 10:51:48 +080070from tempest.services.compute.v3.json.extensions_client import \
71 ExtensionsV3ClientJSON
ivan-zhub25900a2013-12-13 16:28:45 +080072from tempest.services.compute.v3.json.flavors_client import FlavorsV3ClientJSON
ivan-zhu00fe64f2013-08-20 19:35:51 +080073from tempest.services.compute.v3.json.hosts_client import HostsV3ClientJSON
ivan-zhu6f5f9e92013-08-21 22:16:37 +080074from tempest.services.compute.v3.json.hypervisor_client import \
75 HypervisorV3ClientJSON
ivan-zhu91feab92013-08-15 18:25:33 +080076from tempest.services.compute.v3.json.interfaces_client import \
77 InterfacesV3ClientJSON
ivan-zhu7e7e6a32013-11-20 16:07:29 +080078from tempest.services.compute.v3.json.keypairs_client import \
79 KeyPairsV3ClientJSON
Ken'ichi Ohmichi8f088c12014-03-28 15:16:11 +090080from tempest.services.compute.v3.json.migration_client import \
81 MigrationsV3ClientJSON
ivan-zhub6d69ee2013-12-17 14:16:31 +080082from tempest.services.compute.v3.json.quotas_client import \
83 QuotasV3ClientJSON
ivan-zhu8f992be2013-07-31 14:56:58 +080084from tempest.services.compute.v3.json.servers_client import \
85 ServersV3ClientJSON
ivan-zhu5c86ae62013-08-20 21:09:01 +080086from tempest.services.compute.v3.json.services_client import \
87 ServicesV3ClientJSON
Ken'ichi Ohmichi3d6b6fa2014-01-08 04:42:16 +090088from tempest.services.compute.v3.json.version_client import \
89 VersionV3ClientJSON
Mitsuhiko Yamazakiae8fc532013-04-22 11:17:35 +090090from tempest.services.compute.xml.aggregates_client import AggregatesClientXML
Leo Toyodaa5278912013-04-16 15:40:12 +090091from tempest.services.compute.xml.availability_zone_client import \
92 AvailabilityZoneClientXML
ivan-zhud57f3cf2013-11-06 16:59:52 +080093from tempest.services.compute.xml.certificates_client import \
94 CertificatesClientXML
dwallecke62b9f02012-10-10 23:34:42 -050095from tempest.services.compute.xml.extensions_client import ExtensionsClientXML
Sean Dague2416cf32013-04-10 08:29:07 -040096from tempest.services.compute.xml.fixed_ips_client import FixedIPsClientXML
dwallecke62b9f02012-10-10 23:34:42 -050097from tempest.services.compute.xml.flavors_client import FlavorsClientXML
98from tempest.services.compute.xml.floating_ips_client import \
harika-vakadi1a9ad612012-12-14 19:12:08 +053099 FloatingIPsClientXML
Ken'ichi Ohmichia1aa44c2013-12-06 20:48:24 +0900100from tempest.services.compute.xml.hosts_client import HostsClientXML
Tony Yang3d5f1632013-06-06 14:17:57 +0800101from tempest.services.compute.xml.hypervisor_client import HypervisorClientXML
dwallecke62b9f02012-10-10 23:34:42 -0500102from tempest.services.compute.xml.images_client import ImagesClientXML
ivan-zhuef7a1bd2013-10-22 17:56:46 +0800103from tempest.services.compute.xml.instance_usage_audit_log_client import \
104 InstanceUsagesAuditLogClientXML
Sean Dague2416cf32013-04-10 08:29:07 -0400105from tempest.services.compute.xml.interfaces_client import \
106 InterfacesClientXML
dwallecke62b9f02012-10-10 23:34:42 -0500107from tempest.services.compute.xml.keypairs_client import KeyPairsClientXML
108from tempest.services.compute.xml.limits_client import LimitsClientXML
Matt Riedemann848805f2014-06-16 13:23:51 -0700109from tempest.services.compute.xml.quotas_client import QuotaClassesClientXML
rajalakshmi-ganesan1982c3c2013-01-10 14:56:45 +0530110from tempest.services.compute.xml.quotas_client import QuotasClientXML
dwallecke62b9f02012-10-10 23:34:42 -0500111from tempest.services.compute.xml.security_groups_client \
harika-vakadi1a9ad612012-12-14 19:12:08 +0530112 import SecurityGroupsClientXML
dwallecke62b9f02012-10-10 23:34:42 -0500113from tempest.services.compute.xml.servers_client import ServersClientXML
Leo Toyoda3ae31e12013-04-19 11:19:57 +0900114from tempest.services.compute.xml.services_client import ServicesClientXML
Leo Toyodad80b6a02013-05-08 12:15:13 +0900115from tempest.services.compute.xml.tenant_usages_client import \
116 TenantUsagesClientXML
Matthew Treinisha83a16e2012-12-07 13:44:02 -0500117from tempest.services.compute.xml.volumes_extensions_client import \
harika-vakadi1a9ad612012-12-14 19:12:08 +0530118 VolumesExtensionsClientXML
Sergey Lukjanov3bc60e92013-12-10 16:40:50 +0400119from tempest.services.data_processing.v1_1.client import DataProcessingClient
Nikhil Manchandadd6886f2014-03-03 01:58:45 -0800120from tempest.services.database.json.flavors_client import \
121 DatabaseFlavorsClientJSON
Peter Stachowski320f9c72014-04-21 16:13:23 -0400122from tempest.services.database.json.versions_client import \
123 DatabaseVersionsClientJSON
Attila Fazekas407b6db2013-01-19 12:48:36 +0100124from tempest.services.identity.json.identity_client import IdentityClientJSON
125from tempest.services.identity.json.identity_client import TokenClientJSON
nayna-patel914b4712013-07-16 08:29:05 +0000126from tempest.services.identity.v3.json.credentials_client import \
127 CredentialsClientJSON
Sean Dague2416cf32013-04-10 08:29:07 -0400128from tempest.services.identity.v3.json.endpoints_client import \
129 EndPointClientJSON
rajalakshmi-ganesan7312bb52013-01-29 20:03:42 +0530130from tempest.services.identity.v3.json.identity_client import \
131 IdentityV3ClientJSON
nayna-patelb35f7232013-06-28 07:08:44 +0000132from tempest.services.identity.v3.json.identity_client import V3TokenClientJSON
harika-vakadi40e10112013-02-08 14:38:09 +0530133from tempest.services.identity.v3.json.policy_client import PolicyClientJSON
ravikumar-venkatesan3052e942014-05-12 18:25:17 +0000134from tempest.services.identity.v3.json.region_client import RegionClientJSON
harika-vakadia92dd742013-02-19 20:41:22 +0530135from tempest.services.identity.v3.json.service_client import \
136 ServiceClientJSON
nayna-patel914b4712013-07-16 08:29:05 +0000137from tempest.services.identity.v3.xml.credentials_client import \
138 CredentialsClientXML
rajalakshmi-ganesanab426722013-02-08 15:49:15 +0530139from tempest.services.identity.v3.xml.endpoints_client import EndPointClientXML
rajalakshmi-ganesan7312bb52013-01-29 20:03:42 +0530140from tempest.services.identity.v3.xml.identity_client import \
141 IdentityV3ClientXML
nayna-patelb35f7232013-06-28 07:08:44 +0000142from tempest.services.identity.v3.xml.identity_client import V3TokenClientXML
harika-vakadi40e10112013-02-08 14:38:09 +0530143from tempest.services.identity.v3.xml.policy_client import PolicyClientXML
ravikumar-venkatesan3052e942014-05-12 18:25:17 +0000144from tempest.services.identity.v3.xml.region_client import RegionClientXML
harika-vakadia92dd742013-02-19 20:41:22 +0530145from tempest.services.identity.v3.xml.service_client import \
146 ServiceClientXML
Attila Fazekas407b6db2013-01-19 12:48:36 +0100147from tempest.services.identity.xml.identity_client import IdentityClientXML
148from tempest.services.identity.xml.identity_client import TokenClientXML
Matthew Treinish6d59c992013-03-01 16:20:04 -0500149from tempest.services.image.v1.json.image_client import ImageClientJSON
Matthew Treinisha62347f2013-03-01 16:37:30 -0500150from tempest.services.image.v2.json.image_client import ImageClientV2JSON
raiesmh0867698322013-08-20 13:09:01 +0530151from tempest.services.network.json.network_client import NetworkClientJSON
152from tempest.services.network.xml.network_client import NetworkClientXML
dwalleck5d734432012-10-04 01:11:47 -0500153from tempest.services.object_storage.account_client import AccountClient
harika-vakadi2daed0a2013-01-01 20:51:39 +0530154from tempest.services.object_storage.account_client import \
155 AccountClientCustomizedHeader
Attila Fazekas6968dd52013-02-15 17:05:53 +0100156from tempest.services.object_storage.container_client import ContainerClient
157from tempest.services.object_storage.object_client import ObjectClient
158from tempest.services.object_storage.object_client import \
159 ObjectClientCustomizedHeader
Steve Bakerc60e4e32013-05-06 15:22:41 +1200160from tempest.services.orchestration.json.orchestration_client import \
161 OrchestrationClient
Malini Kamalambal6e7b3b82014-02-06 06:49:04 -0500162from tempest.services.queuing.json.queuing_client import QueuingClientJSON
Nikolay Pliashechnikovb053aab2013-11-05 06:06:44 -0800163from tempest.services.telemetry.json.telemetry_client import \
164 TelemetryClientJSON
165from tempest.services.telemetry.xml.telemetry_client import \
166 TelemetryClientXML
Nayna Patel4a5024c2013-11-18 07:08:23 +0000167from tempest.services.volume.json.admin.volume_hosts_client import \
168 VolumeHostsClientJSON
Sylvain Baubeaufdd34592014-02-20 18:40:10 +0100169from tempest.services.volume.json.admin.volume_quotas_client import \
170 VolumeQuotasClientJSON
Abhijeet.Jain0056b072014-04-15 09:32:29 +0530171from tempest.services.volume.json.admin.volume_services_client import \
172 VolumesServicesClientJSON
Attila Fazekas6968dd52013-02-15 17:05:53 +0100173from tempest.services.volume.json.admin.volume_types_client import \
174 VolumeTypesClientJSON
Abhijeet.Jain6109bb82014-05-01 10:29:15 +0530175from tempest.services.volume.json.availability_zone_client import \
176 VolumeAvailabilityZoneClientJSON
Giulio Fidente74b08ad2014-01-18 04:02:51 +0100177from tempest.services.volume.json.backups_client import BackupsClientJSON
Matthew Treinish2324e6b2013-10-21 20:25:17 +0000178from tempest.services.volume.json.extensions_client import \
179 ExtensionsClientJSON as VolumeExtensionClientJSON
Attila Fazekas6968dd52013-02-15 17:05:53 +0100180from tempest.services.volume.json.snapshots_client import SnapshotsClientJSON
181from tempest.services.volume.json.volumes_client import VolumesClientJSON
Zhi Kun Liu53395522014-07-18 16:05:52 +0800182from tempest.services.volume.v2.json.availability_zone_client import \
183 VolumeV2AvailabilityZoneClientJSON
184from tempest.services.volume.v2.json.extensions_client import \
185 ExtensionsV2ClientJSON as VolumeV2ExtensionClientJSON
Zhi Kun Liu8cc3c842014-01-07 10:44:34 +0800186from tempest.services.volume.v2.json.volumes_client import VolumesV2ClientJSON
Zhi Kun Liu53395522014-07-18 16:05:52 +0800187from tempest.services.volume.v2.xml.availability_zone_client import \
188 VolumeV2AvailabilityZoneClientXML
189from tempest.services.volume.v2.xml.extensions_client import \
190 ExtensionsV2ClientXML as VolumeV2ExtensionClientXML
Zhi Kun Liu8cc3c842014-01-07 10:44:34 +0800191from tempest.services.volume.v2.xml.volumes_client import VolumesV2ClientXML
Nayna Patel4a5024c2013-11-18 07:08:23 +0000192from tempest.services.volume.xml.admin.volume_hosts_client import \
193 VolumeHostsClientXML
Sylvain Baubeaufdd34592014-02-20 18:40:10 +0100194from tempest.services.volume.xml.admin.volume_quotas_client import \
195 VolumeQuotasClientXML
Abhijeet.Jain0056b072014-04-15 09:32:29 +0530196from tempest.services.volume.xml.admin.volume_services_client import \
197 VolumesServicesClientXML
Attila Fazekas6968dd52013-02-15 17:05:53 +0100198from tempest.services.volume.xml.admin.volume_types_client import \
199 VolumeTypesClientXML
Abhijeet.Jain6109bb82014-05-01 10:29:15 +0530200from tempest.services.volume.xml.availability_zone_client import \
201 VolumeAvailabilityZoneClientXML
Giulio Fidente74b08ad2014-01-18 04:02:51 +0100202from tempest.services.volume.xml.backups_client import BackupsClientXML
Matthew Treinish2324e6b2013-10-21 20:25:17 +0000203from tempest.services.volume.xml.extensions_client import \
204 ExtensionsClientXML as VolumeExtensionClientXML
Attila Fazekas6968dd52013-02-15 17:05:53 +0100205from tempest.services.volume.xml.snapshots_client import SnapshotsClientXML
206from tempest.services.volume.xml.volumes_client import VolumesClientXML
Vincent Hou6b8a7b72012-08-25 01:24:33 +0800207
Sean Dague86bd8422013-12-20 09:56:44 -0500208CONF = config.CONF
Jay Pipes3f981df2012-03-27 18:59:44 -0400209LOG = logging.getLogger(__name__)
210
Vincent Hou6b8a7b72012-08-25 01:24:33 +0800211
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000212class Manager(manager.Manager):
Daryl Walleck1465d612011-11-02 02:22:15 -0500213
Jay Pipes3f981df2012-03-27 18:59:44 -0400214 """
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000215 Top level manager for OpenStack tempest clients
Jay Pipes3f981df2012-03-27 18:59:44 -0400216 """
217
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000218 def __init__(self, credentials=None, interface='json', service=None):
219 # Set interface and client type first
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000220 self.interface = interface
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000221 self.client_type = 'tempest'
222 # super cares for credentials validation
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000223 super(Manager, self).__init__(credentials=credentials)
Brant Knudsonc7ca3342013-03-28 21:08:50 -0500224
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000225 if self.interface == 'xml':
226 self.certificates_client = CertificatesClientXML(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000227 self.auth_provider)
228 self.servers_client = ServersClientXML(self.auth_provider)
229 self.limits_client = LimitsClientXML(self.auth_provider)
230 self.images_client = ImagesClientXML(self.auth_provider)
231 self.keypairs_client = KeyPairsClientXML(self.auth_provider)
232 self.quotas_client = QuotasClientXML(self.auth_provider)
Matt Riedemann848805f2014-06-16 13:23:51 -0700233 self.quota_classes_client = QuotaClassesClientXML(
234 self.auth_provider)
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000235 self.flavors_client = FlavorsClientXML(self.auth_provider)
236 self.extensions_client = ExtensionsClientXML(self.auth_provider)
Attila Fazekas7e678de2013-07-13 14:13:28 +0200237 self.volumes_extensions_client = VolumesExtensionsClientXML(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000238 self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000239 self.floating_ips_client = FloatingIPsClientXML(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000240 self.auth_provider)
241 self.backups_client = BackupsClientXML(self.auth_provider)
242 self.snapshots_client = SnapshotsClientXML(self.auth_provider)
243 self.volumes_client = VolumesClientXML(self.auth_provider)
244 self.volumes_v2_client = VolumesV2ClientXML(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000245 self.volume_types_client = VolumeTypesClientXML(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000246 self.auth_provider)
247 self.identity_client = IdentityClientXML(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000248 self.identity_v3_client = IdentityV3ClientXML(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000249 self.auth_provider)
Attila Fazekas7e678de2013-07-13 14:13:28 +0200250 self.security_groups_client = SecurityGroupsClientXML(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000251 self.auth_provider)
252 self.interfaces_client = InterfacesClientXML(self.auth_provider)
253 self.endpoints_client = EndPointClientXML(self.auth_provider)
254 self.fixed_ips_client = FixedIPsClientXML(self.auth_provider)
Attila Fazekas7e678de2013-07-13 14:13:28 +0200255 self.availability_zone_client = AvailabilityZoneClientXML(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000256 self.auth_provider)
257 self.service_client = ServiceClientXML(self.auth_provider)
Abhijeet.Jain0056b072014-04-15 09:32:29 +0530258 self.volume_services_client = VolumesServicesClientXML(
259 self.auth_provider)
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000260 self.aggregates_client = AggregatesClientXML(self.auth_provider)
261 self.services_client = ServicesClientXML(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000262 self.tenant_usages_client = TenantUsagesClientXML(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000263 self.auth_provider)
264 self.policy_client = PolicyClientXML(self.auth_provider)
ravikumar-venkatesan3052e942014-05-12 18:25:17 +0000265 self.region_client = RegionClientXML(self.auth_provider)
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000266 self.hosts_client = HostsClientXML(self.auth_provider)
267 self.hypervisor_client = HypervisorClientXML(self.auth_provider)
268 self.network_client = NetworkClientXML(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000269 self.credentials_client = CredentialsClientXML(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000270 self.auth_provider)
ivan-zhuef7a1bd2013-10-22 17:56:46 +0800271 self.instance_usages_audit_log_client = \
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000272 InstanceUsagesAuditLogClientXML(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000273 self.volume_hosts_client = VolumeHostsClientXML(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000274 self.auth_provider)
Sylvain Baubeaufdd34592014-02-20 18:40:10 +0100275 self.volume_quotas_client = VolumeQuotasClientXML(
276 self.auth_provider)
Matthew Treinish2324e6b2013-10-21 20:25:17 +0000277 self.volumes_extension_client = VolumeExtensionClientXML(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000278 self.auth_provider)
Zhi Kun Liu53395522014-07-18 16:05:52 +0800279 self.volumes_v2_extension_client = VolumeV2ExtensionClientXML(
280 self.auth_provider)
Nikolay Pliashechnikovb053aab2013-11-05 06:06:44 -0800281 if CONF.service_available.ceilometer:
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000282 self.telemetry_client = TelemetryClientXML(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000283 self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000284 self.token_client = TokenClientXML()
285 self.token_v3_client = V3TokenClientXML()
Abhijeet.Jain6109bb82014-05-01 10:29:15 +0530286 self.volume_availability_zone_client = \
287 VolumeAvailabilityZoneClientXML(self.auth_provider)
Zhi Kun Liu53395522014-07-18 16:05:52 +0800288 self.volume_v2_availability_zone_client = \
289 VolumeV2AvailabilityZoneClientXML(self.auth_provider)
Brant Knudsonc7ca3342013-03-28 21:08:50 -0500290
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000291 elif self.interface == 'json':
292 self.certificates_client = CertificatesClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000293 self.auth_provider)
ivan-zhu0e062922013-12-17 16:14:12 +0800294 self.certificates_v3_client = CertificatesV3ClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000295 self.auth_provider)
296 self.baremetal_client = BaremetalClientJSON(self.auth_provider)
297 self.servers_client = ServersClientJSON(self.auth_provider)
298 self.servers_v3_client = ServersV3ClientJSON(self.auth_provider)
299 self.limits_client = LimitsClientJSON(self.auth_provider)
300 self.images_client = ImagesClientJSON(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000301 self.keypairs_v3_client = KeyPairsV3ClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000302 self.auth_provider)
303 self.keypairs_client = KeyPairsClientJSON(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000304 self.keypairs_v3_client = KeyPairsV3ClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000305 self.auth_provider)
306 self.quotas_client = QuotasClientJSON(self.auth_provider)
Matt Riedemann848805f2014-06-16 13:23:51 -0700307 self.quota_classes_client = QuotaClassesClientJSON(
308 self.auth_provider)
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000309 self.quotas_v3_client = QuotasV3ClientJSON(self.auth_provider)
310 self.flavors_client = FlavorsClientJSON(self.auth_provider)
311 self.flavors_v3_client = FlavorsV3ClientJSON(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000312 self.extensions_v3_client = ExtensionsV3ClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000313 self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000314 self.extensions_client = ExtensionsClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000315 self.auth_provider)
Attila Fazekas7e678de2013-07-13 14:13:28 +0200316 self.volumes_extensions_client = VolumesExtensionsClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000317 self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000318 self.floating_ips_client = FloatingIPsClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000319 self.auth_provider)
320 self.backups_client = BackupsClientJSON(self.auth_provider)
321 self.snapshots_client = SnapshotsClientJSON(self.auth_provider)
322 self.volumes_client = VolumesClientJSON(self.auth_provider)
323 self.volumes_v2_client = VolumesV2ClientJSON(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000324 self.volume_types_client = VolumeTypesClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000325 self.auth_provider)
326 self.identity_client = IdentityClientJSON(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000327 self.identity_v3_client = IdentityV3ClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000328 self.auth_provider)
Attila Fazekas7e678de2013-07-13 14:13:28 +0200329 self.security_groups_client = SecurityGroupsClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000330 self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000331 self.interfaces_v3_client = InterfacesV3ClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000332 self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000333 self.interfaces_client = InterfacesClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000334 self.auth_provider)
335 self.endpoints_client = EndPointClientJSON(self.auth_provider)
336 self.fixed_ips_client = FixedIPsClientJSON(self.auth_provider)
ivan-zhuac7b3802013-08-21 16:03:53 +0800337 self.availability_zone_v3_client = AvailabilityZoneV3ClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000338 self.auth_provider)
Attila Fazekas7e678de2013-07-13 14:13:28 +0200339 self.availability_zone_client = AvailabilityZoneClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000340 self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000341 self.services_v3_client = ServicesV3ClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000342 self.auth_provider)
343 self.service_client = ServiceClientJSON(self.auth_provider)
Abhijeet.Jain0056b072014-04-15 09:32:29 +0530344 self.volume_services_client = VolumesServicesClientJSON(
345 self.auth_provider)
YuikoTakada8a2ec112014-02-18 21:13:51 +0000346 self.agents_v3_client = AgentsV3ClientJSON(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000347 self.aggregates_v3_client = AggregatesV3ClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000348 self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000349 self.aggregates_client = AggregatesClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000350 self.auth_provider)
351 self.services_client = ServicesClientJSON(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000352 self.tenant_usages_client = TenantUsagesClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000353 self.auth_provider)
354 self.version_v3_client = VersionV3ClientJSON(self.auth_provider)
Ken'ichi Ohmichi8f088c12014-03-28 15:16:11 +0900355 self.migrations_v3_client = MigrationsV3ClientJSON(
356 self.auth_provider)
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000357 self.policy_client = PolicyClientJSON(self.auth_provider)
ravikumar-venkatesan3052e942014-05-12 18:25:17 +0000358 self.region_client = RegionClientJSON(self.auth_provider)
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000359 self.hosts_client = HostsClientJSON(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000360 self.hypervisor_v3_client = HypervisorV3ClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000361 self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000362 self.hypervisor_client = HypervisorClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000363 self.auth_provider)
364 self.network_client = NetworkClientJSON(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000365 self.credentials_client = CredentialsClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000366 self.auth_provider)
ivan-zhuef7a1bd2013-10-22 17:56:46 +0800367 self.instance_usages_audit_log_client = \
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000368 InstanceUsagesAuditLogClientJSON(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000369 self.volume_hosts_client = VolumeHostsClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000370 self.auth_provider)
Sylvain Baubeaufdd34592014-02-20 18:40:10 +0100371 self.volume_quotas_client = VolumeQuotasClientJSON(
372 self.auth_provider)
Matthew Treinish2324e6b2013-10-21 20:25:17 +0000373 self.volumes_extension_client = VolumeExtensionClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000374 self.auth_provider)
Zhi Kun Liu53395522014-07-18 16:05:52 +0800375 self.volumes_v2_extension_client = VolumeV2ExtensionClientJSON(
376 self.auth_provider)
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000377 self.hosts_v3_client = HostsV3ClientJSON(self.auth_provider)
Nikhil Manchandadd6886f2014-03-03 01:58:45 -0800378 self.database_flavors_client = DatabaseFlavorsClientJSON(
379 self.auth_provider)
Peter Stachowski320f9c72014-04-21 16:13:23 -0400380 self.database_versions_client = DatabaseVersionsClientJSON(
381 self.auth_provider)
Malini Kamalambal6e7b3b82014-02-06 06:49:04 -0500382 self.queuing_client = QueuingClientJSON(self.auth_provider)
Nikolay Pliashechnikovb053aab2013-11-05 06:06:44 -0800383 if CONF.service_available.ceilometer:
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000384 self.telemetry_client = TelemetryClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000385 self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000386 self.token_client = TokenClientJSON()
387 self.token_v3_client = V3TokenClientJSON()
Matthew Treinish5c660ab2014-05-18 21:14:36 -0400388 self.negative_client = rest_client.NegativeRestClient(
389 self.auth_provider)
Marc Koderer24eb89c2014-01-31 11:23:33 +0100390 self.negative_client.service = service
Abhijeet.Jain6109bb82014-05-01 10:29:15 +0530391 self.volume_availability_zone_client = \
392 VolumeAvailabilityZoneClientJSON(self.auth_provider)
Zhi Kun Liu53395522014-07-18 16:05:52 +0800393 self.volume_v2_availability_zone_client = \
394 VolumeV2AvailabilityZoneClientJSON(self.auth_provider)
Attila Fazekas7e678de2013-07-13 14:13:28 +0200395
Attila Fazekas7e678de2013-07-13 14:13:28 +0200396 else:
Dan Smithcf8fab62012-08-14 08:03:48 -0700397 msg = "Unsupported interface type `%s'" % interface
398 raise exceptions.InvalidConfiguration(msg)
Attila Fazekas7e678de2013-07-13 14:13:28 +0200399
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000400 # TODO(andreaf) EC2 client still do their auth, v2 only
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000401 ec2_client_args = (self.credentials.username,
402 self.credentials.password,
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000403 CONF.identity.uri,
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000404 self.credentials.tenant_name)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000405
Attila Fazekas7e678de2013-07-13 14:13:28 +0200406 # common clients
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000407 self.account_client = AccountClient(self.auth_provider)
Yuiko Takada420f2eb2014-04-02 19:53:38 +0900408 self.agents_client = AgentsClientJSON(self.auth_provider)
Sean Dague86bd8422013-12-20 09:56:44 -0500409 if CONF.service_available.glance:
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000410 self.image_client = ImageClientJSON(self.auth_provider)
411 self.image_client_v2 = ImageClientV2JSON(self.auth_provider)
412 self.container_client = ContainerClient(self.auth_provider)
413 self.object_client = ObjectClient(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000414 self.orchestration_client = OrchestrationClient(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000415 self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000416 self.ec2api_client = botoclients.APIClientEC2(*ec2_client_args)
417 self.s3_client = botoclients.ObjectClientS3(*ec2_client_args)
418 self.custom_object_client = ObjectClientCustomizedHeader(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000419 self.auth_provider)
harika-vakadi2daed0a2013-01-01 20:51:39 +0530420 self.custom_account_client = \
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000421 AccountClientCustomizedHeader(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000422 self.data_processing_client = DataProcessingClient(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000423 self.auth_provider)
Ken'ichi Ohmichi2fdc1822014-03-18 09:10:57 +0900424 self.migrations_client = MigrationsClientJSON(self.auth_provider)
Jay Pipes50677282012-01-06 15:39:20 -0500425
426
Jay Pipesff10d552012-04-06 14:18:50 -0400427class AltManager(Manager):
428
429 """
430 Manager object that uses the alt_XXX credentials for its
431 managed client objects
432 """
433
Marc Koderer24eb89c2014-01-31 11:23:33 +0100434 def __init__(self, interface='json', service=None):
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000435 super(AltManager, self).__init__(
436 credentials=auth.get_default_credentials('alt_user'),
437 interface=interface,
438 service=service)
Jay Pipesff10d552012-04-06 14:18:50 -0400439
440
441class AdminManager(Manager):
442
443 """
Attila Fazekascadcb1f2013-01-21 23:10:53 +0100444 Manager object that uses the admin credentials for its
Jay Pipesff10d552012-04-06 14:18:50 -0400445 managed client objects
446 """
447
Marc Koderer24eb89c2014-01-31 11:23:33 +0100448 def __init__(self, interface='json', service=None):
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000449 super(AdminManager, self).__init__(
450 credentials=auth.get_default_credentials('identity_admin'),
451 interface=interface,
452 service=service)
Jay Pipesff10d552012-04-06 14:18:50 -0400453
454
Attila Fazekascadcb1f2013-01-21 23:10:53 +0100455class ComputeAdminManager(Manager):
456
457 """
458 Manager object that uses the compute_admin credentials for its
459 managed client objects
460 """
461
Marc Koderer24eb89c2014-01-31 11:23:33 +0100462 def __init__(self, interface='json', service=None):
Attila Fazekascadcb1f2013-01-21 23:10:53 +0100463 base = super(ComputeAdminManager, self)
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000464 base.__init__(
465 credentials=auth.get_default_credentials('compute_admin'),
466 interface=interface,
467 service=service)
Steve Bakerc60e4e32013-05-06 15:22:41 +1200468
469
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000470class OfficialClientManager(manager.Manager):
471 """
472 Manager that provides access to the official python clients for
473 calling various OpenStack APIs.
474 """
475
476 NOVACLIENT_VERSION = '2'
477 CINDERCLIENT_VERSION = '1'
478 HEATCLIENT_VERSION = '1'
Adam Gandelman4a48a602014-03-20 18:23:18 -0700479 IRONICCLIENT_VERSION = '1'
Sergey Lukjanov7409e2e2014-03-27 12:55:50 +0400480 SAHARACLIENT_VERSION = '1.1'
Artur Svechnikovc3bf9252014-05-05 16:37:37 +0400481 CEILOMETERCLIENT_VERSION = '2'
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000482
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000483 def __init__(self, credentials):
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000484 # FIXME(andreaf) Auth provider for client_type 'official' is
485 # not implemented yet, setting to 'tempest' for now.
486 self.client_type = 'tempest'
487 self.interface = None
488 # super cares for credentials validation
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000489 super(OfficialClientManager, self).__init__(credentials=credentials)
Adam Gandelman4a48a602014-03-20 18:23:18 -0700490 self.baremetal_client = self._get_baremetal_client()
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000491 self.compute_client = self._get_compute_client(credentials)
492 self.identity_client = self._get_identity_client(credentials)
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000493 self.image_client = self._get_image_client()
494 self.network_client = self._get_network_client()
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000495 self.volume_client = self._get_volume_client(credentials)
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000496 self.object_storage_client = self._get_object_storage_client(
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000497 credentials)
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000498 self.orchestration_client = self._get_orchestration_client(
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000499 credentials)
Sergey Lukjanov7409e2e2014-03-27 12:55:50 +0400500 self.data_processing_client = self._get_data_processing_client(
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000501 credentials)
Artur Svechnikovc3bf9252014-05-05 16:37:37 +0400502 self.ceilometer_client = self._get_ceilometer_client(
503 credentials)
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000504
Adam Gandelman4a48a602014-03-20 18:23:18 -0700505 def _get_roles(self):
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000506 admin_credentials = auth.get_default_credentials('identity_admin')
507 keystone_admin = self._get_identity_client(admin_credentials)
Adam Gandelman4a48a602014-03-20 18:23:18 -0700508
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000509 username = self.credentials.username
510 tenant_name = self.credentials.tenant_name
Adam Gandelman4a48a602014-03-20 18:23:18 -0700511 user_id = keystone_admin.users.find(name=username).id
512 tenant_id = keystone_admin.tenants.find(name=tenant_name).id
513
514 roles = keystone_admin.roles.roles_for_user(
515 user=user_id, tenant=tenant_id)
516
517 return [r.name for r in roles]
518
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000519 def _get_compute_client(self, credentials):
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000520 # Novaclient will not execute operations for anyone but the
521 # identified user, so a new client needs to be created for
522 # each user that operations need to be performed for.
Zhi Kun Liufaa6b5f2014-04-14 01:38:16 -0500523 if not CONF.service_available.nova:
524 return None
525 import novaclient.client
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000526
527 auth_url = CONF.identity.uri
528 dscv = CONF.identity.disable_ssl_certificate_validation
529 region = CONF.identity.region
530
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000531 client_args = (credentials.username, credentials.password,
532 credentials.tenant_name, auth_url)
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000533
534 # Create our default Nova client to use in testing
535 service_type = CONF.compute.catalog_type
536 endpoint_type = CONF.compute.endpoint_type
537 return novaclient.client.Client(self.NOVACLIENT_VERSION,
538 *client_args,
539 service_type=service_type,
540 endpoint_type=endpoint_type,
541 region_name=region,
542 no_cache=True,
543 insecure=dscv,
544 http_log_debug=True)
545
546 def _get_image_client(self):
Zhi Kun Liufaa6b5f2014-04-14 01:38:16 -0500547 if not CONF.service_available.glance:
548 return None
549 import glanceclient
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000550 token = self.identity_client.auth_token
551 region = CONF.identity.region
552 endpoint_type = CONF.image.endpoint_type
553 endpoint = self.identity_client.service_catalog.url_for(
554 attr='region', filter_value=region,
555 service_type=CONF.image.catalog_type, endpoint_type=endpoint_type)
556 dscv = CONF.identity.disable_ssl_certificate_validation
557 return glanceclient.Client('1', endpoint=endpoint, token=token,
558 insecure=dscv)
559
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000560 def _get_volume_client(self, credentials):
Zhi Kun Liufaa6b5f2014-04-14 01:38:16 -0500561 if not CONF.service_available.cinder:
562 return None
563 import cinderclient.client
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000564 auth_url = CONF.identity.uri
565 region = CONF.identity.region
566 endpoint_type = CONF.volume.endpoint_type
Rob Crittenden1aba5d02014-03-25 23:27:09 -0400567 dscv = CONF.identity.disable_ssl_certificate_validation
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000568 return cinderclient.client.Client(self.CINDERCLIENT_VERSION,
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000569 credentials.username,
570 credentials.password,
571 credentials.tenant_name,
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000572 auth_url,
573 region_name=region,
574 endpoint_type=endpoint_type,
Rob Crittenden1aba5d02014-03-25 23:27:09 -0400575 insecure=dscv,
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000576 http_log_debug=True)
577
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000578 def _get_object_storage_client(self, credentials):
Zhi Kun Liufaa6b5f2014-04-14 01:38:16 -0500579 if not CONF.service_available.swift:
580 return None
581 import swiftclient
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000582 auth_url = CONF.identity.uri
583 # add current tenant to swift operator role group.
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000584 admin_credentials = auth.get_default_credentials('identity_admin')
585 keystone_admin = self._get_identity_client(admin_credentials)
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000586
587 # enable test user to operate swift by adding operator role to him.
588 roles = keystone_admin.roles.list()
589 operator_role = CONF.object_storage.operator_role
590 member_role = [role for role in roles if role.name == operator_role][0]
591 # NOTE(maurosr): This is surrounded in the try-except block cause
592 # neutron tests doesn't have tenant isolation.
593 try:
594 keystone_admin.roles.add_user_role(self.identity_client.user_id,
595 member_role.id,
596 self.identity_client.tenant_id)
597 except keystoneclient.exceptions.Conflict:
598 pass
599
600 endpoint_type = CONF.object_storage.endpoint_type
601 os_options = {'endpoint_type': endpoint_type}
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000602 return swiftclient.Connection(auth_url, credentials.username,
603 credentials.password,
604 tenant_name=credentials.tenant_name,
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000605 auth_version='2',
606 os_options=os_options)
607
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000608 def _get_orchestration_client(self, credentials):
Zhi Kun Liufaa6b5f2014-04-14 01:38:16 -0500609 if not CONF.service_available.heat:
610 return None
611 import heatclient.client
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000612
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000613 keystone = self._get_identity_client(credentials)
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000614 region = CONF.identity.region
615 endpoint_type = CONF.orchestration.endpoint_type
616 token = keystone.auth_token
617 service_type = CONF.orchestration.catalog_type
618 try:
619 endpoint = keystone.service_catalog.url_for(
620 attr='region',
621 filter_value=region,
622 service_type=service_type,
623 endpoint_type=endpoint_type)
624 except keystoneclient.exceptions.EndpointNotFound:
625 return None
626 else:
627 return heatclient.client.Client(self.HEATCLIENT_VERSION,
628 endpoint,
629 token=token,
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000630 username=credentials.username,
631 password=credentials.password)
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000632
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000633 def _get_identity_client(self, credentials):
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000634 # This identity client is not intended to check the security
635 # of the identity service, so use admin credentials by default.
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000636
637 auth_url = CONF.identity.uri
638 dscv = CONF.identity.disable_ssl_certificate_validation
639
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000640 return keystoneclient.v2_0.client.Client(
641 username=credentials.username,
642 password=credentials.password,
643 tenant_name=credentials.tenant_name,
644 auth_url=auth_url,
645 insecure=dscv)
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000646
Adam Gandelman4a48a602014-03-20 18:23:18 -0700647 def _get_baremetal_client(self):
648 # ironic client is currently intended to by used by admin users
Zhi Kun Liufaa6b5f2014-04-14 01:38:16 -0500649 if not CONF.service_available.ironic:
650 return None
651 import ironicclient.client
Adam Gandelman4a48a602014-03-20 18:23:18 -0700652 roles = self._get_roles()
653 if CONF.identity.admin_role not in roles:
654 return None
655
656 auth_url = CONF.identity.uri
657 api_version = self.IRONICCLIENT_VERSION
658 insecure = CONF.identity.disable_ssl_certificate_validation
659 service_type = CONF.baremetal.catalog_type
660 endpoint_type = CONF.baremetal.endpoint_type
661 creds = {
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000662 'os_username': self.credentials.username,
663 'os_password': self.credentials.password,
664 'os_tenant_name': self.credentials.tenant_name
Adam Gandelman4a48a602014-03-20 18:23:18 -0700665 }
666
667 try:
668 return ironicclient.client.get_client(
669 api_version=api_version,
670 os_auth_url=auth_url,
671 insecure=insecure,
672 os_service_type=service_type,
673 os_endpoint_type=endpoint_type,
674 **creds)
675 except keystoneclient.exceptions.EndpointNotFound:
676 return None
677
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000678 def _get_network_client(self):
679 # The intended configuration is for the network client to have
680 # admin privileges and indicate for whom resources are being
681 # created via a 'tenant_id' parameter. This will often be
682 # preferable to authenticating as a specific user because
683 # working with certain resources (public routers and networks)
684 # often requires admin privileges anyway.
Zhi Kun Liufaa6b5f2014-04-14 01:38:16 -0500685 if not CONF.service_available.neutron:
686 return None
687 import neutronclient.v2_0.client
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000688
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000689 credentials = auth.get_default_credentials('identity_admin')
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000690
691 auth_url = CONF.identity.uri
692 dscv = CONF.identity.disable_ssl_certificate_validation
693 endpoint_type = CONF.network.endpoint_type
694
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000695 return neutronclient.v2_0.client.Client(
696 username=credentials.username,
697 password=credentials.password,
698 tenant_name=credentials.tenant_name,
699 endpoint_type=endpoint_type,
700 auth_url=auth_url,
701 insecure=dscv)
Sergey Lukjanov7409e2e2014-03-27 12:55:50 +0400702
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000703 def _get_data_processing_client(self, credentials):
Sergey Lukjanov7409e2e2014-03-27 12:55:50 +0400704 if not CONF.service_available.sahara:
705 # Sahara isn't available
706 return None
707
708 import saharaclient.client
709
Sergey Lukjanov7409e2e2014-03-27 12:55:50 +0400710 endpoint_type = CONF.data_processing.endpoint_type
711 catalog_type = CONF.data_processing.catalog_type
712 auth_url = CONF.identity.uri
713
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000714 client = saharaclient.client.Client(
715 self.SAHARACLIENT_VERSION,
716 credentials.username,
717 credentials.password,
718 project_name=credentials.tenant_name,
719 endpoint_type=endpoint_type,
720 service_type=catalog_type,
721 auth_url=auth_url)
Sergey Lukjanov7409e2e2014-03-27 12:55:50 +0400722
723 return client
Artur Svechnikovc3bf9252014-05-05 16:37:37 +0400724
725 def _get_ceilometer_client(self, credentials):
726 if not CONF.service_available.ceilometer:
727 return None
728
729 import ceilometerclient.client
730
731 keystone = self._get_identity_client(credentials)
732 region = CONF.identity.region
733
734 endpoint_type = CONF.telemetry.endpoint_type
735 service_type = CONF.telemetry.catalog_type
736 auth_url = CONF.identity.uri
737
738 try:
739 keystone.service_catalog.url_for(
740 attr='region',
741 filter_value=region,
742 service_type=service_type,
743 endpoint_type=endpoint_type)
744 except keystoneclient.exceptions.EndpointNotFound:
745 return None
746 else:
747 return ceilometerclient.client.get_client(
748 self.CEILOMETERCLIENT_VERSION,
749 os_username=credentials.username,
750 os_password=credentials.password,
751 os_tenant_name=credentials.tenant_name,
752 os_auth_url=auth_url,
753 os_service_type=service_type,
754 os_endpoint_type=endpoint_type)