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 | |
Ken'ichi Ohmichi | 4771cbc | 2015-01-19 23:45:23 +0000 | [diff] [blame] | 16 | import copy |
| 17 | |
Doug Hellmann | 583ce2c | 2015-03-11 14:55:46 +0000 | [diff] [blame] | 18 | from oslo_log import log as logging |
| 19 | |
Ken'ichi Ohmichi | 4266268 | 2015-01-05 05:00:04 +0000 | [diff] [blame] | 20 | from tempest.common import negative_rest_client |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 21 | from tempest import config |
Andrea Frittoli (andreaf) | 03e546f | 2015-05-13 12:44:47 +0100 | [diff] [blame] | 22 | from tempest import exceptions |
Andrea Frittoli (andreaf) | 76a4b4e | 2016-06-14 23:28:16 +0100 | [diff] [blame] | 23 | from tempest.lib.services import compute |
Andrea Frittoli (andreaf) | fa991be | 2016-06-17 11:46:14 +0100 | [diff] [blame] | 24 | from tempest.lib.services import network |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 25 | from tempest import manager |
Andrea Frittoli (andreaf) | c33486f | 2016-06-17 12:22:08 +0100 | [diff] [blame^] | 26 | from tempest.services import baremetal |
| 27 | from tempest.services import data_processing |
| 28 | from tempest.services import database |
Andrea Frittoli (andreaf) | 6cb6b13 | 2016-06-17 11:39:10 +0100 | [diff] [blame] | 29 | from tempest.services import identity |
Andrea Frittoli (andreaf) | 26300f9 | 2016-06-17 12:14:00 +0100 | [diff] [blame] | 30 | from tempest.services import image |
Andrea Frittoli (andreaf) | 9a22543 | 2016-06-17 12:16:22 +0100 | [diff] [blame] | 31 | from tempest.services import object_storage |
Andrea Frittoli (andreaf) | c33486f | 2016-06-17 12:22:08 +0100 | [diff] [blame^] | 32 | from tempest.services import orchestration |
Andrea Frittoli (andreaf) | 14ecae1 | 2016-06-17 11:56:24 +0100 | [diff] [blame] | 33 | from tempest.services import volume |
Vincent Hou | 6b8a7b7 | 2012-08-25 01:24:33 +0800 | [diff] [blame] | 34 | |
Sean Dague | 86bd842 | 2013-12-20 09:56:44 -0500 | [diff] [blame] | 35 | CONF = config.CONF |
Jay Pipes | 3f981df | 2012-03-27 18:59:44 -0400 | [diff] [blame] | 36 | LOG = logging.getLogger(__name__) |
| 37 | |
Vincent Hou | 6b8a7b7 | 2012-08-25 01:24:33 +0800 | [diff] [blame] | 38 | |
Andrea Frittoli | f9cde7e | 2014-02-18 09:57:04 +0000 | [diff] [blame] | 39 | class Manager(manager.Manager): |
Ken'ichi Ohmichi | 2e2ee19 | 2015-11-19 09:48:27 +0000 | [diff] [blame] | 40 | """Top level manager for OpenStack tempest clients""" |
Jay Pipes | 3f981df | 2012-03-27 18:59:44 -0400 | [diff] [blame] | 41 | |
Ken'ichi Ohmichi | c2b11ce | 2015-01-16 07:17:29 +0000 | [diff] [blame] | 42 | default_params = { |
| 43 | 'disable_ssl_certificate_validation': |
| 44 | CONF.identity.disable_ssl_certificate_validation, |
| 45 | 'ca_certs': CONF.identity.ca_certificates_file, |
| 46 | 'trace_requests': CONF.debug.trace_requests |
| 47 | } |
| 48 | |
Ken'ichi Ohmichi | 737a603 | 2015-01-21 07:04:42 +0000 | [diff] [blame] | 49 | # NOTE: Tempest uses timeout values of compute API if project specific |
| 50 | # timeout values don't exist. |
| 51 | default_params_with_timeout_values = { |
| 52 | 'build_interval': CONF.compute.build_interval, |
| 53 | 'build_timeout': CONF.compute.build_timeout |
| 54 | } |
| 55 | default_params_with_timeout_values.update(default_params) |
| 56 | |
Andrea Frittoli (andreaf) | 3e82af7 | 2016-05-05 22:53:38 +0100 | [diff] [blame] | 57 | def __init__(self, credentials, service=None, scope='project'): |
ghanshyam | 4e2be34 | 2015-11-27 18:07:46 +0900 | [diff] [blame] | 58 | """Initialization of Manager class. |
Brant Knudson | c7ca334 | 2013-03-28 21:08:50 -0500 | [diff] [blame] | 59 | |
ghanshyam | 4e2be34 | 2015-11-27 18:07:46 +0900 | [diff] [blame] | 60 | Setup all services clients and make them available for tests cases. |
| 61 | :param credentials: type Credentials or TestResources |
| 62 | :param service: Service name |
Andrea Frittoli (andreaf) | 3e82af7 | 2016-05-05 22:53:38 +0100 | [diff] [blame] | 63 | :param scope: default scope for tokens produced by the auth provider |
ghanshyam | 4e2be34 | 2015-11-27 18:07:46 +0900 | [diff] [blame] | 64 | """ |
Andrea Frittoli (andreaf) | 3e82af7 | 2016-05-05 22:53:38 +0100 | [diff] [blame] | 65 | super(Manager, self).__init__(credentials=credentials, scope=scope) |
Ken'ichi Ohmichi | 80ec0b9 | 2015-01-16 06:43:10 +0000 | [diff] [blame] | 66 | self._set_compute_clients() |
ravikumar-venkatesan | 9e81b44 | 2014-12-08 09:57:56 +0000 | [diff] [blame] | 67 | self._set_database_clients() |
Ken'ichi Ohmichi | 80ec0b9 | 2015-01-16 06:43:10 +0000 | [diff] [blame] | 68 | self._set_identity_clients() |
| 69 | self._set_volume_clients() |
Ken'ichi Ohmichi | c95eb85 | 2015-01-22 01:57:57 +0000 | [diff] [blame] | 70 | self._set_object_storage_clients() |
Andrea Frittoli (andreaf) | 591e854 | 2016-06-07 18:31:39 +0100 | [diff] [blame] | 71 | self._set_image_clients() |
Andrea Frittoli (andreaf) | 11e1e88 | 2016-06-07 18:35:58 +0100 | [diff] [blame] | 72 | self._set_network_clients() |
Ken'ichi Ohmichi | cd4a51e | 2014-11-13 07:25:33 +0000 | [diff] [blame] | 73 | |
Andrea Frittoli (andreaf) | c33486f | 2016-06-17 12:22:08 +0100 | [diff] [blame^] | 74 | self.baremetal_client = baremetal.BaremetalClient( |
Ken'ichi Ohmichi | 1f88ece | 2015-01-23 03:33:11 +0000 | [diff] [blame] | 75 | self.auth_provider, |
| 76 | CONF.baremetal.catalog_type, |
| 77 | CONF.identity.region, |
| 78 | endpoint_type=CONF.baremetal.endpoint_type, |
| 79 | **self.default_params_with_timeout_values) |
Andrea Frittoli (andreaf) | c33486f | 2016-06-17 12:22:08 +0100 | [diff] [blame^] | 80 | self.orchestration_client = orchestration.OrchestrationClient( |
Ken'ichi Ohmichi | c2b11ce | 2015-01-16 07:17:29 +0000 | [diff] [blame] | 81 | self.auth_provider, |
| 82 | CONF.orchestration.catalog_type, |
| 83 | CONF.orchestration.region or CONF.identity.region, |
| 84 | endpoint_type=CONF.orchestration.endpoint_type, |
| 85 | build_interval=CONF.orchestration.build_interval, |
| 86 | build_timeout=CONF.orchestration.build_timeout, |
| 87 | **self.default_params) |
Andrea Frittoli (andreaf) | c33486f | 2016-06-17 12:22:08 +0100 | [diff] [blame^] | 88 | self.data_processing_client = data_processing.DataProcessingClient( |
Ken'ichi Ohmichi | 4e83b5e | 2015-02-13 04:07:34 +0000 | [diff] [blame] | 89 | self.auth_provider, |
| 90 | CONF.data_processing.catalog_type, |
| 91 | CONF.identity.region, |
| 92 | endpoint_type=CONF.data_processing.endpoint_type, |
| 93 | **self.default_params_with_timeout_values) |
Ken'ichi Ohmichi | b38eb00 | 2015-01-23 02:35:01 +0000 | [diff] [blame] | 94 | self.negative_client = negative_rest_client.NegativeRestClient( |
David Kranz | 1e33e37 | 2015-03-20 09:42:56 -0400 | [diff] [blame] | 95 | self.auth_provider, service, **self.default_params) |
Ken'ichi Ohmichi | c2b11ce | 2015-01-16 07:17:29 +0000 | [diff] [blame] | 96 | |
Andrea Frittoli (andreaf) | 11e1e88 | 2016-06-07 18:35:58 +0100 | [diff] [blame] | 97 | def _set_network_clients(self): |
| 98 | params = { |
| 99 | 'service': CONF.network.catalog_type, |
| 100 | 'region': CONF.network.region or CONF.identity.region, |
| 101 | 'endpoint_type': CONF.network.endpoint_type, |
| 102 | 'build_interval': CONF.network.build_interval, |
| 103 | 'build_timeout': CONF.network.build_timeout |
| 104 | } |
| 105 | params.update(self.default_params) |
Andrea Frittoli (andreaf) | fa991be | 2016-06-17 11:46:14 +0100 | [diff] [blame] | 106 | self.network_agents_client = network.AgentsClient( |
Andrea Frittoli (andreaf) | 11e1e88 | 2016-06-07 18:35:58 +0100 | [diff] [blame] | 107 | self.auth_provider, **params) |
Andrea Frittoli (andreaf) | fa991be | 2016-06-17 11:46:14 +0100 | [diff] [blame] | 108 | self.network_extensions_client = network.ExtensionsClient( |
Andrea Frittoli (andreaf) | 11e1e88 | 2016-06-07 18:35:58 +0100 | [diff] [blame] | 109 | self.auth_provider, **params) |
Andrea Frittoli (andreaf) | fa991be | 2016-06-17 11:46:14 +0100 | [diff] [blame] | 110 | self.networks_client = network.NetworksClient( |
Andrea Frittoli (andreaf) | 11e1e88 | 2016-06-07 18:35:58 +0100 | [diff] [blame] | 111 | self.auth_provider, **params) |
Andrea Frittoli (andreaf) | fa991be | 2016-06-17 11:46:14 +0100 | [diff] [blame] | 112 | self.subnetpools_client = network.SubnetpoolsClient( |
Andrea Frittoli (andreaf) | 11e1e88 | 2016-06-07 18:35:58 +0100 | [diff] [blame] | 113 | self.auth_provider, **params) |
Andrea Frittoli (andreaf) | fa991be | 2016-06-17 11:46:14 +0100 | [diff] [blame] | 114 | self.subnets_client = network.SubnetsClient( |
Andrea Frittoli (andreaf) | 11e1e88 | 2016-06-07 18:35:58 +0100 | [diff] [blame] | 115 | self.auth_provider, **params) |
Andrea Frittoli (andreaf) | fa991be | 2016-06-17 11:46:14 +0100 | [diff] [blame] | 116 | self.ports_client = network.PortsClient( |
Andrea Frittoli (andreaf) | 11e1e88 | 2016-06-07 18:35:58 +0100 | [diff] [blame] | 117 | self.auth_provider, **params) |
Andrea Frittoli (andreaf) | fa991be | 2016-06-17 11:46:14 +0100 | [diff] [blame] | 118 | self.network_quotas_client = network.QuotasClient( |
Andrea Frittoli (andreaf) | 11e1e88 | 2016-06-07 18:35:58 +0100 | [diff] [blame] | 119 | self.auth_provider, **params) |
Andrea Frittoli (andreaf) | fa991be | 2016-06-17 11:46:14 +0100 | [diff] [blame] | 120 | self.floating_ips_client = network.FloatingIPsClient( |
Andrea Frittoli (andreaf) | 11e1e88 | 2016-06-07 18:35:58 +0100 | [diff] [blame] | 121 | self.auth_provider, **params) |
Andrea Frittoli (andreaf) | fa991be | 2016-06-17 11:46:14 +0100 | [diff] [blame] | 122 | self.metering_labels_client = network.MeteringLabelsClient( |
Andrea Frittoli (andreaf) | 11e1e88 | 2016-06-07 18:35:58 +0100 | [diff] [blame] | 123 | self.auth_provider, **params) |
Andrea Frittoli (andreaf) | fa991be | 2016-06-17 11:46:14 +0100 | [diff] [blame] | 124 | self.metering_label_rules_client = network.MeteringLabelRulesClient( |
Andrea Frittoli (andreaf) | 11e1e88 | 2016-06-07 18:35:58 +0100 | [diff] [blame] | 125 | self.auth_provider, **params) |
Andrea Frittoli (andreaf) | fa991be | 2016-06-17 11:46:14 +0100 | [diff] [blame] | 126 | self.routers_client = network.RoutersClient( |
Andrea Frittoli (andreaf) | 11e1e88 | 2016-06-07 18:35:58 +0100 | [diff] [blame] | 127 | self.auth_provider, **params) |
Andrea Frittoli (andreaf) | fa991be | 2016-06-17 11:46:14 +0100 | [diff] [blame] | 128 | self.security_group_rules_client = network.SecurityGroupRulesClient( |
Andrea Frittoli (andreaf) | 11e1e88 | 2016-06-07 18:35:58 +0100 | [diff] [blame] | 129 | self.auth_provider, **params) |
Andrea Frittoli (andreaf) | fa991be | 2016-06-17 11:46:14 +0100 | [diff] [blame] | 130 | self.security_groups_client = network.SecurityGroupsClient( |
Andrea Frittoli (andreaf) | 11e1e88 | 2016-06-07 18:35:58 +0100 | [diff] [blame] | 131 | self.auth_provider, **params) |
Andrea Frittoli (andreaf) | fa991be | 2016-06-17 11:46:14 +0100 | [diff] [blame] | 132 | self.network_versions_client = network.NetworkVersionsClient( |
Mark T. Voelker | abd4cbd | 2016-04-29 12:03:04 -0500 | [diff] [blame] | 133 | self.auth_provider, **params) |
Andrea Frittoli (andreaf) | 11e1e88 | 2016-06-07 18:35:58 +0100 | [diff] [blame] | 134 | |
Andrea Frittoli (andreaf) | 591e854 | 2016-06-07 18:31:39 +0100 | [diff] [blame] | 135 | def _set_image_clients(self): |
| 136 | params = { |
| 137 | 'service': CONF.image.catalog_type, |
| 138 | 'region': CONF.image.region or CONF.identity.region, |
| 139 | 'endpoint_type': CONF.image.endpoint_type, |
| 140 | 'build_interval': CONF.image.build_interval, |
| 141 | 'build_timeout': CONF.image.build_timeout |
| 142 | } |
| 143 | params.update(self.default_params) |
| 144 | |
| 145 | if CONF.service_available.glance: |
Andrea Frittoli (andreaf) | 26300f9 | 2016-06-17 12:14:00 +0100 | [diff] [blame] | 146 | self.image_client = image.v1.ImagesClient( |
Andrea Frittoli (andreaf) | 591e854 | 2016-06-07 18:31:39 +0100 | [diff] [blame] | 147 | self.auth_provider, **params) |
Andrea Frittoli (andreaf) | 26300f9 | 2016-06-17 12:14:00 +0100 | [diff] [blame] | 148 | self.image_member_client = image.v1.ImageMembersClient( |
Andrea Frittoli (andreaf) | 591e854 | 2016-06-07 18:31:39 +0100 | [diff] [blame] | 149 | self.auth_provider, **params) |
Andrea Frittoli (andreaf) | 26300f9 | 2016-06-17 12:14:00 +0100 | [diff] [blame] | 150 | self.image_client_v2 = image.v2.ImagesClient( |
Andrea Frittoli (andreaf) | 591e854 | 2016-06-07 18:31:39 +0100 | [diff] [blame] | 151 | self.auth_provider, **params) |
Andrea Frittoli (andreaf) | 26300f9 | 2016-06-17 12:14:00 +0100 | [diff] [blame] | 152 | self.image_member_client_v2 = image.v2.ImageMembersClient( |
Andrea Frittoli (andreaf) | 591e854 | 2016-06-07 18:31:39 +0100 | [diff] [blame] | 153 | self.auth_provider, **params) |
Andrea Frittoli (andreaf) | 26300f9 | 2016-06-17 12:14:00 +0100 | [diff] [blame] | 154 | self.namespaces_client = image.v2.NamespacesClient( |
Andrea Frittoli (andreaf) | 591e854 | 2016-06-07 18:31:39 +0100 | [diff] [blame] | 155 | self.auth_provider, **params) |
Andrea Frittoli (andreaf) | 26300f9 | 2016-06-17 12:14:00 +0100 | [diff] [blame] | 156 | self.resource_types_client = image.v2.ResourceTypesClient( |
Andrea Frittoli (andreaf) | 591e854 | 2016-06-07 18:31:39 +0100 | [diff] [blame] | 157 | self.auth_provider, **params) |
Andrea Frittoli (andreaf) | 26300f9 | 2016-06-17 12:14:00 +0100 | [diff] [blame] | 158 | self.schemas_client = image.v2.SchemasClient( |
Andrea Frittoli (andreaf) | 591e854 | 2016-06-07 18:31:39 +0100 | [diff] [blame] | 159 | self.auth_provider, **params) |
| 160 | |
Ken'ichi Ohmichi | 80ec0b9 | 2015-01-16 06:43:10 +0000 | [diff] [blame] | 161 | def _set_compute_clients(self): |
Ken'ichi Ohmichi | 4771cbc | 2015-01-19 23:45:23 +0000 | [diff] [blame] | 162 | params = { |
| 163 | 'service': CONF.compute.catalog_type, |
| 164 | 'region': CONF.compute.region or CONF.identity.region, |
| 165 | 'endpoint_type': CONF.compute.endpoint_type, |
| 166 | 'build_interval': CONF.compute.build_interval, |
| 167 | 'build_timeout': CONF.compute.build_timeout |
| 168 | } |
| 169 | params.update(self.default_params) |
| 170 | |
Andrea Frittoli (andreaf) | 76a4b4e | 2016-06-14 23:28:16 +0100 | [diff] [blame] | 171 | self.agents_client = compute.AgentsClient(self.auth_provider, **params) |
| 172 | self.compute_networks_client = compute.NetworksClient( |
John Warren | 9487a18 | 2015-09-14 18:12:56 -0400 | [diff] [blame] | 173 | self.auth_provider, **params) |
Andrea Frittoli (andreaf) | 76a4b4e | 2016-06-14 23:28:16 +0100 | [diff] [blame] | 174 | self.migrations_client = compute.MigrationsClient(self.auth_provider, |
| 175 | **params) |
Ken'ichi Ohmichi | 65225ef | 2014-11-19 01:06:25 +0000 | [diff] [blame] | 176 | self.security_group_default_rules_client = ( |
Andrea Frittoli (andreaf) | 76a4b4e | 2016-06-14 23:28:16 +0100 | [diff] [blame] | 177 | compute.SecurityGroupDefaultRulesClient(self.auth_provider, |
| 178 | **params)) |
| 179 | self.certificates_client = compute.CertificatesClient( |
| 180 | self.auth_provider, **params) |
| 181 | self.servers_client = compute.ServersClient( |
Masayuki Igawa | 8f9c0c8 | 2015-03-03 09:38:08 +0900 | [diff] [blame] | 182 | self.auth_provider, |
| 183 | enable_instance_password=CONF.compute_feature_enabled |
| 184 | .enable_instance_password, |
| 185 | **params) |
Andrea Frittoli (andreaf) | 76a4b4e | 2016-06-14 23:28:16 +0100 | [diff] [blame] | 186 | self.server_groups_client = compute.ServerGroupsClient( |
Ken'ichi Ohmichi | 7ca54b8 | 2015-07-07 01:10:26 +0000 | [diff] [blame] | 187 | self.auth_provider, **params) |
Andrea Frittoli (andreaf) | 76a4b4e | 2016-06-14 23:28:16 +0100 | [diff] [blame] | 188 | self.limits_client = compute.LimitsClient(self.auth_provider, **params) |
| 189 | self.compute_images_client = compute.ImagesClient(self.auth_provider, |
| 190 | **params) |
| 191 | self.keypairs_client = compute.KeyPairsClient(self.auth_provider, |
| 192 | **params) |
| 193 | self.quotas_client = compute.QuotasClient(self.auth_provider, **params) |
| 194 | self.quota_classes_client = compute.QuotaClassesClient( |
| 195 | self.auth_provider, **params) |
| 196 | self.flavors_client = compute.FlavorsClient(self.auth_provider, |
| 197 | **params) |
| 198 | self.extensions_client = compute.ExtensionsClient(self.auth_provider, |
| 199 | **params) |
| 200 | self.floating_ip_pools_client = compute.FloatingIPPoolsClient( |
| 201 | self.auth_provider, **params) |
| 202 | self.floating_ips_bulk_client = compute.FloatingIPsBulkClient( |
| 203 | self.auth_provider, **params) |
| 204 | self.compute_floating_ips_client = compute.FloatingIPsClient( |
| 205 | self.auth_provider, **params) |
| 206 | self.compute_security_group_rules_client = ( |
| 207 | compute.SecurityGroupRulesClient(self.auth_provider, **params)) |
| 208 | self.compute_security_groups_client = compute.SecurityGroupsClient( |
| 209 | self.auth_provider, **params) |
| 210 | self.interfaces_client = compute.InterfacesClient(self.auth_provider, |
| 211 | **params) |
| 212 | self.fixed_ips_client = compute.FixedIPsClient(self.auth_provider, |
Ken'ichi Ohmichi | a628707 | 2015-07-02 02:43:15 +0000 | [diff] [blame] | 213 | **params) |
Andrea Frittoli (andreaf) | 76a4b4e | 2016-06-14 23:28:16 +0100 | [diff] [blame] | 214 | self.availability_zone_client = compute.AvailabilityZoneClient( |
Ken'ichi Ohmichi | 03af1c5 | 2015-07-13 00:28:05 +0000 | [diff] [blame] | 215 | self.auth_provider, **params) |
Andrea Frittoli (andreaf) | 76a4b4e | 2016-06-14 23:28:16 +0100 | [diff] [blame] | 216 | self.aggregates_client = compute.AggregatesClient(self.auth_provider, |
| 217 | **params) |
| 218 | self.services_client = compute.ServicesClient(self.auth_provider, |
| 219 | **params) |
| 220 | self.tenant_usages_client = compute.TenantUsagesClient( |
Ken'ichi Ohmichi | 2b26e75 | 2015-07-13 00:44:36 +0000 | [diff] [blame] | 221 | self.auth_provider, **params) |
Andrea Frittoli (andreaf) | 76a4b4e | 2016-06-14 23:28:16 +0100 | [diff] [blame] | 222 | self.hosts_client = compute.HostsClient(self.auth_provider, **params) |
| 223 | self.hypervisor_client = compute.HypervisorClient(self.auth_provider, |
| 224 | **params) |
| 225 | self.instance_usages_audit_log_client = ( |
| 226 | compute.InstanceUsagesAuditLogClient(self.auth_provider, **params)) |
| 227 | self.tenant_networks_client = compute.TenantNetworksClient( |
John Warren | e74890a | 2015-11-11 15:18:01 -0500 | [diff] [blame] | 228 | self.auth_provider, **params) |
Andrea Frittoli (andreaf) | 76a4b4e | 2016-06-14 23:28:16 +0100 | [diff] [blame] | 229 | self.baremetal_nodes_client = compute.BaremetalNodesClient( |
YuikoTakada | ac0879a | 2015-01-22 02:40:03 +0000 | [diff] [blame] | 230 | self.auth_provider, **params) |
Ken'ichi Ohmichi | 4771cbc | 2015-01-19 23:45:23 +0000 | [diff] [blame] | 231 | |
| 232 | # NOTE: The following client needs special timeout values because |
| 233 | # the API is a proxy for the other component. |
| 234 | params_volume = copy.deepcopy(params) |
| 235 | params_volume.update({ |
| 236 | 'build_interval': CONF.volume.build_interval, |
| 237 | 'build_timeout': CONF.volume.build_timeout |
| 238 | }) |
Andrea Frittoli (andreaf) | 76a4b4e | 2016-06-14 23:28:16 +0100 | [diff] [blame] | 239 | self.volumes_extensions_client = compute.VolumesClient( |
Ken'ichi Ohmichi | c492178 | 2015-08-05 08:14:42 +0000 | [diff] [blame] | 240 | self.auth_provider, **params_volume) |
Andrea Frittoli (andreaf) | 76a4b4e | 2016-06-14 23:28:16 +0100 | [diff] [blame] | 241 | self.compute_versions_client = compute.VersionsClient( |
| 242 | self.auth_provider, **params_volume) |
| 243 | self.snapshots_extensions_client = compute.SnapshotsClient( |
Gaozexu | b9c9d6e | 2015-09-10 17:08:04 +0800 | [diff] [blame] | 244 | self.auth_provider, **params_volume) |
Ken'ichi Ohmichi | cd4a51e | 2014-11-13 07:25:33 +0000 | [diff] [blame] | 245 | |
ravikumar-venkatesan | 9e81b44 | 2014-12-08 09:57:56 +0000 | [diff] [blame] | 246 | def _set_database_clients(self): |
Andrea Frittoli (andreaf) | c33486f | 2016-06-17 12:22:08 +0100 | [diff] [blame^] | 247 | self.database_flavors_client = database.DatabaseFlavorsClient( |
ravikumar-venkatesan | 9e81b44 | 2014-12-08 09:57:56 +0000 | [diff] [blame] | 248 | self.auth_provider, |
| 249 | CONF.database.catalog_type, |
| 250 | CONF.identity.region, |
| 251 | **self.default_params_with_timeout_values) |
Andrea Frittoli (andreaf) | c33486f | 2016-06-17 12:22:08 +0100 | [diff] [blame^] | 252 | self.database_limits_client = database.DatabaseLimitsClient( |
ravikumar-venkatesan | 9e81b44 | 2014-12-08 09:57:56 +0000 | [diff] [blame] | 253 | self.auth_provider, |
| 254 | CONF.database.catalog_type, |
| 255 | CONF.identity.region, |
| 256 | **self.default_params_with_timeout_values) |
Andrea Frittoli (andreaf) | c33486f | 2016-06-17 12:22:08 +0100 | [diff] [blame^] | 257 | self.database_versions_client = database.DatabaseVersionsClient( |
ravikumar-venkatesan | 9e81b44 | 2014-12-08 09:57:56 +0000 | [diff] [blame] | 258 | self.auth_provider, |
| 259 | CONF.database.catalog_type, |
| 260 | CONF.identity.region, |
| 261 | **self.default_params_with_timeout_values) |
| 262 | |
Ken'ichi Ohmichi | 80ec0b9 | 2015-01-16 06:43:10 +0000 | [diff] [blame] | 263 | def _set_identity_clients(self): |
ghanshyam | d26b5cd | 2015-02-09 14:48:58 +0900 | [diff] [blame] | 264 | params = { |
| 265 | 'service': CONF.identity.catalog_type, |
Jane Zadorozhna | c786213 | 2015-07-10 14:34:50 +0300 | [diff] [blame] | 266 | 'region': CONF.identity.region |
ghanshyam | d26b5cd | 2015-02-09 14:48:58 +0900 | [diff] [blame] | 267 | } |
| 268 | params.update(self.default_params_with_timeout_values) |
Yaroslav Lobankov | cd97fea | 2016-01-13 19:59:52 +0300 | [diff] [blame] | 269 | |
| 270 | # Clients below use the admin endpoint type of Keystone API v2 |
Jane Zadorozhna | c786213 | 2015-07-10 14:34:50 +0300 | [diff] [blame] | 271 | params_v2_admin = params.copy() |
| 272 | params_v2_admin['endpoint_type'] = CONF.identity.v2_admin_endpoint_type |
Andrea Frittoli (andreaf) | 6cb6b13 | 2016-06-17 11:39:10 +0100 | [diff] [blame] | 273 | self.endpoints_client = identity.v2.EndpointsClient(self.auth_provider, |
| 274 | **params_v2_admin) |
| 275 | self.identity_client = identity.v2.IdentityClient(self.auth_provider, |
| 276 | **params_v2_admin) |
| 277 | self.tenants_client = identity.v2.TenantsClient(self.auth_provider, |
| 278 | **params_v2_admin) |
| 279 | self.roles_client = identity.v2.RolesClient(self.auth_provider, |
| 280 | **params_v2_admin) |
| 281 | self.users_client = identity.v2.UsersClient(self.auth_provider, |
| 282 | **params_v2_admin) |
| 283 | self.identity_services_client = identity.v2.ServicesClient( |
Yaroslav Lobankov | f6906e1 | 2016-02-26 19:44:53 -0600 | [diff] [blame] | 284 | self.auth_provider, **params_v2_admin) |
Yaroslav Lobankov | cd97fea | 2016-01-13 19:59:52 +0300 | [diff] [blame] | 285 | |
| 286 | # Clients below use the public endpoint type of Keystone API v2 |
Jane Zadorozhna | c786213 | 2015-07-10 14:34:50 +0300 | [diff] [blame] | 287 | params_v2_public = params.copy() |
| 288 | params_v2_public['endpoint_type'] = ( |
| 289 | CONF.identity.v2_public_endpoint_type) |
Andrea Frittoli (andreaf) | 6cb6b13 | 2016-06-17 11:39:10 +0100 | [diff] [blame] | 290 | self.identity_public_client = identity.v2.IdentityClient( |
| 291 | self.auth_provider, **params_v2_public) |
| 292 | self.tenants_public_client = identity.v2.TenantsClient( |
| 293 | self.auth_provider, **params_v2_public) |
| 294 | self.users_public_client = identity.v2.UsersClient( |
| 295 | self.auth_provider, **params_v2_public) |
Yaroslav Lobankov | cd97fea | 2016-01-13 19:59:52 +0300 | [diff] [blame] | 296 | |
| 297 | # Clients below use the endpoint type of Keystone API v3 |
Jane Zadorozhna | c786213 | 2015-07-10 14:34:50 +0300 | [diff] [blame] | 298 | params_v3 = params.copy() |
| 299 | params_v3['endpoint_type'] = CONF.identity.v3_endpoint_type |
Andrea Frittoli (andreaf) | 6cb6b13 | 2016-06-17 11:39:10 +0100 | [diff] [blame] | 300 | self.domains_client = identity.v3.DomainsClient(self.auth_provider, |
| 301 | **params_v3) |
| 302 | self.identity_v3_client = identity.v3.IdentityClient( |
Yaroslav Lobankov | 69d9056 | 2015-12-18 12:06:40 +0300 | [diff] [blame] | 303 | self.auth_provider, **params_v3) |
Andrea Frittoli (andreaf) | 6cb6b13 | 2016-06-17 11:39:10 +0100 | [diff] [blame] | 304 | self.trusts_client = identity.v3.TrustsClient(self.auth_provider, |
| 305 | **params_v3) |
| 306 | self.users_v3_client = identity.v3.UsersClient(self.auth_provider, |
| 307 | **params_v3) |
| 308 | self.endpoints_v3_client = identity.v3.EndPointsClient( |
| 309 | self.auth_provider, **params_v3) |
| 310 | self.roles_v3_client = identity.v3.RolesClient(self.auth_provider, |
| 311 | **params_v3) |
| 312 | self.identity_services_v3_client = identity.v3.ServicesClient( |
| 313 | self.auth_provider, **params_v3) |
| 314 | self.policies_client = identity.v3.PoliciesClient(self.auth_provider, |
| 315 | **params_v3) |
| 316 | self.projects_client = identity.v3.ProjectsClient(self.auth_provider, |
| 317 | **params_v3) |
| 318 | self.regions_client = identity.v3.RegionsClient(self.auth_provider, |
| 319 | **params_v3) |
| 320 | self.credentials_client = identity.v3.CredentialsClient( |
| 321 | self.auth_provider, **params_v3) |
| 322 | self.groups_client = identity.v3.GroupsClient(self.auth_provider, |
| 323 | **params_v3) |
Yaroslav Lobankov | cd97fea | 2016-01-13 19:59:52 +0300 | [diff] [blame] | 324 | |
Andrea Frittoli | 9001235 | 2015-02-25 21:58:02 +0000 | [diff] [blame] | 325 | # Token clients do not use the catalog. They only need default_params. |
Andrea Frittoli (andreaf) | 03e546f | 2015-05-13 12:44:47 +0100 | [diff] [blame] | 326 | # They read auth_url, so they should only be set if the corresponding |
| 327 | # API version is marked as enabled |
| 328 | if CONF.identity_feature_enabled.api_v2: |
| 329 | if CONF.identity.uri: |
Andrea Frittoli (andreaf) | 6cb6b13 | 2016-06-17 11:39:10 +0100 | [diff] [blame] | 330 | self.token_client = identity.v2.TokenClient( |
Andrea Frittoli (andreaf) | 03e546f | 2015-05-13 12:44:47 +0100 | [diff] [blame] | 331 | CONF.identity.uri, **self.default_params) |
| 332 | else: |
| 333 | msg = 'Identity v2 API enabled, but no identity.uri set' |
| 334 | raise exceptions.InvalidConfiguration(msg) |
Ken'ichi Ohmichi | 41951b0 | 2014-11-19 01:57:43 +0000 | [diff] [blame] | 335 | if CONF.identity_feature_enabled.api_v3: |
Andrea Frittoli (andreaf) | 03e546f | 2015-05-13 12:44:47 +0100 | [diff] [blame] | 336 | if CONF.identity.uri_v3: |
Andrea Frittoli (andreaf) | 6cb6b13 | 2016-06-17 11:39:10 +0100 | [diff] [blame] | 337 | self.token_v3_client = identity.v3.V3TokenClient( |
Andrea Frittoli (andreaf) | 03e546f | 2015-05-13 12:44:47 +0100 | [diff] [blame] | 338 | CONF.identity.uri_v3, **self.default_params) |
| 339 | else: |
| 340 | msg = 'Identity v3 API enabled, but no identity.uri_v3 set' |
| 341 | raise exceptions.InvalidConfiguration(msg) |
Ken'ichi Ohmichi | 41951b0 | 2014-11-19 01:57:43 +0000 | [diff] [blame] | 342 | |
Ken'ichi Ohmichi | 80ec0b9 | 2015-01-16 06:43:10 +0000 | [diff] [blame] | 343 | def _set_volume_clients(self): |
Ken'ichi Ohmichi | f85e9bd | 2015-01-27 12:51:47 +0000 | [diff] [blame] | 344 | params = { |
| 345 | 'service': CONF.volume.catalog_type, |
| 346 | 'region': CONF.volume.region or CONF.identity.region, |
| 347 | 'endpoint_type': CONF.volume.endpoint_type, |
| 348 | 'build_interval': CONF.volume.build_interval, |
| 349 | 'build_timeout': CONF.volume.build_timeout |
| 350 | } |
| 351 | params.update(self.default_params) |
| 352 | |
Andrea Frittoli (andreaf) | 14ecae1 | 2016-06-17 11:56:24 +0100 | [diff] [blame] | 353 | self.volume_qos_client = volume.v1.QosSpecsClient(self.auth_provider, |
| 354 | **params) |
| 355 | self.volume_qos_v2_client = volume.v2.QosSpecsClient( |
Ken'ichi Ohmichi | f85e9bd | 2015-01-27 12:51:47 +0000 | [diff] [blame] | 356 | self.auth_provider, **params) |
Andrea Frittoli (andreaf) | 14ecae1 | 2016-06-17 11:56:24 +0100 | [diff] [blame] | 357 | self.volume_services_client = volume.v1.ServicesClient( |
Yaroslav Lobankov | 4c23779 | 2015-12-02 18:43:48 +0300 | [diff] [blame] | 358 | self.auth_provider, **params) |
Andrea Frittoli (andreaf) | 14ecae1 | 2016-06-17 11:56:24 +0100 | [diff] [blame] | 359 | self.volume_services_v2_client = volume.v2.ServicesClient( |
Ken'ichi Ohmichi | f85e9bd | 2015-01-27 12:51:47 +0000 | [diff] [blame] | 360 | self.auth_provider, **params) |
Andrea Frittoli (andreaf) | 14ecae1 | 2016-06-17 11:56:24 +0100 | [diff] [blame] | 361 | self.backups_client = volume.v1.BackupsClient(self.auth_provider, |
| 362 | **params) |
| 363 | self.backups_v2_client = volume.v2.BackupsClient(self.auth_provider, |
| 364 | **params) |
| 365 | self.snapshots_client = volume.v1.SnapshotsClient(self.auth_provider, |
| 366 | **params) |
| 367 | self.snapshots_v2_client = volume.v2.SnapshotsClient( |
| 368 | self.auth_provider, **params) |
| 369 | self.volumes_client = volume.v1.VolumesClient( |
Ken'ichi Ohmichi | 234da80 | 2015-02-13 04:48:06 +0000 | [diff] [blame] | 370 | self.auth_provider, default_volume_size=CONF.volume.volume_size, |
| 371 | **params) |
Andrea Frittoli (andreaf) | 14ecae1 | 2016-06-17 11:56:24 +0100 | [diff] [blame] | 372 | self.volumes_v2_client = volume.v2.VolumesClient( |
Ken'ichi Ohmichi | 234da80 | 2015-02-13 04:48:06 +0000 | [diff] [blame] | 373 | self.auth_provider, default_volume_size=CONF.volume.volume_size, |
| 374 | **params) |
Andrea Frittoli (andreaf) | 14ecae1 | 2016-06-17 11:56:24 +0100 | [diff] [blame] | 375 | self.volume_messages_client = volume.v3.MessagesClient( |
Ken'ichi Ohmichi | f85e9bd | 2015-01-27 12:51:47 +0000 | [diff] [blame] | 376 | self.auth_provider, **params) |
Andrea Frittoli (andreaf) | 14ecae1 | 2016-06-17 11:56:24 +0100 | [diff] [blame] | 377 | self.volume_types_client = volume.v1.TypesClient(self.auth_provider, |
| 378 | **params) |
| 379 | self.volume_types_v2_client = volume.v2.TypesClient(self.auth_provider, |
Ken'ichi Ohmichi | f85e9bd | 2015-01-27 12:51:47 +0000 | [diff] [blame] | 380 | **params) |
Andrea Frittoli (andreaf) | 14ecae1 | 2016-06-17 11:56:24 +0100 | [diff] [blame] | 381 | self.volume_hosts_client = volume.v1.HostsClient(self.auth_provider, |
| 382 | **params) |
| 383 | self.volume_hosts_v2_client = volume.v2.HostsClient(self.auth_provider, |
| 384 | **params) |
| 385 | self.volume_quotas_client = volume.v1.QuotasClient(self.auth_provider, |
| 386 | **params) |
| 387 | self.volume_quotas_v2_client = volume.v2.QuotasClient( |
Ken'ichi Ohmichi | f85e9bd | 2015-01-27 12:51:47 +0000 | [diff] [blame] | 388 | self.auth_provider, **params) |
Andrea Frittoli (andreaf) | 14ecae1 | 2016-06-17 11:56:24 +0100 | [diff] [blame] | 389 | self.volumes_extension_client = volume.v1.ExtensionsClient( |
| 390 | self.auth_provider, **params) |
| 391 | self.volumes_v2_extension_client = volume.v2.ExtensionsClient( |
Ken'ichi Ohmichi | f85e9bd | 2015-01-27 12:51:47 +0000 | [diff] [blame] | 392 | self.auth_provider, **params) |
Ken'ichi Ohmichi | 532ae92 | 2014-11-19 01:37:15 +0000 | [diff] [blame] | 393 | self.volume_availability_zone_client = \ |
Andrea Frittoli (andreaf) | 14ecae1 | 2016-06-17 11:56:24 +0100 | [diff] [blame] | 394 | volume.v1.AvailabilityZoneClient(self.auth_provider, **params) |
Ken'ichi Ohmichi | 532ae92 | 2014-11-19 01:37:15 +0000 | [diff] [blame] | 395 | self.volume_v2_availability_zone_client = \ |
Andrea Frittoli (andreaf) | 14ecae1 | 2016-06-17 11:56:24 +0100 | [diff] [blame] | 396 | volume.v2.AvailabilityZoneClient(self.auth_provider, **params) |
Ken'ichi Ohmichi | 532ae92 | 2014-11-19 01:37:15 +0000 | [diff] [blame] | 397 | |
Ken'ichi Ohmichi | c95eb85 | 2015-01-22 01:57:57 +0000 | [diff] [blame] | 398 | def _set_object_storage_clients(self): |
Ken'ichi Ohmichi | 564b2ad | 2015-01-22 02:08:59 +0000 | [diff] [blame] | 399 | params = { |
| 400 | 'service': CONF.object_storage.catalog_type, |
| 401 | 'region': CONF.object_storage.region or CONF.identity.region, |
| 402 | 'endpoint_type': CONF.object_storage.endpoint_type |
| 403 | } |
| 404 | params.update(self.default_params_with_timeout_values) |
| 405 | |
Andrea Frittoli (andreaf) | 9a22543 | 2016-06-17 12:16:22 +0100 | [diff] [blame] | 406 | self.account_client = object_storage.AccountClient(self.auth_provider, |
| 407 | **params) |
| 408 | self.container_client = object_storage.ContainerClient( |
| 409 | self.auth_provider, **params) |
| 410 | self.object_client = object_storage.ObjectClient(self.auth_provider, |
| 411 | **params) |