blob: 4c4dcf4dc46858137874a7822614d80923f7225c [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 +000016# Default client libs
17import cinderclient.client
18import glanceclient
19import heatclient.client
20import keystoneclient.exceptions
21import keystoneclient.v2_0.client
22import neutronclient.v2_0.client
23import novaclient.client
24import swiftclient
25
Marc Koderer24eb89c2014-01-31 11:23:33 +010026from tempest.common.rest_client import NegativeRestClient
Jay Pipesf38eaac2012-06-21 13:37:35 -040027from tempest import config
Daryl Walleck587385b2012-03-03 13:00:26 -060028from tempest import exceptions
Andrea Frittolif9cde7e2014-02-18 09:57:04 +000029from tempest import manager
Matthew Treinishf4a9b0f2013-07-26 16:58:26 -040030from tempest.openstack.common import log as logging
Roman Prykhodchenko62b1ed12013-10-16 21:51:47 +030031from tempest.services.baremetal.v1.client_json import BaremetalClientJSON
Attila Fazekas1aed6202013-02-11 14:47:45 +010032from tempest.services import botoclients
Mitsuhiko Yamazaki74f07072013-04-02 11:52:31 +090033from tempest.services.compute.json.aggregates_client import \
34 AggregatesClientJSON
Leo Toyodaa5278912013-04-16 15:40:12 +090035from tempest.services.compute.json.availability_zone_client import \
36 AvailabilityZoneClientJSON
ivan-zhud57f3cf2013-11-06 16:59:52 +080037from tempest.services.compute.json.certificates_client import \
38 CertificatesClientJSON
dwallecke62b9f02012-10-10 23:34:42 -050039from tempest.services.compute.json.extensions_client import \
harika-vakadi1a9ad612012-12-14 19:12:08 +053040 ExtensionsClientJSON
Sean Dague2416cf32013-04-10 08:29:07 -040041from tempest.services.compute.json.fixed_ips_client import FixedIPsClientJSON
dwallecke62b9f02012-10-10 23:34:42 -050042from tempest.services.compute.json.flavors_client import FlavorsClientJSON
43from tempest.services.compute.json.floating_ips_client import \
harika-vakadi1a9ad612012-12-14 19:12:08 +053044 FloatingIPsClientJSON
Attila Fazekas8e99b992013-02-24 09:53:23 +010045from tempest.services.compute.json.hosts_client import HostsClientJSON
Tony Yang3d5f1632013-06-06 14:17:57 +080046from tempest.services.compute.json.hypervisor_client import \
47 HypervisorClientJSON
dwallecke62b9f02012-10-10 23:34:42 -050048from tempest.services.compute.json.images_client import ImagesClientJSON
ivan-zhuef7a1bd2013-10-22 17:56:46 +080049from tempest.services.compute.json.instance_usage_audit_log_client import \
50 InstanceUsagesAuditLogClientJSON
Sean Dague2416cf32013-04-10 08:29:07 -040051from tempest.services.compute.json.interfaces_client import \
52 InterfacesClientJSON
Attila Fazekas6968dd52013-02-15 17:05:53 +010053from tempest.services.compute.json.keypairs_client import KeyPairsClientJSON
dwallecke62b9f02012-10-10 23:34:42 -050054from tempest.services.compute.json.limits_client import LimitsClientJSON
Attila Fazekas6968dd52013-02-15 17:05:53 +010055from tempest.services.compute.json.quotas_client import QuotasClientJSON
Matthew Treinisha83a16e2012-12-07 13:44:02 -050056from tempest.services.compute.json.security_groups_client import \
harika-vakadi1a9ad612012-12-14 19:12:08 +053057 SecurityGroupsClientJSON
Attila Fazekas6968dd52013-02-15 17:05:53 +010058from tempest.services.compute.json.servers_client import ServersClientJSON
Leo Toyoda3ae31e12013-04-19 11:19:57 +090059from tempest.services.compute.json.services_client import ServicesClientJSON
Leo Toyodad80b6a02013-05-08 12:15:13 +090060from tempest.services.compute.json.tenant_usages_client import \
61 TenantUsagesClientJSON
Matthew Treinisha83a16e2012-12-07 13:44:02 -050062from tempest.services.compute.json.volumes_extensions_client import \
harika-vakadi1a9ad612012-12-14 19:12:08 +053063 VolumesExtensionsClientJSON
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
ivan-zhub6d69ee2013-12-17 14:16:31 +080080from tempest.services.compute.v3.json.quotas_client import \
81 QuotasV3ClientJSON
ivan-zhu8f992be2013-07-31 14:56:58 +080082from tempest.services.compute.v3.json.servers_client import \
83 ServersV3ClientJSON
ivan-zhu5c86ae62013-08-20 21:09:01 +080084from tempest.services.compute.v3.json.services_client import \
85 ServicesV3ClientJSON
Ken'ichi Ohmichi3d6b6fa2014-01-08 04:42:16 +090086from tempest.services.compute.v3.json.version_client import \
87 VersionV3ClientJSON
Mitsuhiko Yamazakiae8fc532013-04-22 11:17:35 +090088from tempest.services.compute.xml.aggregates_client import AggregatesClientXML
Leo Toyodaa5278912013-04-16 15:40:12 +090089from tempest.services.compute.xml.availability_zone_client import \
90 AvailabilityZoneClientXML
ivan-zhud57f3cf2013-11-06 16:59:52 +080091from tempest.services.compute.xml.certificates_client import \
92 CertificatesClientXML
dwallecke62b9f02012-10-10 23:34:42 -050093from tempest.services.compute.xml.extensions_client import ExtensionsClientXML
Sean Dague2416cf32013-04-10 08:29:07 -040094from tempest.services.compute.xml.fixed_ips_client import FixedIPsClientXML
dwallecke62b9f02012-10-10 23:34:42 -050095from tempest.services.compute.xml.flavors_client import FlavorsClientXML
96from tempest.services.compute.xml.floating_ips_client import \
harika-vakadi1a9ad612012-12-14 19:12:08 +053097 FloatingIPsClientXML
Ken'ichi Ohmichia1aa44c2013-12-06 20:48:24 +090098from tempest.services.compute.xml.hosts_client import HostsClientXML
Tony Yang3d5f1632013-06-06 14:17:57 +080099from tempest.services.compute.xml.hypervisor_client import HypervisorClientXML
dwallecke62b9f02012-10-10 23:34:42 -0500100from tempest.services.compute.xml.images_client import ImagesClientXML
ivan-zhuef7a1bd2013-10-22 17:56:46 +0800101from tempest.services.compute.xml.instance_usage_audit_log_client import \
102 InstanceUsagesAuditLogClientXML
Sean Dague2416cf32013-04-10 08:29:07 -0400103from tempest.services.compute.xml.interfaces_client import \
104 InterfacesClientXML
dwallecke62b9f02012-10-10 23:34:42 -0500105from tempest.services.compute.xml.keypairs_client import KeyPairsClientXML
106from tempest.services.compute.xml.limits_client import LimitsClientXML
rajalakshmi-ganesan1982c3c2013-01-10 14:56:45 +0530107from tempest.services.compute.xml.quotas_client import QuotasClientXML
dwallecke62b9f02012-10-10 23:34:42 -0500108from tempest.services.compute.xml.security_groups_client \
harika-vakadi1a9ad612012-12-14 19:12:08 +0530109 import SecurityGroupsClientXML
dwallecke62b9f02012-10-10 23:34:42 -0500110from tempest.services.compute.xml.servers_client import ServersClientXML
Leo Toyoda3ae31e12013-04-19 11:19:57 +0900111from tempest.services.compute.xml.services_client import ServicesClientXML
Leo Toyodad80b6a02013-05-08 12:15:13 +0900112from tempest.services.compute.xml.tenant_usages_client import \
113 TenantUsagesClientXML
Matthew Treinisha83a16e2012-12-07 13:44:02 -0500114from tempest.services.compute.xml.volumes_extensions_client import \
harika-vakadi1a9ad612012-12-14 19:12:08 +0530115 VolumesExtensionsClientXML
Sergey Lukjanov3bc60e92013-12-10 16:40:50 +0400116from tempest.services.data_processing.v1_1.client import DataProcessingClient
Nikhil Manchandadd6886f2014-03-03 01:58:45 -0800117from tempest.services.database.json.flavors_client import \
118 DatabaseFlavorsClientJSON
Attila Fazekas407b6db2013-01-19 12:48:36 +0100119from tempest.services.identity.json.identity_client import IdentityClientJSON
120from tempest.services.identity.json.identity_client import TokenClientJSON
nayna-patel914b4712013-07-16 08:29:05 +0000121from tempest.services.identity.v3.json.credentials_client import \
122 CredentialsClientJSON
Sean Dague2416cf32013-04-10 08:29:07 -0400123from tempest.services.identity.v3.json.endpoints_client import \
124 EndPointClientJSON
rajalakshmi-ganesan7312bb52013-01-29 20:03:42 +0530125from tempest.services.identity.v3.json.identity_client import \
126 IdentityV3ClientJSON
nayna-patelb35f7232013-06-28 07:08:44 +0000127from tempest.services.identity.v3.json.identity_client import V3TokenClientJSON
harika-vakadi40e10112013-02-08 14:38:09 +0530128from tempest.services.identity.v3.json.policy_client import PolicyClientJSON
harika-vakadia92dd742013-02-19 20:41:22 +0530129from tempest.services.identity.v3.json.service_client import \
130 ServiceClientJSON
nayna-patel914b4712013-07-16 08:29:05 +0000131from tempest.services.identity.v3.xml.credentials_client import \
132 CredentialsClientXML
rajalakshmi-ganesanab426722013-02-08 15:49:15 +0530133from tempest.services.identity.v3.xml.endpoints_client import EndPointClientXML
rajalakshmi-ganesan7312bb52013-01-29 20:03:42 +0530134from tempest.services.identity.v3.xml.identity_client import \
135 IdentityV3ClientXML
nayna-patelb35f7232013-06-28 07:08:44 +0000136from tempest.services.identity.v3.xml.identity_client import V3TokenClientXML
harika-vakadi40e10112013-02-08 14:38:09 +0530137from tempest.services.identity.v3.xml.policy_client import PolicyClientXML
harika-vakadia92dd742013-02-19 20:41:22 +0530138from tempest.services.identity.v3.xml.service_client import \
139 ServiceClientXML
Attila Fazekas407b6db2013-01-19 12:48:36 +0100140from tempest.services.identity.xml.identity_client import IdentityClientXML
141from tempest.services.identity.xml.identity_client import TokenClientXML
Matthew Treinish6d59c992013-03-01 16:20:04 -0500142from tempest.services.image.v1.json.image_client import ImageClientJSON
Matthew Treinisha62347f2013-03-01 16:37:30 -0500143from tempest.services.image.v2.json.image_client import ImageClientV2JSON
raiesmh0867698322013-08-20 13:09:01 +0530144from tempest.services.network.json.network_client import NetworkClientJSON
145from tempest.services.network.xml.network_client import NetworkClientXML
dwalleck5d734432012-10-04 01:11:47 -0500146from tempest.services.object_storage.account_client import AccountClient
harika-vakadi2daed0a2013-01-01 20:51:39 +0530147from tempest.services.object_storage.account_client import \
148 AccountClientCustomizedHeader
Attila Fazekas6968dd52013-02-15 17:05:53 +0100149from tempest.services.object_storage.container_client import ContainerClient
150from tempest.services.object_storage.object_client import ObjectClient
151from tempest.services.object_storage.object_client import \
152 ObjectClientCustomizedHeader
Steve Bakerc60e4e32013-05-06 15:22:41 +1200153from tempest.services.orchestration.json.orchestration_client import \
154 OrchestrationClient
Malini Kamalambal6e7b3b82014-02-06 06:49:04 -0500155from tempest.services.queuing.json.queuing_client import QueuingClientJSON
Nikolay Pliashechnikovb053aab2013-11-05 06:06:44 -0800156from tempest.services.telemetry.json.telemetry_client import \
157 TelemetryClientJSON
158from tempest.services.telemetry.xml.telemetry_client import \
159 TelemetryClientXML
Nayna Patel4a5024c2013-11-18 07:08:23 +0000160from tempest.services.volume.json.admin.volume_hosts_client import \
161 VolumeHostsClientJSON
Attila Fazekas6968dd52013-02-15 17:05:53 +0100162from tempest.services.volume.json.admin.volume_types_client import \
163 VolumeTypesClientJSON
Giulio Fidente74b08ad2014-01-18 04:02:51 +0100164from tempest.services.volume.json.backups_client import BackupsClientJSON
Matthew Treinish2324e6b2013-10-21 20:25:17 +0000165from tempest.services.volume.json.extensions_client import \
166 ExtensionsClientJSON as VolumeExtensionClientJSON
Attila Fazekas6968dd52013-02-15 17:05:53 +0100167from tempest.services.volume.json.snapshots_client import SnapshotsClientJSON
168from tempest.services.volume.json.volumes_client import VolumesClientJSON
Zhi Kun Liu8cc3c842014-01-07 10:44:34 +0800169from tempest.services.volume.v2.json.volumes_client import VolumesV2ClientJSON
170from tempest.services.volume.v2.xml.volumes_client import VolumesV2ClientXML
Nayna Patel4a5024c2013-11-18 07:08:23 +0000171from tempest.services.volume.xml.admin.volume_hosts_client import \
172 VolumeHostsClientXML
Attila Fazekas6968dd52013-02-15 17:05:53 +0100173from tempest.services.volume.xml.admin.volume_types_client import \
174 VolumeTypesClientXML
Giulio Fidente74b08ad2014-01-18 04:02:51 +0100175from tempest.services.volume.xml.backups_client import BackupsClientXML
Matthew Treinish2324e6b2013-10-21 20:25:17 +0000176from tempest.services.volume.xml.extensions_client import \
177 ExtensionsClientXML as VolumeExtensionClientXML
Attila Fazekas6968dd52013-02-15 17:05:53 +0100178from tempest.services.volume.xml.snapshots_client import SnapshotsClientXML
179from tempest.services.volume.xml.volumes_client import VolumesClientXML
Vincent Hou6b8a7b72012-08-25 01:24:33 +0800180
Sean Dague86bd8422013-12-20 09:56:44 -0500181CONF = config.CONF
Jay Pipes3f981df2012-03-27 18:59:44 -0400182LOG = logging.getLogger(__name__)
183
Vincent Hou6b8a7b72012-08-25 01:24:33 +0800184
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000185class Manager(manager.Manager):
Daryl Walleck1465d612011-11-02 02:22:15 -0500186
Jay Pipes3f981df2012-03-27 18:59:44 -0400187 """
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000188 Top level manager for OpenStack tempest clients
Jay Pipes3f981df2012-03-27 18:59:44 -0400189 """
190
James E. Blaire6d8ee12013-01-18 21:33:45 +0000191 def __init__(self, username=None, password=None, tenant_name=None,
Marc Koderer24eb89c2014-01-31 11:23:33 +0100192 interface='json', service=None):
Jay Pipesff10d552012-04-06 14:18:50 -0400193 """
194 We allow overriding of the credentials used within the various
195 client classes managed by the Manager object. Left as None, the
196 standard username/password/tenant_name is used.
197
198 :param username: Override of the username
199 :param password: Override of the password
200 :param tenant_name: Override of the tenant name
201 """
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000202 self.interface = interface
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000203 self.client_type = 'tempest'
204 # super cares for credentials validation
205 super(Manager, self).__init__(
206 username=username, password=password, tenant_name=tenant_name)
Brant Knudsonc7ca3342013-03-28 21:08:50 -0500207
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000208 if self.interface == 'xml':
209 self.certificates_client = CertificatesClientXML(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000210 self.auth_provider)
211 self.servers_client = ServersClientXML(self.auth_provider)
212 self.limits_client = LimitsClientXML(self.auth_provider)
213 self.images_client = ImagesClientXML(self.auth_provider)
214 self.keypairs_client = KeyPairsClientXML(self.auth_provider)
215 self.quotas_client = QuotasClientXML(self.auth_provider)
216 self.flavors_client = FlavorsClientXML(self.auth_provider)
217 self.extensions_client = ExtensionsClientXML(self.auth_provider)
Attila Fazekas7e678de2013-07-13 14:13:28 +0200218 self.volumes_extensions_client = VolumesExtensionsClientXML(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000219 self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000220 self.floating_ips_client = FloatingIPsClientXML(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000221 self.auth_provider)
222 self.backups_client = BackupsClientXML(self.auth_provider)
223 self.snapshots_client = SnapshotsClientXML(self.auth_provider)
224 self.volumes_client = VolumesClientXML(self.auth_provider)
225 self.volumes_v2_client = VolumesV2ClientXML(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000226 self.volume_types_client = VolumeTypesClientXML(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000227 self.auth_provider)
228 self.identity_client = IdentityClientXML(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000229 self.identity_v3_client = IdentityV3ClientXML(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000230 self.auth_provider)
Attila Fazekas7e678de2013-07-13 14:13:28 +0200231 self.security_groups_client = SecurityGroupsClientXML(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000232 self.auth_provider)
233 self.interfaces_client = InterfacesClientXML(self.auth_provider)
234 self.endpoints_client = EndPointClientXML(self.auth_provider)
235 self.fixed_ips_client = FixedIPsClientXML(self.auth_provider)
Attila Fazekas7e678de2013-07-13 14:13:28 +0200236 self.availability_zone_client = AvailabilityZoneClientXML(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000237 self.auth_provider)
238 self.service_client = ServiceClientXML(self.auth_provider)
239 self.aggregates_client = AggregatesClientXML(self.auth_provider)
240 self.services_client = ServicesClientXML(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000241 self.tenant_usages_client = TenantUsagesClientXML(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000242 self.auth_provider)
243 self.policy_client = PolicyClientXML(self.auth_provider)
244 self.hosts_client = HostsClientXML(self.auth_provider)
245 self.hypervisor_client = HypervisorClientXML(self.auth_provider)
246 self.network_client = NetworkClientXML(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000247 self.credentials_client = CredentialsClientXML(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000248 self.auth_provider)
ivan-zhuef7a1bd2013-10-22 17:56:46 +0800249 self.instance_usages_audit_log_client = \
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000250 InstanceUsagesAuditLogClientXML(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000251 self.volume_hosts_client = VolumeHostsClientXML(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000252 self.auth_provider)
Matthew Treinish2324e6b2013-10-21 20:25:17 +0000253 self.volumes_extension_client = VolumeExtensionClientXML(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000254 self.auth_provider)
Nikolay Pliashechnikovb053aab2013-11-05 06:06:44 -0800255 if CONF.service_available.ceilometer:
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000256 self.telemetry_client = TelemetryClientXML(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000257 self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000258 self.token_client = TokenClientXML()
259 self.token_v3_client = V3TokenClientXML()
Brant Knudsonc7ca3342013-03-28 21:08:50 -0500260
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000261 elif self.interface == 'json':
262 self.certificates_client = CertificatesClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000263 self.auth_provider)
ivan-zhu0e062922013-12-17 16:14:12 +0800264 self.certificates_v3_client = CertificatesV3ClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000265 self.auth_provider)
266 self.baremetal_client = BaremetalClientJSON(self.auth_provider)
267 self.servers_client = ServersClientJSON(self.auth_provider)
268 self.servers_v3_client = ServersV3ClientJSON(self.auth_provider)
269 self.limits_client = LimitsClientJSON(self.auth_provider)
270 self.images_client = ImagesClientJSON(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000271 self.keypairs_v3_client = KeyPairsV3ClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000272 self.auth_provider)
273 self.keypairs_client = KeyPairsClientJSON(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000274 self.keypairs_v3_client = KeyPairsV3ClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000275 self.auth_provider)
276 self.quotas_client = QuotasClientJSON(self.auth_provider)
277 self.quotas_v3_client = QuotasV3ClientJSON(self.auth_provider)
278 self.flavors_client = FlavorsClientJSON(self.auth_provider)
279 self.flavors_v3_client = FlavorsV3ClientJSON(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000280 self.extensions_v3_client = ExtensionsV3ClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000281 self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000282 self.extensions_client = ExtensionsClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000283 self.auth_provider)
Attila Fazekas7e678de2013-07-13 14:13:28 +0200284 self.volumes_extensions_client = VolumesExtensionsClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000285 self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000286 self.floating_ips_client = FloatingIPsClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000287 self.auth_provider)
288 self.backups_client = BackupsClientJSON(self.auth_provider)
289 self.snapshots_client = SnapshotsClientJSON(self.auth_provider)
290 self.volumes_client = VolumesClientJSON(self.auth_provider)
291 self.volumes_v2_client = VolumesV2ClientJSON(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000292 self.volume_types_client = VolumeTypesClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000293 self.auth_provider)
294 self.identity_client = IdentityClientJSON(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000295 self.identity_v3_client = IdentityV3ClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000296 self.auth_provider)
Attila Fazekas7e678de2013-07-13 14:13:28 +0200297 self.security_groups_client = SecurityGroupsClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000298 self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000299 self.interfaces_v3_client = InterfacesV3ClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000300 self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000301 self.interfaces_client = InterfacesClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000302 self.auth_provider)
303 self.endpoints_client = EndPointClientJSON(self.auth_provider)
304 self.fixed_ips_client = FixedIPsClientJSON(self.auth_provider)
ivan-zhuac7b3802013-08-21 16:03:53 +0800305 self.availability_zone_v3_client = AvailabilityZoneV3ClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000306 self.auth_provider)
Attila Fazekas7e678de2013-07-13 14:13:28 +0200307 self.availability_zone_client = AvailabilityZoneClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000308 self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000309 self.services_v3_client = ServicesV3ClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000310 self.auth_provider)
311 self.service_client = ServiceClientJSON(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000312 self.aggregates_v3_client = AggregatesV3ClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000313 self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000314 self.aggregates_client = AggregatesClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000315 self.auth_provider)
316 self.services_client = ServicesClientJSON(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000317 self.tenant_usages_client = TenantUsagesClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000318 self.auth_provider)
319 self.version_v3_client = VersionV3ClientJSON(self.auth_provider)
320 self.policy_client = PolicyClientJSON(self.auth_provider)
321 self.hosts_client = HostsClientJSON(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000322 self.hypervisor_v3_client = HypervisorV3ClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000323 self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000324 self.hypervisor_client = HypervisorClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000325 self.auth_provider)
326 self.network_client = NetworkClientJSON(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000327 self.credentials_client = CredentialsClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000328 self.auth_provider)
ivan-zhuef7a1bd2013-10-22 17:56:46 +0800329 self.instance_usages_audit_log_client = \
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000330 InstanceUsagesAuditLogClientJSON(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000331 self.volume_hosts_client = VolumeHostsClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000332 self.auth_provider)
Matthew Treinish2324e6b2013-10-21 20:25:17 +0000333 self.volumes_extension_client = VolumeExtensionClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000334 self.auth_provider)
335 self.hosts_v3_client = HostsV3ClientJSON(self.auth_provider)
Nikhil Manchandadd6886f2014-03-03 01:58:45 -0800336 self.database_flavors_client = DatabaseFlavorsClientJSON(
337 self.auth_provider)
Malini Kamalambal6e7b3b82014-02-06 06:49:04 -0500338 self.queuing_client = QueuingClientJSON(self.auth_provider)
Nikolay Pliashechnikovb053aab2013-11-05 06:06:44 -0800339 if CONF.service_available.ceilometer:
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000340 self.telemetry_client = TelemetryClientJSON(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000341 self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000342 self.token_client = TokenClientJSON()
343 self.token_v3_client = V3TokenClientJSON()
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000344 self.negative_client = NegativeRestClient(self.auth_provider)
Marc Koderer24eb89c2014-01-31 11:23:33 +0100345 self.negative_client.service = service
Attila Fazekas7e678de2013-07-13 14:13:28 +0200346
Attila Fazekas7e678de2013-07-13 14:13:28 +0200347 else:
Dan Smithcf8fab62012-08-14 08:03:48 -0700348 msg = "Unsupported interface type `%s'" % interface
349 raise exceptions.InvalidConfiguration(msg)
Attila Fazekas7e678de2013-07-13 14:13:28 +0200350
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000351 # TODO(andreaf) EC2 client still do their auth, v2 only
352 ec2_client_args = (self.credentials.get('username'),
353 self.credentials.get('password'),
354 CONF.identity.uri,
355 self.credentials.get('tenant_name'))
356
Attila Fazekas7e678de2013-07-13 14:13:28 +0200357 # common clients
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000358 self.account_client = AccountClient(self.auth_provider)
Sean Dague86bd8422013-12-20 09:56:44 -0500359 if CONF.service_available.glance:
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000360 self.image_client = ImageClientJSON(self.auth_provider)
361 self.image_client_v2 = ImageClientV2JSON(self.auth_provider)
362 self.container_client = ContainerClient(self.auth_provider)
363 self.object_client = ObjectClient(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000364 self.orchestration_client = OrchestrationClient(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000365 self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000366 self.ec2api_client = botoclients.APIClientEC2(*ec2_client_args)
367 self.s3_client = botoclients.ObjectClientS3(*ec2_client_args)
368 self.custom_object_client = ObjectClientCustomizedHeader(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000369 self.auth_provider)
harika-vakadi2daed0a2013-01-01 20:51:39 +0530370 self.custom_account_client = \
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000371 AccountClientCustomizedHeader(self.auth_provider)
Andrea Frittoli8bbdb162014-01-06 11:06:13 +0000372 self.data_processing_client = DataProcessingClient(
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000373 self.auth_provider)
Jay Pipes50677282012-01-06 15:39:20 -0500374
375
Jay Pipesff10d552012-04-06 14:18:50 -0400376class AltManager(Manager):
377
378 """
379 Manager object that uses the alt_XXX credentials for its
380 managed client objects
381 """
382
Marc Koderer24eb89c2014-01-31 11:23:33 +0100383 def __init__(self, interface='json', service=None):
Sean Dague86bd8422013-12-20 09:56:44 -0500384 super(AltManager, self).__init__(CONF.identity.alt_username,
385 CONF.identity.alt_password,
386 CONF.identity.alt_tenant_name,
Marc Koderer24eb89c2014-01-31 11:23:33 +0100387 interface=interface,
388 service=service)
Jay Pipesff10d552012-04-06 14:18:50 -0400389
390
391class AdminManager(Manager):
392
393 """
Attila Fazekascadcb1f2013-01-21 23:10:53 +0100394 Manager object that uses the admin credentials for its
Jay Pipesff10d552012-04-06 14:18:50 -0400395 managed client objects
396 """
397
Marc Koderer24eb89c2014-01-31 11:23:33 +0100398 def __init__(self, interface='json', service=None):
Sean Dague86bd8422013-12-20 09:56:44 -0500399 super(AdminManager, self).__init__(CONF.identity.admin_username,
400 CONF.identity.admin_password,
401 CONF.identity.admin_tenant_name,
Marc Koderer24eb89c2014-01-31 11:23:33 +0100402 interface=interface,
403 service=service)
Jay Pipesff10d552012-04-06 14:18:50 -0400404
405
Attila Fazekascadcb1f2013-01-21 23:10:53 +0100406class ComputeAdminManager(Manager):
407
408 """
409 Manager object that uses the compute_admin credentials for its
410 managed client objects
411 """
412
Marc Koderer24eb89c2014-01-31 11:23:33 +0100413 def __init__(self, interface='json', service=None):
Attila Fazekascadcb1f2013-01-21 23:10:53 +0100414 base = super(ComputeAdminManager, self)
Sean Dague86bd8422013-12-20 09:56:44 -0500415 base.__init__(CONF.compute_admin.username,
416 CONF.compute_admin.password,
417 CONF.compute_admin.tenant_name,
Marc Koderer24eb89c2014-01-31 11:23:33 +0100418 interface=interface,
419 service=service)
Steve Bakerc60e4e32013-05-06 15:22:41 +1200420
421
422class OrchestrationManager(Manager):
423 """
424 Manager object that uses the admin credentials for its
425 so that heat templates can create users
426 """
Marc Koderer24eb89c2014-01-31 11:23:33 +0100427 def __init__(self, interface='json', service=None):
Steve Bakerc60e4e32013-05-06 15:22:41 +1200428 base = super(OrchestrationManager, self)
Steve Bakerb07f9742014-02-19 10:03:57 +1300429 # heat currently needs an admin user so that stacks can create users
430 # however the tests need the demo tenant so that the neutron
431 # private network is the default. DO NOT change this auth combination
432 # until heat can run with the demo user.
Sean Dague86bd8422013-12-20 09:56:44 -0500433 base.__init__(CONF.identity.admin_username,
434 CONF.identity.admin_password,
Steve Bakerb07f9742014-02-19 10:03:57 +1300435 CONF.identity.tenant_name,
Marc Koderer24eb89c2014-01-31 11:23:33 +0100436 interface=interface,
437 service=service)
Andrea Frittolif9cde7e2014-02-18 09:57:04 +0000438
439
440class OfficialClientManager(manager.Manager):
441 """
442 Manager that provides access to the official python clients for
443 calling various OpenStack APIs.
444 """
445
446 NOVACLIENT_VERSION = '2'
447 CINDERCLIENT_VERSION = '1'
448 HEATCLIENT_VERSION = '1'
449
450 def __init__(self, username, password, tenant_name):
451 # FIXME(andreaf) Auth provider for client_type 'official' is
452 # not implemented yet, setting to 'tempest' for now.
453 self.client_type = 'tempest'
454 self.interface = None
455 # super cares for credentials validation
456 super(OfficialClientManager, self).__init__(
457 username=username, password=password, tenant_name=tenant_name)
458 self.compute_client = self._get_compute_client(username,
459 password,
460 tenant_name)
461 self.identity_client = self._get_identity_client(username,
462 password,
463 tenant_name)
464 self.image_client = self._get_image_client()
465 self.network_client = self._get_network_client()
466 self.volume_client = self._get_volume_client(username,
467 password,
468 tenant_name)
469 self.object_storage_client = self._get_object_storage_client(
470 username,
471 password,
472 tenant_name)
473 self.orchestration_client = self._get_orchestration_client(
474 username,
475 password,
476 tenant_name)
477
478 def _get_compute_client(self, username, password, tenant_name):
479 # Novaclient will not execute operations for anyone but the
480 # identified user, so a new client needs to be created for
481 # each user that operations need to be performed for.
482 self._validate_credentials(username, password, tenant_name)
483
484 auth_url = CONF.identity.uri
485 dscv = CONF.identity.disable_ssl_certificate_validation
486 region = CONF.identity.region
487
488 client_args = (username, password, tenant_name, auth_url)
489
490 # Create our default Nova client to use in testing
491 service_type = CONF.compute.catalog_type
492 endpoint_type = CONF.compute.endpoint_type
493 return novaclient.client.Client(self.NOVACLIENT_VERSION,
494 *client_args,
495 service_type=service_type,
496 endpoint_type=endpoint_type,
497 region_name=region,
498 no_cache=True,
499 insecure=dscv,
500 http_log_debug=True)
501
502 def _get_image_client(self):
503 token = self.identity_client.auth_token
504 region = CONF.identity.region
505 endpoint_type = CONF.image.endpoint_type
506 endpoint = self.identity_client.service_catalog.url_for(
507 attr='region', filter_value=region,
508 service_type=CONF.image.catalog_type, endpoint_type=endpoint_type)
509 dscv = CONF.identity.disable_ssl_certificate_validation
510 return glanceclient.Client('1', endpoint=endpoint, token=token,
511 insecure=dscv)
512
513 def _get_volume_client(self, username, password, tenant_name):
514 auth_url = CONF.identity.uri
515 region = CONF.identity.region
516 endpoint_type = CONF.volume.endpoint_type
517 return cinderclient.client.Client(self.CINDERCLIENT_VERSION,
518 username,
519 password,
520 tenant_name,
521 auth_url,
522 region_name=region,
523 endpoint_type=endpoint_type,
524 http_log_debug=True)
525
526 def _get_object_storage_client(self, username, password, tenant_name):
527 auth_url = CONF.identity.uri
528 # add current tenant to swift operator role group.
529 keystone_admin = self._get_identity_client(
530 CONF.identity.admin_username,
531 CONF.identity.admin_password,
532 CONF.identity.admin_tenant_name)
533
534 # enable test user to operate swift by adding operator role to him.
535 roles = keystone_admin.roles.list()
536 operator_role = CONF.object_storage.operator_role
537 member_role = [role for role in roles if role.name == operator_role][0]
538 # NOTE(maurosr): This is surrounded in the try-except block cause
539 # neutron tests doesn't have tenant isolation.
540 try:
541 keystone_admin.roles.add_user_role(self.identity_client.user_id,
542 member_role.id,
543 self.identity_client.tenant_id)
544 except keystoneclient.exceptions.Conflict:
545 pass
546
547 endpoint_type = CONF.object_storage.endpoint_type
548 os_options = {'endpoint_type': endpoint_type}
549 return swiftclient.Connection(auth_url, username, password,
550 tenant_name=tenant_name,
551 auth_version='2',
552 os_options=os_options)
553
554 def _get_orchestration_client(self, username=None, password=None,
555 tenant_name=None):
556 if not username:
557 username = CONF.identity.admin_username
558 if not password:
559 password = CONF.identity.admin_password
560 if not tenant_name:
561 tenant_name = CONF.identity.tenant_name
562
563 self._validate_credentials(username, password, tenant_name)
564
565 keystone = self._get_identity_client(username, password, tenant_name)
566 region = CONF.identity.region
567 endpoint_type = CONF.orchestration.endpoint_type
568 token = keystone.auth_token
569 service_type = CONF.orchestration.catalog_type
570 try:
571 endpoint = keystone.service_catalog.url_for(
572 attr='region',
573 filter_value=region,
574 service_type=service_type,
575 endpoint_type=endpoint_type)
576 except keystoneclient.exceptions.EndpointNotFound:
577 return None
578 else:
579 return heatclient.client.Client(self.HEATCLIENT_VERSION,
580 endpoint,
581 token=token,
582 username=username,
583 password=password)
584
585 def _get_identity_client(self, username, password, tenant_name):
586 # This identity client is not intended to check the security
587 # of the identity service, so use admin credentials by default.
588 self._validate_credentials(username, password, tenant_name)
589
590 auth_url = CONF.identity.uri
591 dscv = CONF.identity.disable_ssl_certificate_validation
592
593 return keystoneclient.v2_0.client.Client(username=username,
594 password=password,
595 tenant_name=tenant_name,
596 auth_url=auth_url,
597 insecure=dscv)
598
599 def _get_network_client(self):
600 # The intended configuration is for the network client to have
601 # admin privileges and indicate for whom resources are being
602 # created via a 'tenant_id' parameter. This will often be
603 # preferable to authenticating as a specific user because
604 # working with certain resources (public routers and networks)
605 # often requires admin privileges anyway.
606 username = CONF.identity.admin_username
607 password = CONF.identity.admin_password
608 tenant_name = CONF.identity.admin_tenant_name
609
610 self._validate_credentials(username, password, tenant_name)
611
612 auth_url = CONF.identity.uri
613 dscv = CONF.identity.disable_ssl_certificate_validation
614 endpoint_type = CONF.network.endpoint_type
615
616 return neutronclient.v2_0.client.Client(username=username,
617 password=password,
618 tenant_name=tenant_name,
619 endpoint_type=endpoint_type,
620 auth_url=auth_url,
621 insecure=dscv)