blob: 053e5ea6a3b0d7cdd9bdec767b63559d1277f5d7 [file] [log] [blame]
Daniel Mellado3c0aeab2016-01-29 11:30:25 +00001# 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 Kopecdd96e9a2020-12-18 13:12:19 +000016from tempest import clients as tempest_clients
17from tempest.lib.services import clients
Roee Agiman6a0a18a2017-11-16 11:51:56 +020018from tempest.lib.services.compute import availability_zone_client
19from tempest.lib.services.compute import hypervisor_client
Hongbin Lu965b03d2018-04-25 22:32:30 +000020from tempest.lib.services.compute import interfaces_client
Itzik Browne67ebb52016-05-15 05:34:41 +000021from tempest.lib.services.compute import keypairs_client
22from tempest.lib.services.compute import servers_client
Ken'ichi Ohmichib35c6cd2016-06-30 12:19:37 -070023from tempest.lib.services.identity.v2 import tenants_client
nanaboatedfe7742017-07-14 22:26:52 +000024from tempest.lib.services.identity.v3 import projects_client
zahlabut7ebb66e2021-09-01 22:39:49 +030025from tempest.lib.services.network import qos_limit_bandwidth_rules_client
26from tempest.lib.services.network import qos_minimum_bandwidth_rules_client
elajkat4a1357b2021-08-31 10:16:25 +020027from tempest.lib.services.network import qos_minimum_packet_rate_rules_client
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000028
Chandan Kumar667d3d32017-09-22 12:24:06 +053029from neutron_tempest_plugin import config
30from neutron_tempest_plugin.services.network.json import network_client
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000031
32CONF = config.CONF
33
34
Martin Kopecdd96e9a2020-12-18 13:12:19 +000035class Manager(clients.ServiceClients):
Brian Haleyae328b92018-10-09 19:51:54 -040036 """Top level manager for OpenStack tempest clients"""
Armando Migliaccioa2275dc2016-08-22 15:14:38 +000037 default_params = {
38 'disable_ssl_certificate_validation':
39 CONF.identity.disable_ssl_certificate_validation,
40 'ca_certs': CONF.identity.ca_certificates_file,
Federico Ressi7b410ed2018-04-12 13:59:56 +020041 'trace_requests': CONF.debug.trace_requests,
42 'proxy_url': CONF.service_clients.proxy_url
Armando Migliaccioa2275dc2016-08-22 15:14:38 +000043 }
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000044
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 Kopecdd96e9a2020-12-18 13:12:19 +000054 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 Mellado3c0aeab2016-01-29 11:30:25 +000063
64 self._set_identity_clients()
65
Itzik Browne67ebb52016-05-15 05:34:41 +000066 self.network_client = network_client.NetworkClientJSON(
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000067 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 Browne67ebb52016-05-15 05:34:41 +000075 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 Lu965b03d2018-04-25 22:32:30 +000089 self.interfaces_client = interfaces_client.InterfacesClient(
90 self.auth_provider, **params)
Itzik Browne67ebb52016-05-15 05:34:41 +000091 self.keypairs_client = keypairs_client.KeyPairsClient(
yatinkarel2ad4d582022-03-08 19:25:10 +053092 self.auth_provider, ssh_key_type=CONF.validation.ssh_key_type,
93 **params)
Roee Agiman6a0a18a2017-11-16 11:51:56 +020094 self.hv_client = hypervisor_client.HypervisorClient(
95 self.auth_provider, **params)
96 self.az_client = availability_zone_client.AvailabilityZoneClient(
97 self.auth_provider, **params)
Itzik Browne67ebb52016-05-15 05:34:41 +000098
zahlabut7ebb66e2021-09-01 22:39:49 +030099 self.qos_limit_bandwidth_rules_client = \
100 qos_limit_bandwidth_rules_client.QosLimitBandwidthRulesClient(
101 self.auth_provider,
102 CONF.network.catalog_type,
103 CONF.network.region or CONF.identity.region,
104 endpoint_type=CONF.network.endpoint_type,
105 build_interval=CONF.network.build_interval,
106 build_timeout=CONF.network.build_timeout,
107 **self.default_params)
108
109 self.qos_minimum_bandwidth_rules_client = \
110 qos_minimum_bandwidth_rules_client.QosMinimumBandwidthRulesClient(
111 self.auth_provider,
112 CONF.network.catalog_type,
113 CONF.network.region or CONF.identity.region,
114 endpoint_type=CONF.network.endpoint_type,
115 build_interval=CONF.network.build_interval,
116 build_timeout=CONF.network.build_timeout,
117 **self.default_params)
118
elajkat4a1357b2021-08-31 10:16:25 +0200119 self.qos_minimum_packet_rate_rules_client = \
120 qos_minimum_packet_rate_rules_client.\
121 QosMinimumPacketRateRulesClient(
122 self.auth_provider,
123 CONF.network.catalog_type,
124 CONF.network.region or CONF.identity.region,
125 endpoint_type=CONF.network.endpoint_type,
126 build_interval=CONF.network.build_interval,
127 build_timeout=CONF.network.build_timeout,
128 **self.default_params)
129
Daniel Mellado3c0aeab2016-01-29 11:30:25 +0000130 def _set_identity_clients(self):
131 params = {
132 'service': CONF.identity.catalog_type,
133 'region': CONF.identity.region
134 }
135 params.update(self.default_params_with_timeout_values)
136 params_v2_admin = params.copy()
137 params_v2_admin['endpoint_type'] = CONF.identity.v2_admin_endpoint_type
138 # Client uses admin endpoint type of Keystone API v2
Itzik Browne67ebb52016-05-15 05:34:41 +0000139 self.tenants_client = tenants_client.TenantsClient(self.auth_provider,
140 **params_v2_admin)
nanaboatedfe7742017-07-14 22:26:52 +0000141 # Client uses admin endpoint type of Keystone API v3
142 self.projects_client = projects_client.ProjectsClient(
143 self.auth_provider, **params_v2_admin)