ZhiQiang Fan | 39f9722 | 2013-09-20 04:49:44 +0800 | [diff] [blame] | 1 | # Copyright 2012 OpenStack Foundation |
Jay Pipes | 3f981df | 2012-03-27 18:59:44 -0400 | [diff] [blame] | 2 | # All Rights Reserved. |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 5 | # not use this file except in compliance with the License. You may obtain |
| 6 | # a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 | # License for the specific language governing permissions and limitations |
| 14 | # under the License. |
| 15 | |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 16 | # Default client libs |
| 17 | import cinderclient.client |
| 18 | import glanceclient |
| 19 | import heatclient.client |
| 20 | import keystoneclient.exceptions |
| 21 | import keystoneclient.v2_0.client |
| 22 | import neutronclient.v2_0.client |
| 23 | import novaclient.client |
| 24 | import swiftclient |
| 25 | |
Marc Koderer | 24eb89c | 2014-01-31 11:23:33 +0100 | [diff] [blame] | 26 | from tempest.common.rest_client import NegativeRestClient |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 27 | from tempest import config |
Daryl Walleck | 587385b | 2012-03-03 13:00:26 -0600 | [diff] [blame] | 28 | from tempest import exceptions |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 29 | from tempest import manager |
Matthew Treinish | f4a9b0f | 2013-07-26 16:58:26 -0400 | [diff] [blame] | 30 | from tempest.openstack.common import log as logging |
Roman Prykhodchenko | 62b1ed1 | 2013-10-16 21:51:47 +0300 | [diff] [blame] | 31 | from tempest.services.baremetal.v1.client_json import BaremetalClientJSON |
Attila Fazekas | 1aed620 | 2013-02-11 14:47:45 +0100 | [diff] [blame] | 32 | from tempest.services import botoclients |
Mitsuhiko Yamazaki | 74f0707 | 2013-04-02 11:52:31 +0900 | [diff] [blame] | 33 | from tempest.services.compute.json.aggregates_client import \ |
| 34 | AggregatesClientJSON |
Leo Toyoda | a527891 | 2013-04-16 15:40:12 +0900 | [diff] [blame] | 35 | from tempest.services.compute.json.availability_zone_client import \ |
| 36 | AvailabilityZoneClientJSON |
ivan-zhu | d57f3cf | 2013-11-06 16:59:52 +0800 | [diff] [blame] | 37 | from tempest.services.compute.json.certificates_client import \ |
| 38 | CertificatesClientJSON |
dwalleck | e62b9f0 | 2012-10-10 23:34:42 -0500 | [diff] [blame] | 39 | from tempest.services.compute.json.extensions_client import \ |
harika-vakadi | 1a9ad61 | 2012-12-14 19:12:08 +0530 | [diff] [blame] | 40 | ExtensionsClientJSON |
Sean Dague | 2416cf3 | 2013-04-10 08:29:07 -0400 | [diff] [blame] | 41 | from tempest.services.compute.json.fixed_ips_client import FixedIPsClientJSON |
dwalleck | e62b9f0 | 2012-10-10 23:34:42 -0500 | [diff] [blame] | 42 | from tempest.services.compute.json.flavors_client import FlavorsClientJSON |
| 43 | from tempest.services.compute.json.floating_ips_client import \ |
harika-vakadi | 1a9ad61 | 2012-12-14 19:12:08 +0530 | [diff] [blame] | 44 | FloatingIPsClientJSON |
Attila Fazekas | 8e99b99 | 2013-02-24 09:53:23 +0100 | [diff] [blame] | 45 | from tempest.services.compute.json.hosts_client import HostsClientJSON |
Tony Yang | 3d5f163 | 2013-06-06 14:17:57 +0800 | [diff] [blame] | 46 | from tempest.services.compute.json.hypervisor_client import \ |
| 47 | HypervisorClientJSON |
dwalleck | e62b9f0 | 2012-10-10 23:34:42 -0500 | [diff] [blame] | 48 | from tempest.services.compute.json.images_client import ImagesClientJSON |
ivan-zhu | ef7a1bd | 2013-10-22 17:56:46 +0800 | [diff] [blame] | 49 | from tempest.services.compute.json.instance_usage_audit_log_client import \ |
| 50 | InstanceUsagesAuditLogClientJSON |
Sean Dague | 2416cf3 | 2013-04-10 08:29:07 -0400 | [diff] [blame] | 51 | from tempest.services.compute.json.interfaces_client import \ |
| 52 | InterfacesClientJSON |
Attila Fazekas | 6968dd5 | 2013-02-15 17:05:53 +0100 | [diff] [blame] | 53 | from tempest.services.compute.json.keypairs_client import KeyPairsClientJSON |
dwalleck | e62b9f0 | 2012-10-10 23:34:42 -0500 | [diff] [blame] | 54 | from tempest.services.compute.json.limits_client import LimitsClientJSON |
Attila Fazekas | 6968dd5 | 2013-02-15 17:05:53 +0100 | [diff] [blame] | 55 | from tempest.services.compute.json.quotas_client import QuotasClientJSON |
Matthew Treinish | a83a16e | 2012-12-07 13:44:02 -0500 | [diff] [blame] | 56 | from tempest.services.compute.json.security_groups_client import \ |
harika-vakadi | 1a9ad61 | 2012-12-14 19:12:08 +0530 | [diff] [blame] | 57 | SecurityGroupsClientJSON |
Attila Fazekas | 6968dd5 | 2013-02-15 17:05:53 +0100 | [diff] [blame] | 58 | from tempest.services.compute.json.servers_client import ServersClientJSON |
Leo Toyoda | 3ae31e1 | 2013-04-19 11:19:57 +0900 | [diff] [blame] | 59 | from tempest.services.compute.json.services_client import ServicesClientJSON |
Leo Toyoda | d80b6a0 | 2013-05-08 12:15:13 +0900 | [diff] [blame] | 60 | from tempest.services.compute.json.tenant_usages_client import \ |
| 61 | TenantUsagesClientJSON |
Matthew Treinish | a83a16e | 2012-12-07 13:44:02 -0500 | [diff] [blame] | 62 | from tempest.services.compute.json.volumes_extensions_client import \ |
harika-vakadi | 1a9ad61 | 2012-12-14 19:12:08 +0530 | [diff] [blame] | 63 | VolumesExtensionsClientJSON |
ivan-zhu | 00fe64f | 2013-08-20 19:35:51 +0800 | [diff] [blame] | 64 | from tempest.services.compute.v3.json.aggregates_client import \ |
| 65 | AggregatesV3ClientJSON |
ivan-zhu | ac7b380 | 2013-08-21 16:03:53 +0800 | [diff] [blame] | 66 | from tempest.services.compute.v3.json.availability_zone_client import \ |
| 67 | AvailabilityZoneV3ClientJSON |
ivan-zhu | 0e06292 | 2013-12-17 16:14:12 +0800 | [diff] [blame] | 68 | from tempest.services.compute.v3.json.certificates_client import \ |
| 69 | CertificatesV3ClientJSON |
ivan-zhu | 31d9848 | 2013-08-22 10:51:48 +0800 | [diff] [blame] | 70 | from tempest.services.compute.v3.json.extensions_client import \ |
| 71 | ExtensionsV3ClientJSON |
ivan-zhu | b25900a | 2013-12-13 16:28:45 +0800 | [diff] [blame] | 72 | from tempest.services.compute.v3.json.flavors_client import FlavorsV3ClientJSON |
ivan-zhu | 00fe64f | 2013-08-20 19:35:51 +0800 | [diff] [blame] | 73 | from tempest.services.compute.v3.json.hosts_client import HostsV3ClientJSON |
ivan-zhu | 6f5f9e9 | 2013-08-21 22:16:37 +0800 | [diff] [blame] | 74 | from tempest.services.compute.v3.json.hypervisor_client import \ |
| 75 | HypervisorV3ClientJSON |
ivan-zhu | 91feab9 | 2013-08-15 18:25:33 +0800 | [diff] [blame] | 76 | from tempest.services.compute.v3.json.interfaces_client import \ |
| 77 | InterfacesV3ClientJSON |
ivan-zhu | 7e7e6a3 | 2013-11-20 16:07:29 +0800 | [diff] [blame] | 78 | from tempest.services.compute.v3.json.keypairs_client import \ |
| 79 | KeyPairsV3ClientJSON |
ivan-zhu | b6d69ee | 2013-12-17 14:16:31 +0800 | [diff] [blame] | 80 | from tempest.services.compute.v3.json.quotas_client import \ |
| 81 | QuotasV3ClientJSON |
ivan-zhu | 8f992be | 2013-07-31 14:56:58 +0800 | [diff] [blame] | 82 | from tempest.services.compute.v3.json.servers_client import \ |
| 83 | ServersV3ClientJSON |
ivan-zhu | 5c86ae6 | 2013-08-20 21:09:01 +0800 | [diff] [blame] | 84 | from tempest.services.compute.v3.json.services_client import \ |
| 85 | ServicesV3ClientJSON |
Ken'ichi Ohmichi | 3d6b6fa | 2014-01-08 04:42:16 +0900 | [diff] [blame] | 86 | from tempest.services.compute.v3.json.version_client import \ |
| 87 | VersionV3ClientJSON |
Mitsuhiko Yamazaki | ae8fc53 | 2013-04-22 11:17:35 +0900 | [diff] [blame] | 88 | from tempest.services.compute.xml.aggregates_client import AggregatesClientXML |
Leo Toyoda | a527891 | 2013-04-16 15:40:12 +0900 | [diff] [blame] | 89 | from tempest.services.compute.xml.availability_zone_client import \ |
| 90 | AvailabilityZoneClientXML |
ivan-zhu | d57f3cf | 2013-11-06 16:59:52 +0800 | [diff] [blame] | 91 | from tempest.services.compute.xml.certificates_client import \ |
| 92 | CertificatesClientXML |
dwalleck | e62b9f0 | 2012-10-10 23:34:42 -0500 | [diff] [blame] | 93 | from tempest.services.compute.xml.extensions_client import ExtensionsClientXML |
Sean Dague | 2416cf3 | 2013-04-10 08:29:07 -0400 | [diff] [blame] | 94 | from tempest.services.compute.xml.fixed_ips_client import FixedIPsClientXML |
dwalleck | e62b9f0 | 2012-10-10 23:34:42 -0500 | [diff] [blame] | 95 | from tempest.services.compute.xml.flavors_client import FlavorsClientXML |
| 96 | from tempest.services.compute.xml.floating_ips_client import \ |
harika-vakadi | 1a9ad61 | 2012-12-14 19:12:08 +0530 | [diff] [blame] | 97 | FloatingIPsClientXML |
Ken'ichi Ohmichi | a1aa44c | 2013-12-06 20:48:24 +0900 | [diff] [blame] | 98 | from tempest.services.compute.xml.hosts_client import HostsClientXML |
Tony Yang | 3d5f163 | 2013-06-06 14:17:57 +0800 | [diff] [blame] | 99 | from tempest.services.compute.xml.hypervisor_client import HypervisorClientXML |
dwalleck | e62b9f0 | 2012-10-10 23:34:42 -0500 | [diff] [blame] | 100 | from tempest.services.compute.xml.images_client import ImagesClientXML |
ivan-zhu | ef7a1bd | 2013-10-22 17:56:46 +0800 | [diff] [blame] | 101 | from tempest.services.compute.xml.instance_usage_audit_log_client import \ |
| 102 | InstanceUsagesAuditLogClientXML |
Sean Dague | 2416cf3 | 2013-04-10 08:29:07 -0400 | [diff] [blame] | 103 | from tempest.services.compute.xml.interfaces_client import \ |
| 104 | InterfacesClientXML |
dwalleck | e62b9f0 | 2012-10-10 23:34:42 -0500 | [diff] [blame] | 105 | from tempest.services.compute.xml.keypairs_client import KeyPairsClientXML |
| 106 | from tempest.services.compute.xml.limits_client import LimitsClientXML |
rajalakshmi-ganesan | 1982c3c | 2013-01-10 14:56:45 +0530 | [diff] [blame] | 107 | from tempest.services.compute.xml.quotas_client import QuotasClientXML |
dwalleck | e62b9f0 | 2012-10-10 23:34:42 -0500 | [diff] [blame] | 108 | from tempest.services.compute.xml.security_groups_client \ |
harika-vakadi | 1a9ad61 | 2012-12-14 19:12:08 +0530 | [diff] [blame] | 109 | import SecurityGroupsClientXML |
dwalleck | e62b9f0 | 2012-10-10 23:34:42 -0500 | [diff] [blame] | 110 | from tempest.services.compute.xml.servers_client import ServersClientXML |
Leo Toyoda | 3ae31e1 | 2013-04-19 11:19:57 +0900 | [diff] [blame] | 111 | from tempest.services.compute.xml.services_client import ServicesClientXML |
Leo Toyoda | d80b6a0 | 2013-05-08 12:15:13 +0900 | [diff] [blame] | 112 | from tempest.services.compute.xml.tenant_usages_client import \ |
| 113 | TenantUsagesClientXML |
Matthew Treinish | a83a16e | 2012-12-07 13:44:02 -0500 | [diff] [blame] | 114 | from tempest.services.compute.xml.volumes_extensions_client import \ |
harika-vakadi | 1a9ad61 | 2012-12-14 19:12:08 +0530 | [diff] [blame] | 115 | VolumesExtensionsClientXML |
Sergey Lukjanov | 3bc60e9 | 2013-12-10 16:40:50 +0400 | [diff] [blame] | 116 | from tempest.services.data_processing.v1_1.client import DataProcessingClient |
Nikhil Manchanda | dd6886f | 2014-03-03 01:58:45 -0800 | [diff] [blame] | 117 | from tempest.services.database.json.flavors_client import \ |
| 118 | DatabaseFlavorsClientJSON |
Attila Fazekas | 407b6db | 2013-01-19 12:48:36 +0100 | [diff] [blame] | 119 | from tempest.services.identity.json.identity_client import IdentityClientJSON |
| 120 | from tempest.services.identity.json.identity_client import TokenClientJSON |
nayna-patel | 914b471 | 2013-07-16 08:29:05 +0000 | [diff] [blame] | 121 | from tempest.services.identity.v3.json.credentials_client import \ |
| 122 | CredentialsClientJSON |
Sean Dague | 2416cf3 | 2013-04-10 08:29:07 -0400 | [diff] [blame] | 123 | from tempest.services.identity.v3.json.endpoints_client import \ |
| 124 | EndPointClientJSON |
rajalakshmi-ganesan | 7312bb5 | 2013-01-29 20:03:42 +0530 | [diff] [blame] | 125 | from tempest.services.identity.v3.json.identity_client import \ |
| 126 | IdentityV3ClientJSON |
nayna-patel | b35f723 | 2013-06-28 07:08:44 +0000 | [diff] [blame] | 127 | from tempest.services.identity.v3.json.identity_client import V3TokenClientJSON |
harika-vakadi | 40e1011 | 2013-02-08 14:38:09 +0530 | [diff] [blame] | 128 | from tempest.services.identity.v3.json.policy_client import PolicyClientJSON |
harika-vakadi | a92dd74 | 2013-02-19 20:41:22 +0530 | [diff] [blame] | 129 | from tempest.services.identity.v3.json.service_client import \ |
| 130 | ServiceClientJSON |
nayna-patel | 914b471 | 2013-07-16 08:29:05 +0000 | [diff] [blame] | 131 | from tempest.services.identity.v3.xml.credentials_client import \ |
| 132 | CredentialsClientXML |
rajalakshmi-ganesan | ab42672 | 2013-02-08 15:49:15 +0530 | [diff] [blame] | 133 | from tempest.services.identity.v3.xml.endpoints_client import EndPointClientXML |
rajalakshmi-ganesan | 7312bb5 | 2013-01-29 20:03:42 +0530 | [diff] [blame] | 134 | from tempest.services.identity.v3.xml.identity_client import \ |
| 135 | IdentityV3ClientXML |
nayna-patel | b35f723 | 2013-06-28 07:08:44 +0000 | [diff] [blame] | 136 | from tempest.services.identity.v3.xml.identity_client import V3TokenClientXML |
harika-vakadi | 40e1011 | 2013-02-08 14:38:09 +0530 | [diff] [blame] | 137 | from tempest.services.identity.v3.xml.policy_client import PolicyClientXML |
harika-vakadi | a92dd74 | 2013-02-19 20:41:22 +0530 | [diff] [blame] | 138 | from tempest.services.identity.v3.xml.service_client import \ |
| 139 | ServiceClientXML |
Attila Fazekas | 407b6db | 2013-01-19 12:48:36 +0100 | [diff] [blame] | 140 | from tempest.services.identity.xml.identity_client import IdentityClientXML |
| 141 | from tempest.services.identity.xml.identity_client import TokenClientXML |
Matthew Treinish | 6d59c99 | 2013-03-01 16:20:04 -0500 | [diff] [blame] | 142 | from tempest.services.image.v1.json.image_client import ImageClientJSON |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 143 | from tempest.services.image.v2.json.image_client import ImageClientV2JSON |
raiesmh08 | 6769832 | 2013-08-20 13:09:01 +0530 | [diff] [blame] | 144 | from tempest.services.network.json.network_client import NetworkClientJSON |
| 145 | from tempest.services.network.xml.network_client import NetworkClientXML |
dwalleck | 5d73443 | 2012-10-04 01:11:47 -0500 | [diff] [blame] | 146 | from tempest.services.object_storage.account_client import AccountClient |
harika-vakadi | 2daed0a | 2013-01-01 20:51:39 +0530 | [diff] [blame] | 147 | from tempest.services.object_storage.account_client import \ |
| 148 | AccountClientCustomizedHeader |
Attila Fazekas | 6968dd5 | 2013-02-15 17:05:53 +0100 | [diff] [blame] | 149 | from tempest.services.object_storage.container_client import ContainerClient |
| 150 | from tempest.services.object_storage.object_client import ObjectClient |
| 151 | from tempest.services.object_storage.object_client import \ |
| 152 | ObjectClientCustomizedHeader |
Steve Baker | c60e4e3 | 2013-05-06 15:22:41 +1200 | [diff] [blame] | 153 | from tempest.services.orchestration.json.orchestration_client import \ |
| 154 | OrchestrationClient |
Malini Kamalambal | 6e7b3b8 | 2014-02-06 06:49:04 -0500 | [diff] [blame^] | 155 | from tempest.services.queuing.json.queuing_client import QueuingClientJSON |
Nikolay Pliashechnikov | b053aab | 2013-11-05 06:06:44 -0800 | [diff] [blame] | 156 | from tempest.services.telemetry.json.telemetry_client import \ |
| 157 | TelemetryClientJSON |
| 158 | from tempest.services.telemetry.xml.telemetry_client import \ |
| 159 | TelemetryClientXML |
Nayna Patel | 4a5024c | 2013-11-18 07:08:23 +0000 | [diff] [blame] | 160 | from tempest.services.volume.json.admin.volume_hosts_client import \ |
| 161 | VolumeHostsClientJSON |
Attila Fazekas | 6968dd5 | 2013-02-15 17:05:53 +0100 | [diff] [blame] | 162 | from tempest.services.volume.json.admin.volume_types_client import \ |
| 163 | VolumeTypesClientJSON |
Giulio Fidente | 74b08ad | 2014-01-18 04:02:51 +0100 | [diff] [blame] | 164 | from tempest.services.volume.json.backups_client import BackupsClientJSON |
Matthew Treinish | 2324e6b | 2013-10-21 20:25:17 +0000 | [diff] [blame] | 165 | from tempest.services.volume.json.extensions_client import \ |
| 166 | ExtensionsClientJSON as VolumeExtensionClientJSON |
Attila Fazekas | 6968dd5 | 2013-02-15 17:05:53 +0100 | [diff] [blame] | 167 | from tempest.services.volume.json.snapshots_client import SnapshotsClientJSON |
| 168 | from tempest.services.volume.json.volumes_client import VolumesClientJSON |
Zhi Kun Liu | 8cc3c84 | 2014-01-07 10:44:34 +0800 | [diff] [blame] | 169 | from tempest.services.volume.v2.json.volumes_client import VolumesV2ClientJSON |
| 170 | from tempest.services.volume.v2.xml.volumes_client import VolumesV2ClientXML |
Nayna Patel | 4a5024c | 2013-11-18 07:08:23 +0000 | [diff] [blame] | 171 | from tempest.services.volume.xml.admin.volume_hosts_client import \ |
| 172 | VolumeHostsClientXML |
Attila Fazekas | 6968dd5 | 2013-02-15 17:05:53 +0100 | [diff] [blame] | 173 | from tempest.services.volume.xml.admin.volume_types_client import \ |
| 174 | VolumeTypesClientXML |
Giulio Fidente | 74b08ad | 2014-01-18 04:02:51 +0100 | [diff] [blame] | 175 | from tempest.services.volume.xml.backups_client import BackupsClientXML |
Matthew Treinish | 2324e6b | 2013-10-21 20:25:17 +0000 | [diff] [blame] | 176 | from tempest.services.volume.xml.extensions_client import \ |
| 177 | ExtensionsClientXML as VolumeExtensionClientXML |
Attila Fazekas | 6968dd5 | 2013-02-15 17:05:53 +0100 | [diff] [blame] | 178 | from tempest.services.volume.xml.snapshots_client import SnapshotsClientXML |
| 179 | from tempest.services.volume.xml.volumes_client import VolumesClientXML |
Vincent Hou | 6b8a7b7 | 2012-08-25 01:24:33 +0800 | [diff] [blame] | 180 | |
Sean Dague | 86bd842 | 2013-12-20 09:56:44 -0500 | [diff] [blame] | 181 | CONF = config.CONF |
Jay Pipes | 3f981df | 2012-03-27 18:59:44 -0400 | [diff] [blame] | 182 | LOG = logging.getLogger(__name__) |
| 183 | |
Vincent Hou | 6b8a7b7 | 2012-08-25 01:24:33 +0800 | [diff] [blame] | 184 | |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 185 | class Manager(manager.Manager): |
Daryl Walleck | 1465d61 | 2011-11-02 02:22:15 -0500 | [diff] [blame] | 186 | |
Jay Pipes | 3f981df | 2012-03-27 18:59:44 -0400 | [diff] [blame] | 187 | """ |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 188 | Top level manager for OpenStack tempest clients |
Jay Pipes | 3f981df | 2012-03-27 18:59:44 -0400 | [diff] [blame] | 189 | """ |
| 190 | |
James E. Blair | e6d8ee1 | 2013-01-18 21:33:45 +0000 | [diff] [blame] | 191 | def __init__(self, username=None, password=None, tenant_name=None, |
Marc Koderer | 24eb89c | 2014-01-31 11:23:33 +0100 | [diff] [blame] | 192 | interface='json', service=None): |
Jay Pipes | ff10d55 | 2012-04-06 14:18:50 -0400 | [diff] [blame] | 193 | """ |
| 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 Frittoli | 8bbdb16 | 2014-01-06 11:06:13 +0000 | [diff] [blame] | 202 | self.interface = interface |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 203 | 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 Knudson | c7ca334 | 2013-03-28 21:08:50 -0500 | [diff] [blame] | 207 | |
Andrea Frittoli | 8bbdb16 | 2014-01-06 11:06:13 +0000 | [diff] [blame] | 208 | if self.interface == 'xml': |
| 209 | self.certificates_client = CertificatesClientXML( |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 210 | 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 Fazekas | 7e678de | 2013-07-13 14:13:28 +0200 | [diff] [blame] | 218 | self.volumes_extensions_client = VolumesExtensionsClientXML( |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 219 | self.auth_provider) |
Andrea Frittoli | 8bbdb16 | 2014-01-06 11:06:13 +0000 | [diff] [blame] | 220 | self.floating_ips_client = FloatingIPsClientXML( |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 221 | 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 Frittoli | 8bbdb16 | 2014-01-06 11:06:13 +0000 | [diff] [blame] | 226 | self.volume_types_client = VolumeTypesClientXML( |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 227 | self.auth_provider) |
| 228 | self.identity_client = IdentityClientXML(self.auth_provider) |
Andrea Frittoli | 8bbdb16 | 2014-01-06 11:06:13 +0000 | [diff] [blame] | 229 | self.identity_v3_client = IdentityV3ClientXML( |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 230 | self.auth_provider) |
Attila Fazekas | 7e678de | 2013-07-13 14:13:28 +0200 | [diff] [blame] | 231 | self.security_groups_client = SecurityGroupsClientXML( |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 232 | 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 Fazekas | 7e678de | 2013-07-13 14:13:28 +0200 | [diff] [blame] | 236 | self.availability_zone_client = AvailabilityZoneClientXML( |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 237 | 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 Frittoli | 8bbdb16 | 2014-01-06 11:06:13 +0000 | [diff] [blame] | 241 | self.tenant_usages_client = TenantUsagesClientXML( |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 242 | 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 Frittoli | 8bbdb16 | 2014-01-06 11:06:13 +0000 | [diff] [blame] | 247 | self.credentials_client = CredentialsClientXML( |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 248 | self.auth_provider) |
ivan-zhu | ef7a1bd | 2013-10-22 17:56:46 +0800 | [diff] [blame] | 249 | self.instance_usages_audit_log_client = \ |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 250 | InstanceUsagesAuditLogClientXML(self.auth_provider) |
Andrea Frittoli | 8bbdb16 | 2014-01-06 11:06:13 +0000 | [diff] [blame] | 251 | self.volume_hosts_client = VolumeHostsClientXML( |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 252 | self.auth_provider) |
Matthew Treinish | 2324e6b | 2013-10-21 20:25:17 +0000 | [diff] [blame] | 253 | self.volumes_extension_client = VolumeExtensionClientXML( |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 254 | self.auth_provider) |
Nikolay Pliashechnikov | b053aab | 2013-11-05 06:06:44 -0800 | [diff] [blame] | 255 | if CONF.service_available.ceilometer: |
Andrea Frittoli | 8bbdb16 | 2014-01-06 11:06:13 +0000 | [diff] [blame] | 256 | self.telemetry_client = TelemetryClientXML( |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 257 | self.auth_provider) |
Andrea Frittoli | 8bbdb16 | 2014-01-06 11:06:13 +0000 | [diff] [blame] | 258 | self.token_client = TokenClientXML() |
| 259 | self.token_v3_client = V3TokenClientXML() |
Brant Knudson | c7ca334 | 2013-03-28 21:08:50 -0500 | [diff] [blame] | 260 | |
Andrea Frittoli | 8bbdb16 | 2014-01-06 11:06:13 +0000 | [diff] [blame] | 261 | elif self.interface == 'json': |
| 262 | self.certificates_client = CertificatesClientJSON( |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 263 | self.auth_provider) |
ivan-zhu | 0e06292 | 2013-12-17 16:14:12 +0800 | [diff] [blame] | 264 | self.certificates_v3_client = CertificatesV3ClientJSON( |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 265 | 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 Frittoli | 8bbdb16 | 2014-01-06 11:06:13 +0000 | [diff] [blame] | 271 | self.keypairs_v3_client = KeyPairsV3ClientJSON( |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 272 | self.auth_provider) |
| 273 | self.keypairs_client = KeyPairsClientJSON(self.auth_provider) |
Andrea Frittoli | 8bbdb16 | 2014-01-06 11:06:13 +0000 | [diff] [blame] | 274 | self.keypairs_v3_client = KeyPairsV3ClientJSON( |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 275 | 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 Frittoli | 8bbdb16 | 2014-01-06 11:06:13 +0000 | [diff] [blame] | 280 | self.extensions_v3_client = ExtensionsV3ClientJSON( |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 281 | self.auth_provider) |
Andrea Frittoli | 8bbdb16 | 2014-01-06 11:06:13 +0000 | [diff] [blame] | 282 | self.extensions_client = ExtensionsClientJSON( |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 283 | self.auth_provider) |
Attila Fazekas | 7e678de | 2013-07-13 14:13:28 +0200 | [diff] [blame] | 284 | self.volumes_extensions_client = VolumesExtensionsClientJSON( |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 285 | self.auth_provider) |
Andrea Frittoli | 8bbdb16 | 2014-01-06 11:06:13 +0000 | [diff] [blame] | 286 | self.floating_ips_client = FloatingIPsClientJSON( |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 287 | 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 Frittoli | 8bbdb16 | 2014-01-06 11:06:13 +0000 | [diff] [blame] | 292 | self.volume_types_client = VolumeTypesClientJSON( |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 293 | self.auth_provider) |
| 294 | self.identity_client = IdentityClientJSON(self.auth_provider) |
Andrea Frittoli | 8bbdb16 | 2014-01-06 11:06:13 +0000 | [diff] [blame] | 295 | self.identity_v3_client = IdentityV3ClientJSON( |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 296 | self.auth_provider) |
Attila Fazekas | 7e678de | 2013-07-13 14:13:28 +0200 | [diff] [blame] | 297 | self.security_groups_client = SecurityGroupsClientJSON( |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 298 | self.auth_provider) |
Andrea Frittoli | 8bbdb16 | 2014-01-06 11:06:13 +0000 | [diff] [blame] | 299 | self.interfaces_v3_client = InterfacesV3ClientJSON( |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 300 | self.auth_provider) |
Andrea Frittoli | 8bbdb16 | 2014-01-06 11:06:13 +0000 | [diff] [blame] | 301 | self.interfaces_client = InterfacesClientJSON( |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 302 | self.auth_provider) |
| 303 | self.endpoints_client = EndPointClientJSON(self.auth_provider) |
| 304 | self.fixed_ips_client = FixedIPsClientJSON(self.auth_provider) |
ivan-zhu | ac7b380 | 2013-08-21 16:03:53 +0800 | [diff] [blame] | 305 | self.availability_zone_v3_client = AvailabilityZoneV3ClientJSON( |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 306 | self.auth_provider) |
Attila Fazekas | 7e678de | 2013-07-13 14:13:28 +0200 | [diff] [blame] | 307 | self.availability_zone_client = AvailabilityZoneClientJSON( |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 308 | self.auth_provider) |
Andrea Frittoli | 8bbdb16 | 2014-01-06 11:06:13 +0000 | [diff] [blame] | 309 | self.services_v3_client = ServicesV3ClientJSON( |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 310 | self.auth_provider) |
| 311 | self.service_client = ServiceClientJSON(self.auth_provider) |
Andrea Frittoli | 8bbdb16 | 2014-01-06 11:06:13 +0000 | [diff] [blame] | 312 | self.aggregates_v3_client = AggregatesV3ClientJSON( |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 313 | self.auth_provider) |
Andrea Frittoli | 8bbdb16 | 2014-01-06 11:06:13 +0000 | [diff] [blame] | 314 | self.aggregates_client = AggregatesClientJSON( |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 315 | self.auth_provider) |
| 316 | self.services_client = ServicesClientJSON(self.auth_provider) |
Andrea Frittoli | 8bbdb16 | 2014-01-06 11:06:13 +0000 | [diff] [blame] | 317 | self.tenant_usages_client = TenantUsagesClientJSON( |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 318 | 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 Frittoli | 8bbdb16 | 2014-01-06 11:06:13 +0000 | [diff] [blame] | 322 | self.hypervisor_v3_client = HypervisorV3ClientJSON( |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 323 | self.auth_provider) |
Andrea Frittoli | 8bbdb16 | 2014-01-06 11:06:13 +0000 | [diff] [blame] | 324 | self.hypervisor_client = HypervisorClientJSON( |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 325 | self.auth_provider) |
| 326 | self.network_client = NetworkClientJSON(self.auth_provider) |
Andrea Frittoli | 8bbdb16 | 2014-01-06 11:06:13 +0000 | [diff] [blame] | 327 | self.credentials_client = CredentialsClientJSON( |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 328 | self.auth_provider) |
ivan-zhu | ef7a1bd | 2013-10-22 17:56:46 +0800 | [diff] [blame] | 329 | self.instance_usages_audit_log_client = \ |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 330 | InstanceUsagesAuditLogClientJSON(self.auth_provider) |
Andrea Frittoli | 8bbdb16 | 2014-01-06 11:06:13 +0000 | [diff] [blame] | 331 | self.volume_hosts_client = VolumeHostsClientJSON( |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 332 | self.auth_provider) |
Matthew Treinish | 2324e6b | 2013-10-21 20:25:17 +0000 | [diff] [blame] | 333 | self.volumes_extension_client = VolumeExtensionClientJSON( |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 334 | self.auth_provider) |
| 335 | self.hosts_v3_client = HostsV3ClientJSON(self.auth_provider) |
Nikhil Manchanda | dd6886f | 2014-03-03 01:58:45 -0800 | [diff] [blame] | 336 | self.database_flavors_client = DatabaseFlavorsClientJSON( |
| 337 | self.auth_provider) |
Malini Kamalambal | 6e7b3b8 | 2014-02-06 06:49:04 -0500 | [diff] [blame^] | 338 | self.queuing_client = QueuingClientJSON(self.auth_provider) |
Nikolay Pliashechnikov | b053aab | 2013-11-05 06:06:44 -0800 | [diff] [blame] | 339 | if CONF.service_available.ceilometer: |
Andrea Frittoli | 8bbdb16 | 2014-01-06 11:06:13 +0000 | [diff] [blame] | 340 | self.telemetry_client = TelemetryClientJSON( |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 341 | self.auth_provider) |
Andrea Frittoli | 8bbdb16 | 2014-01-06 11:06:13 +0000 | [diff] [blame] | 342 | self.token_client = TokenClientJSON() |
| 343 | self.token_v3_client = V3TokenClientJSON() |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 344 | self.negative_client = NegativeRestClient(self.auth_provider) |
Marc Koderer | 24eb89c | 2014-01-31 11:23:33 +0100 | [diff] [blame] | 345 | self.negative_client.service = service |
Attila Fazekas | 7e678de | 2013-07-13 14:13:28 +0200 | [diff] [blame] | 346 | |
Attila Fazekas | 7e678de | 2013-07-13 14:13:28 +0200 | [diff] [blame] | 347 | else: |
Dan Smith | cf8fab6 | 2012-08-14 08:03:48 -0700 | [diff] [blame] | 348 | msg = "Unsupported interface type `%s'" % interface |
| 349 | raise exceptions.InvalidConfiguration(msg) |
Attila Fazekas | 7e678de | 2013-07-13 14:13:28 +0200 | [diff] [blame] | 350 | |
Andrea Frittoli | 8bbdb16 | 2014-01-06 11:06:13 +0000 | [diff] [blame] | 351 | # 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 Fazekas | 7e678de | 2013-07-13 14:13:28 +0200 | [diff] [blame] | 357 | # common clients |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 358 | self.account_client = AccountClient(self.auth_provider) |
Sean Dague | 86bd842 | 2013-12-20 09:56:44 -0500 | [diff] [blame] | 359 | if CONF.service_available.glance: |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 360 | 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 Frittoli | 8bbdb16 | 2014-01-06 11:06:13 +0000 | [diff] [blame] | 364 | self.orchestration_client = OrchestrationClient( |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 365 | self.auth_provider) |
Andrea Frittoli | 8bbdb16 | 2014-01-06 11:06:13 +0000 | [diff] [blame] | 366 | self.ec2api_client = botoclients.APIClientEC2(*ec2_client_args) |
| 367 | self.s3_client = botoclients.ObjectClientS3(*ec2_client_args) |
| 368 | self.custom_object_client = ObjectClientCustomizedHeader( |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 369 | self.auth_provider) |
harika-vakadi | 2daed0a | 2013-01-01 20:51:39 +0530 | [diff] [blame] | 370 | self.custom_account_client = \ |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 371 | AccountClientCustomizedHeader(self.auth_provider) |
Andrea Frittoli | 8bbdb16 | 2014-01-06 11:06:13 +0000 | [diff] [blame] | 372 | self.data_processing_client = DataProcessingClient( |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 373 | self.auth_provider) |
Jay Pipes | 5067728 | 2012-01-06 15:39:20 -0500 | [diff] [blame] | 374 | |
| 375 | |
Jay Pipes | ff10d55 | 2012-04-06 14:18:50 -0400 | [diff] [blame] | 376 | class AltManager(Manager): |
| 377 | |
| 378 | """ |
| 379 | Manager object that uses the alt_XXX credentials for its |
| 380 | managed client objects |
| 381 | """ |
| 382 | |
Marc Koderer | 24eb89c | 2014-01-31 11:23:33 +0100 | [diff] [blame] | 383 | def __init__(self, interface='json', service=None): |
Sean Dague | 86bd842 | 2013-12-20 09:56:44 -0500 | [diff] [blame] | 384 | super(AltManager, self).__init__(CONF.identity.alt_username, |
| 385 | CONF.identity.alt_password, |
| 386 | CONF.identity.alt_tenant_name, |
Marc Koderer | 24eb89c | 2014-01-31 11:23:33 +0100 | [diff] [blame] | 387 | interface=interface, |
| 388 | service=service) |
Jay Pipes | ff10d55 | 2012-04-06 14:18:50 -0400 | [diff] [blame] | 389 | |
| 390 | |
| 391 | class AdminManager(Manager): |
| 392 | |
| 393 | """ |
Attila Fazekas | cadcb1f | 2013-01-21 23:10:53 +0100 | [diff] [blame] | 394 | Manager object that uses the admin credentials for its |
Jay Pipes | ff10d55 | 2012-04-06 14:18:50 -0400 | [diff] [blame] | 395 | managed client objects |
| 396 | """ |
| 397 | |
Marc Koderer | 24eb89c | 2014-01-31 11:23:33 +0100 | [diff] [blame] | 398 | def __init__(self, interface='json', service=None): |
Sean Dague | 86bd842 | 2013-12-20 09:56:44 -0500 | [diff] [blame] | 399 | super(AdminManager, self).__init__(CONF.identity.admin_username, |
| 400 | CONF.identity.admin_password, |
| 401 | CONF.identity.admin_tenant_name, |
Marc Koderer | 24eb89c | 2014-01-31 11:23:33 +0100 | [diff] [blame] | 402 | interface=interface, |
| 403 | service=service) |
Jay Pipes | ff10d55 | 2012-04-06 14:18:50 -0400 | [diff] [blame] | 404 | |
| 405 | |
Attila Fazekas | cadcb1f | 2013-01-21 23:10:53 +0100 | [diff] [blame] | 406 | class ComputeAdminManager(Manager): |
| 407 | |
| 408 | """ |
| 409 | Manager object that uses the compute_admin credentials for its |
| 410 | managed client objects |
| 411 | """ |
| 412 | |
Marc Koderer | 24eb89c | 2014-01-31 11:23:33 +0100 | [diff] [blame] | 413 | def __init__(self, interface='json', service=None): |
Attila Fazekas | cadcb1f | 2013-01-21 23:10:53 +0100 | [diff] [blame] | 414 | base = super(ComputeAdminManager, self) |
Sean Dague | 86bd842 | 2013-12-20 09:56:44 -0500 | [diff] [blame] | 415 | base.__init__(CONF.compute_admin.username, |
| 416 | CONF.compute_admin.password, |
| 417 | CONF.compute_admin.tenant_name, |
Marc Koderer | 24eb89c | 2014-01-31 11:23:33 +0100 | [diff] [blame] | 418 | interface=interface, |
| 419 | service=service) |
Steve Baker | c60e4e3 | 2013-05-06 15:22:41 +1200 | [diff] [blame] | 420 | |
| 421 | |
| 422 | class OrchestrationManager(Manager): |
| 423 | """ |
| 424 | Manager object that uses the admin credentials for its |
| 425 | so that heat templates can create users |
| 426 | """ |
Marc Koderer | 24eb89c | 2014-01-31 11:23:33 +0100 | [diff] [blame] | 427 | def __init__(self, interface='json', service=None): |
Steve Baker | c60e4e3 | 2013-05-06 15:22:41 +1200 | [diff] [blame] | 428 | base = super(OrchestrationManager, self) |
Steve Baker | b07f974 | 2014-02-19 10:03:57 +1300 | [diff] [blame] | 429 | # 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 Dague | 86bd842 | 2013-12-20 09:56:44 -0500 | [diff] [blame] | 433 | base.__init__(CONF.identity.admin_username, |
| 434 | CONF.identity.admin_password, |
Steve Baker | b07f974 | 2014-02-19 10:03:57 +1300 | [diff] [blame] | 435 | CONF.identity.tenant_name, |
Marc Koderer | 24eb89c | 2014-01-31 11:23:33 +0100 | [diff] [blame] | 436 | interface=interface, |
| 437 | service=service) |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 438 | |
| 439 | |
| 440 | class 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) |