Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 1 | # Copyright 2012 OpenStack Foundation |
| 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 | |
Martin Kopec | dd96e9a | 2020-12-18 13:12:19 +0000 | [diff] [blame] | 16 | from tempest import clients as tempest_clients |
| 17 | from tempest.lib.services import clients |
Roee Agiman | 6a0a18a | 2017-11-16 11:51:56 +0200 | [diff] [blame] | 18 | from tempest.lib.services.compute import availability_zone_client |
| 19 | from tempest.lib.services.compute import hypervisor_client |
Hongbin Lu | 965b03d | 2018-04-25 22:32:30 +0000 | [diff] [blame] | 20 | from tempest.lib.services.compute import interfaces_client |
Itzik Brown | e67ebb5 | 2016-05-15 05:34:41 +0000 | [diff] [blame] | 21 | from tempest.lib.services.compute import keypairs_client |
| 22 | from tempest.lib.services.compute import servers_client |
Ken'ichi Ohmichi | b35c6cd | 2016-06-30 12:19:37 -0700 | [diff] [blame] | 23 | from tempest.lib.services.identity.v2 import tenants_client |
nanaboat | edfe774 | 2017-07-14 22:26:52 +0000 | [diff] [blame] | 24 | from tempest.lib.services.identity.v3 import projects_client |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 25 | |
Chandan Kumar | 667d3d3 | 2017-09-22 12:24:06 +0530 | [diff] [blame] | 26 | from neutron_tempest_plugin import config |
| 27 | from neutron_tempest_plugin.services.network.json import network_client |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 28 | |
| 29 | CONF = config.CONF |
| 30 | |
| 31 | |
Martin Kopec | dd96e9a | 2020-12-18 13:12:19 +0000 | [diff] [blame] | 32 | class Manager(clients.ServiceClients): |
Brian Haley | ae328b9 | 2018-10-09 19:51:54 -0400 | [diff] [blame] | 33 | """Top level manager for OpenStack tempest clients""" |
Armando Migliaccio | a2275dc | 2016-08-22 15:14:38 +0000 | [diff] [blame] | 34 | default_params = { |
| 35 | 'disable_ssl_certificate_validation': |
| 36 | CONF.identity.disable_ssl_certificate_validation, |
| 37 | 'ca_certs': CONF.identity.ca_certificates_file, |
Federico Ressi | 7b410ed | 2018-04-12 13:59:56 +0200 | [diff] [blame] | 38 | 'trace_requests': CONF.debug.trace_requests, |
| 39 | 'proxy_url': CONF.service_clients.proxy_url |
Armando Migliaccio | a2275dc | 2016-08-22 15:14:38 +0000 | [diff] [blame] | 40 | } |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 41 | |
| 42 | # NOTE: Tempest uses timeout values of compute API if project specific |
| 43 | # timeout values don't exist. |
| 44 | default_params_with_timeout_values = { |
| 45 | 'build_interval': CONF.compute.build_interval, |
| 46 | 'build_timeout': CONF.compute.build_timeout |
| 47 | } |
| 48 | default_params_with_timeout_values.update(default_params) |
| 49 | |
| 50 | def __init__(self, credentials=None, service=None): |
Martin Kopec | dd96e9a | 2020-12-18 13:12:19 +0000 | [diff] [blame] | 51 | dscv = CONF.identity.disable_ssl_certificate_validation |
| 52 | _, uri = tempest_clients.get_auth_provider_class(credentials) |
| 53 | super(Manager, self).__init__( |
| 54 | credentials=credentials, |
| 55 | identity_uri=uri, |
| 56 | scope='project', |
| 57 | disable_ssl_certificate_validation=dscv, |
| 58 | ca_certs=CONF.identity.ca_certificates_file, |
| 59 | trace_requests=CONF.debug.trace_requests) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 60 | |
| 61 | self._set_identity_clients() |
| 62 | |
Itzik Brown | e67ebb5 | 2016-05-15 05:34:41 +0000 | [diff] [blame] | 63 | self.network_client = network_client.NetworkClientJSON( |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 64 | self.auth_provider, |
| 65 | CONF.network.catalog_type, |
| 66 | CONF.network.region or CONF.identity.region, |
| 67 | endpoint_type=CONF.network.endpoint_type, |
| 68 | build_interval=CONF.network.build_interval, |
| 69 | build_timeout=CONF.network.build_timeout, |
| 70 | **self.default_params) |
| 71 | |
Itzik Brown | e67ebb5 | 2016-05-15 05:34:41 +0000 | [diff] [blame] | 72 | params = { |
| 73 | 'service': CONF.compute.catalog_type, |
| 74 | 'region': CONF.compute.region or CONF.identity.region, |
| 75 | 'endpoint_type': CONF.compute.endpoint_type, |
| 76 | 'build_interval': CONF.compute.build_interval, |
| 77 | 'build_timeout': CONF.compute.build_timeout |
| 78 | } |
| 79 | params.update(self.default_params) |
| 80 | |
| 81 | self.servers_client = servers_client.ServersClient( |
| 82 | self.auth_provider, |
| 83 | enable_instance_password=CONF.compute_feature_enabled |
| 84 | .enable_instance_password, |
| 85 | **params) |
Hongbin Lu | 965b03d | 2018-04-25 22:32:30 +0000 | [diff] [blame] | 86 | self.interfaces_client = interfaces_client.InterfacesClient( |
| 87 | self.auth_provider, **params) |
Itzik Brown | e67ebb5 | 2016-05-15 05:34:41 +0000 | [diff] [blame] | 88 | self.keypairs_client = keypairs_client.KeyPairsClient( |
| 89 | self.auth_provider, **params) |
Roee Agiman | 6a0a18a | 2017-11-16 11:51:56 +0200 | [diff] [blame] | 90 | self.hv_client = hypervisor_client.HypervisorClient( |
| 91 | self.auth_provider, **params) |
| 92 | self.az_client = availability_zone_client.AvailabilityZoneClient( |
| 93 | self.auth_provider, **params) |
Itzik Brown | e67ebb5 | 2016-05-15 05:34:41 +0000 | [diff] [blame] | 94 | |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 95 | def _set_identity_clients(self): |
| 96 | params = { |
| 97 | 'service': CONF.identity.catalog_type, |
| 98 | 'region': CONF.identity.region |
| 99 | } |
| 100 | params.update(self.default_params_with_timeout_values) |
| 101 | params_v2_admin = params.copy() |
| 102 | params_v2_admin['endpoint_type'] = CONF.identity.v2_admin_endpoint_type |
| 103 | # Client uses admin endpoint type of Keystone API v2 |
Itzik Brown | e67ebb5 | 2016-05-15 05:34:41 +0000 | [diff] [blame] | 104 | self.tenants_client = tenants_client.TenantsClient(self.auth_provider, |
| 105 | **params_v2_admin) |
nanaboat | edfe774 | 2017-07-14 22:26:52 +0000 | [diff] [blame] | 106 | # Client uses admin endpoint type of Keystone API v3 |
| 107 | self.projects_client = projects_client.ProjectsClient( |
| 108 | self.auth_provider, **params_v2_admin) |