blob: 2b8b6fbe60e78fb7fb43416819f7d36cf6420ac5 [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
Andrea Frittolie258cd72014-07-17 04:47:26 +010053from tempest.services.compute.json.networks_client import NetworksClientJSON
Matt Riedemann848805f2014-06-16 13:23:51 -070054from tempest.services.compute.json.quotas_client import QuotaClassesClientJSON
Attila Fazekas6968dd52013-02-15 17:05:53 +010055from tempest.services.compute.json.quotas_client import QuotasClientJSON
Ghanshyam9d9201d2014-04-16 19:28:09 +090056from tempest.services.compute.json.security_group_default_rules_client import \
57 SecurityGroupDefaultRulesClientJSON
Matthew Treinisha83a16e2012-12-07 13:44:02 -050058from tempest.services.compute.json.security_groups_client import \
harika-vakadi1a9ad612012-12-14 19:12:08 +053059 SecurityGroupsClientJSON
Attila Fazekas6968dd52013-02-15 17:05:53 +010060from tempest.services.compute.json.servers_client import ServersClientJSON
Leo Toyoda3ae31e12013-04-19 11:19:57 +090061from tempest.services.compute.json.services_client import ServicesClientJSON
Leo Toyodad80b6a02013-05-08 12:15:13 +090062from tempest.services.compute.json.tenant_usages_client import \
63 TenantUsagesClientJSON
Matthew Treinisha83a16e2012-12-07 13:44:02 -050064from tempest.services.compute.json.volumes_extensions_client import \
harika-vakadi1a9ad612012-12-14 19:12:08 +053065 VolumesExtensionsClientJSON
YuikoTakada8a2ec112014-02-18 21:13:51 +000066from tempest.services.compute.v3.json.agents_client import AgentsV3ClientJSON
ivan-zhu00fe64f2013-08-20 19:35:51 +080067from tempest.services.compute.v3.json.aggregates_client import \
68 AggregatesV3ClientJSON
ivan-zhuac7b3802013-08-21 16:03:53 +080069from tempest.services.compute.v3.json.availability_zone_client import \
70 AvailabilityZoneV3ClientJSON
ivan-zhu0e062922013-12-17 16:14:12 +080071from tempest.services.compute.v3.json.certificates_client import \
72 CertificatesV3ClientJSON
ivan-zhu31d98482013-08-22 10:51:48 +080073from tempest.services.compute.v3.json.extensions_client import \
74 ExtensionsV3ClientJSON
ivan-zhub25900a2013-12-13 16:28:45 +080075from tempest.services.compute.v3.json.flavors_client import FlavorsV3ClientJSON
ivan-zhu00fe64f2013-08-20 19:35:51 +080076from tempest.services.compute.v3.json.hosts_client import HostsV3ClientJSON
ivan-zhu6f5f9e92013-08-21 22:16:37 +080077from tempest.services.compute.v3.json.hypervisor_client import \
78 HypervisorV3ClientJSON
ivan-zhu91feab92013-08-15 18:25:33 +080079from tempest.services.compute.v3.json.interfaces_client import \
80 InterfacesV3ClientJSON
ivan-zhu7e7e6a32013-11-20 16:07:29 +080081from tempest.services.compute.v3.json.keypairs_client import \
82 KeyPairsV3ClientJSON
Ken'ichi Ohmichi8f088c12014-03-28 15:16:11 +090083from tempest.services.compute.v3.json.migration_client import \
84 MigrationsV3ClientJSON
ivan-zhub6d69ee2013-12-17 14:16:31 +080085from tempest.services.compute.v3.json.quotas_client import \
86 QuotasV3ClientJSON
ivan-zhu8f992be2013-07-31 14:56:58 +080087from tempest.services.compute.v3.json.servers_client import \
88 ServersV3ClientJSON
ivan-zhu5c86ae62013-08-20 21:09:01 +080089from tempest.services.compute.v3.json.services_client import \
90 ServicesV3ClientJSON
Ken'ichi Ohmichi3d6b6fa2014-01-08 04:42:16 +090091from tempest.services.compute.v3.json.version_client import \
92 VersionV3ClientJSON
Mitsuhiko Yamazakiae8fc532013-04-22 11:17:35 +090093from tempest.services.compute.xml.aggregates_client import AggregatesClientXML
Leo Toyodaa5278912013-04-16 15:40:12 +090094from tempest.services.compute.xml.availability_zone_client import \
95 AvailabilityZoneClientXML
ivan-zhud57f3cf2013-11-06 16:59:52 +080096from tempest.services.compute.xml.certificates_client import \
97 CertificatesClientXML
dwallecke62b9f02012-10-10 23:34:42 -050098from tempest.services.compute.xml.extensions_client import ExtensionsClientXML
Sean Dague2416cf32013-04-10 08:29:07 -040099from tempest.services.compute.xml.fixed_ips_client import FixedIPsClientXML
dwallecke62b9f02012-10-10 23:34:42 -0500100from tempest.services.compute.xml.flavors_client import FlavorsClientXML
101from tempest.services.compute.xml.floating_ips_client import \
harika-vakadi1a9ad612012-12-14 19:12:08 +0530102 FloatingIPsClientXML
Ken'ichi Ohmichia1aa44c2013-12-06 20:48:24 +0900103from tempest.services.compute.xml.hosts_client import HostsClientXML
Tony Yang3d5f1632013-06-06 14:17:57 +0800104from tempest.services.compute.xml.hypervisor_client import HypervisorClientXML
dwallecke62b9f02012-10-10 23:34:42 -0500105from tempest.services.compute.xml.images_client import ImagesClientXML
ivan-zhuef7a1bd2013-10-22 17:56:46 +0800106from tempest.services.compute.xml.instance_usage_audit_log_client import \
107 InstanceUsagesAuditLogClientXML
Sean Dague2416cf32013-04-10 08:29:07 -0400108from tempest.services.compute.xml.interfaces_client import \
109 InterfacesClientXML
dwallecke62b9f02012-10-10 23:34:42 -0500110from tempest.services.compute.xml.keypairs_client import KeyPairsClientXML
111from tempest.services.compute.xml.limits_client import LimitsClientXML
Matt Riedemann848805f2014-06-16 13:23:51 -0700112from tempest.services.compute.xml.quotas_client import QuotaClassesClientXML
rajalakshmi-ganesan1982c3c2013-01-10 14:56:45 +0530113from tempest.services.compute.xml.quotas_client import QuotasClientXML
dwallecke62b9f02012-10-10 23:34:42 -0500114from tempest.services.compute.xml.security_groups_client \
harika-vakadi1a9ad612012-12-14 19:12:08 +0530115 import SecurityGroupsClientXML
dwallecke62b9f02012-10-10 23:34:42 -0500116from tempest.services.compute.xml.servers_client import ServersClientXML
Leo Toyoda3ae31e12013-04-19 11:19:57 +0900117from tempest.services.compute.xml.services_client import ServicesClientXML
Leo Toyodad80b6a02013-05-08 12:15:13 +0900118from tempest.services.compute.xml.tenant_usages_client import \
119 TenantUsagesClientXML
Matthew Treinisha83a16e2012-12-07 13:44:02 -0500120from tempest.services.compute.xml.volumes_extensions_client import \
harika-vakadi1a9ad612012-12-14 19:12:08 +0530121 VolumesExtensionsClientXML
Sergey Lukjanov3bc60e92013-12-10 16:40:50 +0400122from tempest.services.data_processing.v1_1.client import DataProcessingClient
Nikhil Manchandadd6886f2014-03-03 01:58:45 -0800123from tempest.services.database.json.flavors_client import \
124 DatabaseFlavorsClientJSON
Peter Stachowski320f9c72014-04-21 16:13:23 -0400125from tempest.services.database.json.versions_client import \
126 DatabaseVersionsClientJSON
Attila Fazekas407b6db2013-01-19 12:48:36 +0100127from tempest.services.identity.json.identity_client import IdentityClientJSON
128from tempest.services.identity.json.identity_client import TokenClientJSON
nayna-patel914b4712013-07-16 08:29:05 +0000129from tempest.services.identity.v3.json.credentials_client import \
130 CredentialsClientJSON
Sean Dague2416cf32013-04-10 08:29:07 -0400131from tempest.services.identity.v3.json.endpoints_client import \
132 EndPointClientJSON
rajalakshmi-ganesan7312bb52013-01-29 20:03:42 +0530133from tempest.services.identity.v3.json.identity_client import \
134 IdentityV3ClientJSON
nayna-patelb35f7232013-06-28 07:08:44 +0000135from tempest.services.identity.v3.json.identity_client import V3TokenClientJSON
harika-vakadi40e10112013-02-08 14:38:09 +0530136from tempest.services.identity.v3.json.policy_client import PolicyClientJSON
ravikumar-venkatesan3052e942014-05-12 18:25:17 +0000137from tempest.services.identity.v3.json.region_client import RegionClientJSON
harika-vakadia92dd742013-02-19 20:41:22 +0530138from tempest.services.identity.v3.json.service_client import \
139 ServiceClientJSON
nayna-patel914b4712013-07-16 08:29:05 +0000140from tempest.services.identity.v3.xml.credentials_client import \
141 CredentialsClientXML
rajalakshmi-ganesanab426722013-02-08 15:49:15 +0530142from tempest.services.identity.v3.xml.endpoints_client import EndPointClientXML
rajalakshmi-ganesan7312bb52013-01-29 20:03:42 +0530143from tempest.services.identity.v3.xml.identity_client import \
144 IdentityV3ClientXML
nayna-patelb35f7232013-06-28 07:08:44 +0000145from tempest.services.identity.v3.xml.identity_client import V3TokenClientXML
harika-vakadi40e10112013-02-08 14:38:09 +0530146from tempest.services.identity.v3.xml.policy_client import PolicyClientXML
ravikumar-venkatesan3052e942014-05-12 18:25:17 +0000147from tempest.services.identity.v3.xml.region_client import RegionClientXML
harika-vakadia92dd742013-02-19 20:41:22 +0530148from tempest.services.identity.v3.xml.service_client import \
149 ServiceClientXML
Attila Fazekas407b6db2013-01-19 12:48:36 +0100150from tempest.services.identity.xml.identity_client import IdentityClientXML
151from tempest.services.identity.xml.identity_client import TokenClientXML
Matthew Treinish6d59c992013-03-01 16:20:04 -0500152from tempest.services.image.v1.json.image_client import ImageClientJSON
Matthew Treinisha62347f2013-03-01 16:37:30 -0500153from tempest.services.image.v2.json.image_client import ImageClientV2JSON
raiesmh0867698322013-08-20 13:09:01 +0530154from tempest.services.network.json.network_client import NetworkClientJSON
155from tempest.services.network.xml.network_client import NetworkClientXML
dwalleck5d734432012-10-04 01:11:47 -0500156from tempest.services.object_storage.account_client import AccountClient
harika-vakadi2daed0a2013-01-01 20:51:39 +0530157from tempest.services.object_storage.account_client import \
158 AccountClientCustomizedHeader
Attila Fazekas6968dd52013-02-15 17:05:53 +0100159from tempest.services.object_storage.container_client import ContainerClient
160from tempest.services.object_storage.object_client import ObjectClient
161from tempest.services.object_storage.object_client import \
162 ObjectClientCustomizedHeader
Steve Bakerc60e4e32013-05-06 15:22:41 +1200163from tempest.services.orchestration.json.orchestration_client import \
164 OrchestrationClient
Malini Kamalambal6e7b3b82014-02-06 06:49:04 -0500165from tempest.services.queuing.json.queuing_client import QueuingClientJSON
Nikolay Pliashechnikovb053aab2013-11-05 06:06:44 -0800166from tempest.services.telemetry.json.telemetry_client import \
167 TelemetryClientJSON
168from tempest.services.telemetry.xml.telemetry_client import \
169 TelemetryClientXML
Nayna Patel4a5024c2013-11-18 07:08:23 +0000170from tempest.services.volume.json.admin.volume_hosts_client import \
171 VolumeHostsClientJSON
Sylvain Baubeaufdd34592014-02-20 18:40:10 +0100172from tempest.services.volume.json.admin.volume_quotas_client import \
173 VolumeQuotasClientJSON
Abhijeet.Jain0056b072014-04-15 09:32:29 +0530174from tempest.services.volume.json.admin.volume_services_client import \
175 VolumesServicesClientJSON
Attila Fazekas6968dd52013-02-15 17:05:53 +0100176from tempest.services.volume.json.admin.volume_types_client import \
177 VolumeTypesClientJSON
Abhijeet.Jain6109bb82014-05-01 10:29:15 +0530178from tempest.services.volume.json.availability_zone_client import \
179 VolumeAvailabilityZoneClientJSON
Giulio Fidente74b08ad2014-01-18 04:02:51 +0100180from tempest.services.volume.json.backups_client import BackupsClientJSON
Matthew Treinish2324e6b2013-10-21 20:25:17 +0000181from tempest.services.volume.json.extensions_client import \
182 ExtensionsClientJSON as VolumeExtensionClientJSON
Attila Fazekas6968dd52013-02-15 17:05:53 +0100183from tempest.services.volume.json.snapshots_client import SnapshotsClientJSON
184from tempest.services.volume.json.volumes_client import VolumesClientJSON
Zhi Kun Liu53395522014-07-18 16:05:52 +0800185from tempest.services.volume.v2.json.availability_zone_client import \
186 VolumeV2AvailabilityZoneClientJSON
187from tempest.services.volume.v2.json.extensions_client import \
188 ExtensionsV2ClientJSON as VolumeV2ExtensionClientJSON
Zhi Kun Liu8cc3c842014-01-07 10:44:34 +0800189from tempest.services.volume.v2.json.volumes_client import VolumesV2ClientJSON
Zhi Kun Liu53395522014-07-18 16:05:52 +0800190from tempest.services.volume.v2.xml.availability_zone_client import \
191 VolumeV2AvailabilityZoneClientXML
192from tempest.services.volume.v2.xml.extensions_client import \
193 ExtensionsV2ClientXML as VolumeV2ExtensionClientXML
Zhi Kun Liu8cc3c842014-01-07 10:44:34 +0800194from tempest.services.volume.v2.xml.volumes_client import VolumesV2ClientXML
Nayna Patel4a5024c2013-11-18 07:08:23 +0000195from tempest.services.volume.xml.admin.volume_hosts_client import \
196 VolumeHostsClientXML
Sylvain Baubeaufdd34592014-02-20 18:40:10 +0100197from tempest.services.volume.xml.admin.volume_quotas_client import \
198 VolumeQuotasClientXML
Abhijeet.Jain0056b072014-04-15 09:32:29 +0530199from tempest.services.volume.xml.admin.volume_services_client import \
200 VolumesServicesClientXML
Attila Fazekas6968dd52013-02-15 17:05:53 +0100201from tempest.services.volume.xml.admin.volume_types_client import \
202 VolumeTypesClientXML
Abhijeet.Jain6109bb82014-05-01 10:29:15 +0530203from tempest.services.volume.xml.availability_zone_client import \
204 VolumeAvailabilityZoneClientXML
Giulio Fidente74b08ad2014-01-18 04:02:51 +0100205from tempest.services.volume.xml.backups_client import BackupsClientXML
Matthew Treinish2324e6b2013-10-21 20:25:17 +0000206from tempest.services.volume.xml.extensions_client import \
207 ExtensionsClientXML as VolumeExtensionClientXML
Attila Fazekas6968dd52013-02-15 17:05:53 +0100208from tempest.services.volume.xml.snapshots_client import SnapshotsClientXML
209from tempest.services.volume.xml.volumes_client import VolumesClientXML
Vincent Hou6b8a7b72012-08-25 01:24:33 +0800210
Sean Dague86bd8422013-12-20 09:56:44 -0500211CONF = config.CONF
Jay Pipes3f981df2012-03-27 18:59:44 -0400212LOG = logging.getLogger(__name__)
213
Vincent Hou6b8a7b72012-08-25 01:24:33 +0800214
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000215class Manager(manager.Manager):
Daryl Walleck1465d612011-11-02 02:22:15 -0500216
Jay Pipes3f981df2012-03-27 18:59:44 -0400217 """
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000218 Top level manager for OpenStack tempest clients
Jay Pipes3f981df2012-03-27 18:59:44 -0400219 """
220
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000221 def __init__(self, credentials=None, interface='json', service=None):
222 # Set interface and client type first
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000223 self.interface = interface
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000224 self.client_type = 'tempest'
225 # super cares for credentials validation
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000226 super(Manager, self).__init__(credentials=credentials)
Brant Knudsonc7ca3342013-03-28 21:08:50 -0500227
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000228 if self.interface == 'xml':
229 self.certificates_client = CertificatesClientXML(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000230 self.auth_provider)
231 self.servers_client = ServersClientXML(self.auth_provider)
232 self.limits_client = LimitsClientXML(self.auth_provider)
233 self.images_client = ImagesClientXML(self.auth_provider)
234 self.keypairs_client = KeyPairsClientXML(self.auth_provider)
235 self.quotas_client = QuotasClientXML(self.auth_provider)
Matt Riedemann848805f2014-06-16 13:23:51 -0700236 self.quota_classes_client = QuotaClassesClientXML(
237 self.auth_provider)
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000238 self.flavors_client = FlavorsClientXML(self.auth_provider)
239 self.extensions_client = ExtensionsClientXML(self.auth_provider)
Attila Fazekas7e678de2013-07-13 14:13:28 +0200240 self.volumes_extensions_client = VolumesExtensionsClientXML(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000241 self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000242 self.floating_ips_client = FloatingIPsClientXML(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000243 self.auth_provider)
244 self.backups_client = BackupsClientXML(self.auth_provider)
245 self.snapshots_client = SnapshotsClientXML(self.auth_provider)
246 self.volumes_client = VolumesClientXML(self.auth_provider)
247 self.volumes_v2_client = VolumesV2ClientXML(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000248 self.volume_types_client = VolumeTypesClientXML(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000249 self.auth_provider)
250 self.identity_client = IdentityClientXML(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000251 self.identity_v3_client = IdentityV3ClientXML(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000252 self.auth_provider)
Attila Fazekas7e678de2013-07-13 14:13:28 +0200253 self.security_groups_client = SecurityGroupsClientXML(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000254 self.auth_provider)
255 self.interfaces_client = InterfacesClientXML(self.auth_provider)
256 self.endpoints_client = EndPointClientXML(self.auth_provider)
257 self.fixed_ips_client = FixedIPsClientXML(self.auth_provider)
Attila Fazekas7e678de2013-07-13 14:13:28 +0200258 self.availability_zone_client = AvailabilityZoneClientXML(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000259 self.auth_provider)
260 self.service_client = ServiceClientXML(self.auth_provider)
Abhijeet.Jain0056b072014-04-15 09:32:29 +0530261 self.volume_services_client = VolumesServicesClientXML(
262 self.auth_provider)
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000263 self.aggregates_client = AggregatesClientXML(self.auth_provider)
264 self.services_client = ServicesClientXML(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000265 self.tenant_usages_client = TenantUsagesClientXML(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000266 self.auth_provider)
267 self.policy_client = PolicyClientXML(self.auth_provider)
ravikumar-venkatesan3052e942014-05-12 18:25:17 +0000268 self.region_client = RegionClientXML(self.auth_provider)
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000269 self.hosts_client = HostsClientXML(self.auth_provider)
270 self.hypervisor_client = HypervisorClientXML(self.auth_provider)
271 self.network_client = NetworkClientXML(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000272 self.credentials_client = CredentialsClientXML(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000273 self.auth_provider)
ivan-zhuef7a1bd2013-10-22 17:56:46 +0800274 self.instance_usages_audit_log_client = \
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000275 InstanceUsagesAuditLogClientXML(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000276 self.volume_hosts_client = VolumeHostsClientXML(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000277 self.auth_provider)
Sylvain Baubeaufdd34592014-02-20 18:40:10 +0100278 self.volume_quotas_client = VolumeQuotasClientXML(
279 self.auth_provider)
Matthew Treinish2324e6b2013-10-21 20:25:17 +0000280 self.volumes_extension_client = VolumeExtensionClientXML(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000281 self.auth_provider)
Zhi Kun Liu53395522014-07-18 16:05:52 +0800282 self.volumes_v2_extension_client = VolumeV2ExtensionClientXML(
283 self.auth_provider)
Nikolay Pliashechnikovb053aab2013-11-05 06:06:44 -0800284 if CONF.service_available.ceilometer:
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000285 self.telemetry_client = TelemetryClientXML(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000286 self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000287 self.token_client = TokenClientXML()
288 self.token_v3_client = V3TokenClientXML()
Abhijeet.Jain6109bb82014-05-01 10:29:15 +0530289 self.volume_availability_zone_client = \
290 VolumeAvailabilityZoneClientXML(self.auth_provider)
Zhi Kun Liu53395522014-07-18 16:05:52 +0800291 self.volume_v2_availability_zone_client = \
292 VolumeV2AvailabilityZoneClientXML(self.auth_provider)
Brant Knudsonc7ca3342013-03-28 21:08:50 -0500293
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000294 elif self.interface == 'json':
295 self.certificates_client = CertificatesClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000296 self.auth_provider)
ivan-zhu0e062922013-12-17 16:14:12 +0800297 self.certificates_v3_client = CertificatesV3ClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000298 self.auth_provider)
299 self.baremetal_client = BaremetalClientJSON(self.auth_provider)
300 self.servers_client = ServersClientJSON(self.auth_provider)
301 self.servers_v3_client = ServersV3ClientJSON(self.auth_provider)
302 self.limits_client = LimitsClientJSON(self.auth_provider)
303 self.images_client = ImagesClientJSON(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.keypairs_client = KeyPairsClientJSON(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000307 self.keypairs_v3_client = KeyPairsV3ClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000308 self.auth_provider)
309 self.quotas_client = QuotasClientJSON(self.auth_provider)
Matt Riedemann848805f2014-06-16 13:23:51 -0700310 self.quota_classes_client = QuotaClassesClientJSON(
311 self.auth_provider)
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000312 self.quotas_v3_client = QuotasV3ClientJSON(self.auth_provider)
313 self.flavors_client = FlavorsClientJSON(self.auth_provider)
314 self.flavors_v3_client = FlavorsV3ClientJSON(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000315 self.extensions_v3_client = ExtensionsV3ClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000316 self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000317 self.extensions_client = ExtensionsClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000318 self.auth_provider)
Attila Fazekas7e678de2013-07-13 14:13:28 +0200319 self.volumes_extensions_client = VolumesExtensionsClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000320 self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000321 self.floating_ips_client = FloatingIPsClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000322 self.auth_provider)
323 self.backups_client = BackupsClientJSON(self.auth_provider)
324 self.snapshots_client = SnapshotsClientJSON(self.auth_provider)
325 self.volumes_client = VolumesClientJSON(self.auth_provider)
326 self.volumes_v2_client = VolumesV2ClientJSON(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000327 self.volume_types_client = VolumeTypesClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000328 self.auth_provider)
329 self.identity_client = IdentityClientJSON(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000330 self.identity_v3_client = IdentityV3ClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000331 self.auth_provider)
Attila Fazekas7e678de2013-07-13 14:13:28 +0200332 self.security_groups_client = SecurityGroupsClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000333 self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000334 self.interfaces_v3_client = InterfacesV3ClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000335 self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000336 self.interfaces_client = InterfacesClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000337 self.auth_provider)
338 self.endpoints_client = EndPointClientJSON(self.auth_provider)
339 self.fixed_ips_client = FixedIPsClientJSON(self.auth_provider)
ivan-zhuac7b3802013-08-21 16:03:53 +0800340 self.availability_zone_v3_client = AvailabilityZoneV3ClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000341 self.auth_provider)
Attila Fazekas7e678de2013-07-13 14:13:28 +0200342 self.availability_zone_client = AvailabilityZoneClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000343 self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000344 self.services_v3_client = ServicesV3ClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000345 self.auth_provider)
346 self.service_client = ServiceClientJSON(self.auth_provider)
Abhijeet.Jain0056b072014-04-15 09:32:29 +0530347 self.volume_services_client = VolumesServicesClientJSON(
348 self.auth_provider)
YuikoTakada8a2ec112014-02-18 21:13:51 +0000349 self.agents_v3_client = AgentsV3ClientJSON(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000350 self.aggregates_v3_client = AggregatesV3ClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000351 self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000352 self.aggregates_client = AggregatesClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000353 self.auth_provider)
354 self.services_client = ServicesClientJSON(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000355 self.tenant_usages_client = TenantUsagesClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000356 self.auth_provider)
357 self.version_v3_client = VersionV3ClientJSON(self.auth_provider)
Ken'ichi Ohmichi8f088c12014-03-28 15:16:11 +0900358 self.migrations_v3_client = MigrationsV3ClientJSON(
359 self.auth_provider)
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000360 self.policy_client = PolicyClientJSON(self.auth_provider)
ravikumar-venkatesan3052e942014-05-12 18:25:17 +0000361 self.region_client = RegionClientJSON(self.auth_provider)
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000362 self.hosts_client = HostsClientJSON(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000363 self.hypervisor_v3_client = HypervisorV3ClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000364 self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000365 self.hypervisor_client = HypervisorClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000366 self.auth_provider)
367 self.network_client = NetworkClientJSON(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000368 self.credentials_client = CredentialsClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000369 self.auth_provider)
ivan-zhuef7a1bd2013-10-22 17:56:46 +0800370 self.instance_usages_audit_log_client = \
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000371 InstanceUsagesAuditLogClientJSON(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000372 self.volume_hosts_client = VolumeHostsClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000373 self.auth_provider)
Sylvain Baubeaufdd34592014-02-20 18:40:10 +0100374 self.volume_quotas_client = VolumeQuotasClientJSON(
375 self.auth_provider)
Matthew Treinish2324e6b2013-10-21 20:25:17 +0000376 self.volumes_extension_client = VolumeExtensionClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000377 self.auth_provider)
Zhi Kun Liu53395522014-07-18 16:05:52 +0800378 self.volumes_v2_extension_client = VolumeV2ExtensionClientJSON(
379 self.auth_provider)
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000380 self.hosts_v3_client = HostsV3ClientJSON(self.auth_provider)
Nikhil Manchandadd6886f2014-03-03 01:58:45 -0800381 self.database_flavors_client = DatabaseFlavorsClientJSON(
382 self.auth_provider)
Peter Stachowski320f9c72014-04-21 16:13:23 -0400383 self.database_versions_client = DatabaseVersionsClientJSON(
384 self.auth_provider)
Malini Kamalambal6e7b3b82014-02-06 06:49:04 -0500385 self.queuing_client = QueuingClientJSON(self.auth_provider)
Nikolay Pliashechnikovb053aab2013-11-05 06:06:44 -0800386 if CONF.service_available.ceilometer:
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000387 self.telemetry_client = TelemetryClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000388 self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000389 self.token_client = TokenClientJSON()
390 self.token_v3_client = V3TokenClientJSON()
Matthew Treinish5c660ab2014-05-18 21:14:36 -0400391 self.negative_client = rest_client.NegativeRestClient(
392 self.auth_provider)
Marc Koderer24eb89c2014-01-31 11:23:33 +0100393 self.negative_client.service = service
Abhijeet.Jain6109bb82014-05-01 10:29:15 +0530394 self.volume_availability_zone_client = \
395 VolumeAvailabilityZoneClientJSON(self.auth_provider)
Zhi Kun Liu53395522014-07-18 16:05:52 +0800396 self.volume_v2_availability_zone_client = \
397 VolumeV2AvailabilityZoneClientJSON(self.auth_provider)
Attila Fazekas7e678de2013-07-13 14:13:28 +0200398
Attila Fazekas7e678de2013-07-13 14:13:28 +0200399 else:
Dan Smithcf8fab62012-08-14 08:03:48 -0700400 msg = "Unsupported interface type `%s'" % interface
401 raise exceptions.InvalidConfiguration(msg)
Attila Fazekas7e678de2013-07-13 14:13:28 +0200402
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000403 # TODO(andreaf) EC2 client still do their auth, v2 only
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000404 ec2_client_args = (self.credentials.username,
405 self.credentials.password,
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000406 CONF.identity.uri,
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000407 self.credentials.tenant_name)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000408
Attila Fazekas7e678de2013-07-13 14:13:28 +0200409 # common clients
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000410 self.account_client = AccountClient(self.auth_provider)
Yuiko Takada420f2eb2014-04-02 19:53:38 +0900411 self.agents_client = AgentsClientJSON(self.auth_provider)
Sean Dague86bd8422013-12-20 09:56:44 -0500412 if CONF.service_available.glance:
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000413 self.image_client = ImageClientJSON(self.auth_provider)
414 self.image_client_v2 = ImageClientV2JSON(self.auth_provider)
415 self.container_client = ContainerClient(self.auth_provider)
416 self.object_client = ObjectClient(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000417 self.orchestration_client = OrchestrationClient(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000418 self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000419 self.ec2api_client = botoclients.APIClientEC2(*ec2_client_args)
420 self.s3_client = botoclients.ObjectClientS3(*ec2_client_args)
421 self.custom_object_client = ObjectClientCustomizedHeader(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000422 self.auth_provider)
harika-vakadi2daed0a2013-01-01 20:51:39 +0530423 self.custom_account_client = \
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000424 AccountClientCustomizedHeader(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000425 self.data_processing_client = DataProcessingClient(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000426 self.auth_provider)
Ken'ichi Ohmichi2fdc1822014-03-18 09:10:57 +0900427 self.migrations_client = MigrationsClientJSON(self.auth_provider)
Ghanshyam9d9201d2014-04-16 19:28:09 +0900428 self.security_group_default_rules_client = (
429 SecurityGroupDefaultRulesClientJSON(self.auth_provider))
Andrea Frittolie258cd72014-07-17 04:47:26 +0100430 self.networks_client = NetworksClientJSON(self.auth_provider)
Jay Pipes50677282012-01-06 15:39:20 -0500431
432
Jay Pipesff10d552012-04-06 14:18:50 -0400433class AltManager(Manager):
434
435 """
436 Manager object that uses the alt_XXX credentials for its
437 managed client objects
438 """
439
Marc Koderer24eb89c2014-01-31 11:23:33 +0100440 def __init__(self, interface='json', service=None):
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000441 super(AltManager, self).__init__(
442 credentials=auth.get_default_credentials('alt_user'),
443 interface=interface,
444 service=service)
Jay Pipesff10d552012-04-06 14:18:50 -0400445
446
447class AdminManager(Manager):
448
449 """
Attila Fazekascadcb1f2013-01-21 23:10:53 +0100450 Manager object that uses the admin credentials for its
Jay Pipesff10d552012-04-06 14:18:50 -0400451 managed client objects
452 """
453
Marc Koderer24eb89c2014-01-31 11:23:33 +0100454 def __init__(self, interface='json', service=None):
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000455 super(AdminManager, self).__init__(
456 credentials=auth.get_default_credentials('identity_admin'),
457 interface=interface,
458 service=service)
Jay Pipesff10d552012-04-06 14:18:50 -0400459
460
Attila Fazekascadcb1f2013-01-21 23:10:53 +0100461class ComputeAdminManager(Manager):
462
463 """
464 Manager object that uses the compute_admin credentials for its
465 managed client objects
466 """
467
Marc Koderer24eb89c2014-01-31 11:23:33 +0100468 def __init__(self, interface='json', service=None):
Attila Fazekascadcb1f2013-01-21 23:10:53 +0100469 base = super(ComputeAdminManager, self)
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000470 base.__init__(
471 credentials=auth.get_default_credentials('compute_admin'),
472 interface=interface,
473 service=service)
Steve Bakerc60e4e32013-05-06 15:22:41 +1200474
475
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000476class OfficialClientManager(manager.Manager):
477 """
478 Manager that provides access to the official python clients for
479 calling various OpenStack APIs.
480 """
481
482 NOVACLIENT_VERSION = '2'
483 CINDERCLIENT_VERSION = '1'
484 HEATCLIENT_VERSION = '1'
Adam Gandelman4a48a602014-03-20 18:23:18 -0700485 IRONICCLIENT_VERSION = '1'
Sergey Lukjanov7409e2e2014-03-27 12:55:50 +0400486 SAHARACLIENT_VERSION = '1.1'
Artur Svechnikovc3bf9252014-05-05 16:37:37 +0400487 CEILOMETERCLIENT_VERSION = '2'
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000488
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000489 def __init__(self, credentials):
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000490 # FIXME(andreaf) Auth provider for client_type 'official' is
491 # not implemented yet, setting to 'tempest' for now.
492 self.client_type = 'tempest'
493 self.interface = None
494 # super cares for credentials validation
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000495 super(OfficialClientManager, self).__init__(credentials=credentials)
Adam Gandelman4a48a602014-03-20 18:23:18 -0700496 self.baremetal_client = self._get_baremetal_client()
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000497 self.compute_client = self._get_compute_client(credentials)
498 self.identity_client = self._get_identity_client(credentials)
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000499 self.image_client = self._get_image_client()
500 self.network_client = self._get_network_client()
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000501 self.volume_client = self._get_volume_client(credentials)
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000502 self.object_storage_client = self._get_object_storage_client(
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000503 credentials)
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000504 self.orchestration_client = self._get_orchestration_client(
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000505 credentials)
Sergey Lukjanov7409e2e2014-03-27 12:55:50 +0400506 self.data_processing_client = self._get_data_processing_client(
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000507 credentials)
Artur Svechnikovc3bf9252014-05-05 16:37:37 +0400508 self.ceilometer_client = self._get_ceilometer_client(
509 credentials)
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000510
Adam Gandelman4a48a602014-03-20 18:23:18 -0700511 def _get_roles(self):
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000512 admin_credentials = auth.get_default_credentials('identity_admin')
513 keystone_admin = self._get_identity_client(admin_credentials)
Adam Gandelman4a48a602014-03-20 18:23:18 -0700514
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000515 username = self.credentials.username
516 tenant_name = self.credentials.tenant_name
Adam Gandelman4a48a602014-03-20 18:23:18 -0700517 user_id = keystone_admin.users.find(name=username).id
518 tenant_id = keystone_admin.tenants.find(name=tenant_name).id
519
520 roles = keystone_admin.roles.roles_for_user(
521 user=user_id, tenant=tenant_id)
522
523 return [r.name for r in roles]
524
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000525 def _get_compute_client(self, credentials):
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000526 # Novaclient will not execute operations for anyone but the
527 # identified user, so a new client needs to be created for
528 # each user that operations need to be performed for.
Zhi Kun Liufaa6b5f2014-04-14 01:38:16 -0500529 if not CONF.service_available.nova:
530 return None
531 import novaclient.client
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000532
533 auth_url = CONF.identity.uri
534 dscv = CONF.identity.disable_ssl_certificate_validation
535 region = CONF.identity.region
536
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000537 client_args = (credentials.username, credentials.password,
538 credentials.tenant_name, auth_url)
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000539
540 # Create our default Nova client to use in testing
541 service_type = CONF.compute.catalog_type
542 endpoint_type = CONF.compute.endpoint_type
543 return novaclient.client.Client(self.NOVACLIENT_VERSION,
544 *client_args,
545 service_type=service_type,
546 endpoint_type=endpoint_type,
547 region_name=region,
548 no_cache=True,
549 insecure=dscv,
550 http_log_debug=True)
551
552 def _get_image_client(self):
Zhi Kun Liufaa6b5f2014-04-14 01:38:16 -0500553 if not CONF.service_available.glance:
554 return None
555 import glanceclient
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000556 token = self.identity_client.auth_token
557 region = CONF.identity.region
558 endpoint_type = CONF.image.endpoint_type
559 endpoint = self.identity_client.service_catalog.url_for(
560 attr='region', filter_value=region,
561 service_type=CONF.image.catalog_type, endpoint_type=endpoint_type)
562 dscv = CONF.identity.disable_ssl_certificate_validation
563 return glanceclient.Client('1', endpoint=endpoint, token=token,
564 insecure=dscv)
565
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000566 def _get_volume_client(self, credentials):
Zhi Kun Liufaa6b5f2014-04-14 01:38:16 -0500567 if not CONF.service_available.cinder:
568 return None
569 import cinderclient.client
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000570 auth_url = CONF.identity.uri
571 region = CONF.identity.region
572 endpoint_type = CONF.volume.endpoint_type
Rob Crittenden1aba5d02014-03-25 23:27:09 -0400573 dscv = CONF.identity.disable_ssl_certificate_validation
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000574 return cinderclient.client.Client(self.CINDERCLIENT_VERSION,
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000575 credentials.username,
576 credentials.password,
577 credentials.tenant_name,
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000578 auth_url,
579 region_name=region,
580 endpoint_type=endpoint_type,
Rob Crittenden1aba5d02014-03-25 23:27:09 -0400581 insecure=dscv,
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000582 http_log_debug=True)
583
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000584 def _get_object_storage_client(self, credentials):
Zhi Kun Liufaa6b5f2014-04-14 01:38:16 -0500585 if not CONF.service_available.swift:
586 return None
587 import swiftclient
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000588 auth_url = CONF.identity.uri
589 # add current tenant to swift operator role group.
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000590 admin_credentials = auth.get_default_credentials('identity_admin')
591 keystone_admin = self._get_identity_client(admin_credentials)
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000592
593 # enable test user to operate swift by adding operator role to him.
594 roles = keystone_admin.roles.list()
595 operator_role = CONF.object_storage.operator_role
596 member_role = [role for role in roles if role.name == operator_role][0]
597 # NOTE(maurosr): This is surrounded in the try-except block cause
598 # neutron tests doesn't have tenant isolation.
599 try:
600 keystone_admin.roles.add_user_role(self.identity_client.user_id,
601 member_role.id,
602 self.identity_client.tenant_id)
603 except keystoneclient.exceptions.Conflict:
604 pass
605
606 endpoint_type = CONF.object_storage.endpoint_type
607 os_options = {'endpoint_type': endpoint_type}
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000608 return swiftclient.Connection(auth_url, credentials.username,
609 credentials.password,
610 tenant_name=credentials.tenant_name,
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000611 auth_version='2',
612 os_options=os_options)
613
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000614 def _get_orchestration_client(self, credentials):
Zhi Kun Liufaa6b5f2014-04-14 01:38:16 -0500615 if not CONF.service_available.heat:
616 return None
617 import heatclient.client
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000618
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000619 keystone = self._get_identity_client(credentials)
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000620 region = CONF.identity.region
621 endpoint_type = CONF.orchestration.endpoint_type
622 token = keystone.auth_token
623 service_type = CONF.orchestration.catalog_type
624 try:
625 endpoint = keystone.service_catalog.url_for(
626 attr='region',
627 filter_value=region,
628 service_type=service_type,
629 endpoint_type=endpoint_type)
630 except keystoneclient.exceptions.EndpointNotFound:
631 return None
632 else:
633 return heatclient.client.Client(self.HEATCLIENT_VERSION,
634 endpoint,
635 token=token,
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000636 username=credentials.username,
637 password=credentials.password)
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000638
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000639 def _get_identity_client(self, credentials):
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000640 # This identity client is not intended to check the security
641 # of the identity service, so use admin credentials by default.
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000642
643 auth_url = CONF.identity.uri
644 dscv = CONF.identity.disable_ssl_certificate_validation
645
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000646 return keystoneclient.v2_0.client.Client(
647 username=credentials.username,
648 password=credentials.password,
649 tenant_name=credentials.tenant_name,
650 auth_url=auth_url,
651 insecure=dscv)
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000652
Adam Gandelman4a48a602014-03-20 18:23:18 -0700653 def _get_baremetal_client(self):
654 # ironic client is currently intended to by used by admin users
Zhi Kun Liufaa6b5f2014-04-14 01:38:16 -0500655 if not CONF.service_available.ironic:
656 return None
657 import ironicclient.client
Adam Gandelman4a48a602014-03-20 18:23:18 -0700658 roles = self._get_roles()
659 if CONF.identity.admin_role not in roles:
660 return None
661
662 auth_url = CONF.identity.uri
663 api_version = self.IRONICCLIENT_VERSION
664 insecure = CONF.identity.disable_ssl_certificate_validation
665 service_type = CONF.baremetal.catalog_type
666 endpoint_type = CONF.baremetal.endpoint_type
667 creds = {
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000668 'os_username': self.credentials.username,
669 'os_password': self.credentials.password,
670 'os_tenant_name': self.credentials.tenant_name
Adam Gandelman4a48a602014-03-20 18:23:18 -0700671 }
672
673 try:
674 return ironicclient.client.get_client(
675 api_version=api_version,
676 os_auth_url=auth_url,
677 insecure=insecure,
678 os_service_type=service_type,
679 os_endpoint_type=endpoint_type,
680 **creds)
681 except keystoneclient.exceptions.EndpointNotFound:
682 return None
683
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000684 def _get_network_client(self):
685 # The intended configuration is for the network client to have
686 # admin privileges and indicate for whom resources are being
687 # created via a 'tenant_id' parameter. This will often be
688 # preferable to authenticating as a specific user because
689 # working with certain resources (public routers and networks)
690 # often requires admin privileges anyway.
Zhi Kun Liufaa6b5f2014-04-14 01:38:16 -0500691 if not CONF.service_available.neutron:
692 return None
693 import neutronclient.v2_0.client
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000694
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000695 credentials = auth.get_default_credentials('identity_admin')
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000696
697 auth_url = CONF.identity.uri
698 dscv = CONF.identity.disable_ssl_certificate_validation
699 endpoint_type = CONF.network.endpoint_type
700
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000701 return neutronclient.v2_0.client.Client(
702 username=credentials.username,
703 password=credentials.password,
704 tenant_name=credentials.tenant_name,
705 endpoint_type=endpoint_type,
706 auth_url=auth_url,
707 insecure=dscv)
Sergey Lukjanov7409e2e2014-03-27 12:55:50 +0400708
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000709 def _get_data_processing_client(self, credentials):
Sergey Lukjanov7409e2e2014-03-27 12:55:50 +0400710 if not CONF.service_available.sahara:
711 # Sahara isn't available
712 return None
713
714 import saharaclient.client
715
Sergey Lukjanov7409e2e2014-03-27 12:55:50 +0400716 endpoint_type = CONF.data_processing.endpoint_type
717 catalog_type = CONF.data_processing.catalog_type
718 auth_url = CONF.identity.uri
719
Andrea Frittoli422fbdf2014-03-20 10:05:18 +0000720 client = saharaclient.client.Client(
721 self.SAHARACLIENT_VERSION,
722 credentials.username,
723 credentials.password,
724 project_name=credentials.tenant_name,
725 endpoint_type=endpoint_type,
726 service_type=catalog_type,
727 auth_url=auth_url)
Sergey Lukjanov7409e2e2014-03-27 12:55:50 +0400728
729 return client
Artur Svechnikovc3bf9252014-05-05 16:37:37 +0400730
731 def _get_ceilometer_client(self, credentials):
732 if not CONF.service_available.ceilometer:
733 return None
734
735 import ceilometerclient.client
736
737 keystone = self._get_identity_client(credentials)
738 region = CONF.identity.region
739
740 endpoint_type = CONF.telemetry.endpoint_type
741 service_type = CONF.telemetry.catalog_type
742 auth_url = CONF.identity.uri
743
744 try:
745 keystone.service_catalog.url_for(
746 attr='region',
747 filter_value=region,
748 service_type=service_type,
749 endpoint_type=endpoint_type)
750 except keystoneclient.exceptions.EndpointNotFound:
751 return None
752 else:
753 return ceilometerclient.client.get_client(
754 self.CEILOMETERCLIENT_VERSION,
755 os_username=credentials.username,
756 os_password=credentials.password,
757 os_tenant_name=credentials.tenant_name,
758 os_auth_url=auth_url,
759 os_service_type=service_type,
760 os_endpoint_type=endpoint_type)