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