blob: df0eb4de46644e2b83b0893a93e8084d7f53ab3d [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
Michael Polenchukcd930ba2022-05-16 19:25:50 +040016from tempest.lib.services.compute import hosts_client
Hongbin Lu965b03d2018-04-25 22:32:30 +000017from tempest.lib.services.compute import interfaces_client
Itzik Browne67ebb52016-05-15 05:34:41 +000018from tempest.lib.services.compute import keypairs_client
19from tempest.lib.services.compute import servers_client
Ken'ichi Ohmichib35c6cd2016-06-30 12:19:37 -070020from tempest.lib.services.identity.v2 import tenants_client
nanaboatedfe7742017-07-14 22:26:52 +000021from tempest.lib.services.identity.v3 import projects_client
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000022from tempest import manager
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000023
Chandan Kumar667d3d32017-09-22 12:24:06 +053024from neutron_tempest_plugin import config
25from neutron_tempest_plugin.services.network.json import network_client
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000026
27CONF = config.CONF
28
29
30class Manager(manager.Manager):
Brian Haleyae328b92018-10-09 19:51:54 -040031 """Top level manager for OpenStack tempest clients"""
Armando Migliaccioa2275dc2016-08-22 15:14:38 +000032 default_params = {
33 'disable_ssl_certificate_validation':
34 CONF.identity.disable_ssl_certificate_validation,
35 'ca_certs': CONF.identity.ca_certificates_file,
Federico Ressi7b410ed2018-04-12 13:59:56 +020036 'trace_requests': CONF.debug.trace_requests,
37 'proxy_url': CONF.service_clients.proxy_url
Armando Migliaccioa2275dc2016-08-22 15:14:38 +000038 }
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000039
40 # NOTE: Tempest uses timeout values of compute API if project specific
41 # timeout values don't exist.
42 default_params_with_timeout_values = {
43 'build_interval': CONF.compute.build_interval,
44 'build_timeout': CONF.compute.build_timeout
45 }
46 default_params_with_timeout_values.update(default_params)
47
48 def __init__(self, credentials=None, service=None):
49 super(Manager, self).__init__(credentials=credentials)
50
51 self._set_identity_clients()
52
Itzik Browne67ebb52016-05-15 05:34:41 +000053 self.network_client = network_client.NetworkClientJSON(
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000054 self.auth_provider,
55 CONF.network.catalog_type,
56 CONF.network.region or CONF.identity.region,
57 endpoint_type=CONF.network.endpoint_type,
58 build_interval=CONF.network.build_interval,
59 build_timeout=CONF.network.build_timeout,
60 **self.default_params)
61
Itzik Browne67ebb52016-05-15 05:34:41 +000062 params = {
63 'service': CONF.compute.catalog_type,
64 'region': CONF.compute.region or CONF.identity.region,
65 'endpoint_type': CONF.compute.endpoint_type,
66 'build_interval': CONF.compute.build_interval,
67 'build_timeout': CONF.compute.build_timeout
68 }
69 params.update(self.default_params)
70
71 self.servers_client = servers_client.ServersClient(
72 self.auth_provider,
73 enable_instance_password=CONF.compute_feature_enabled
74 .enable_instance_password,
75 **params)
Hongbin Lu965b03d2018-04-25 22:32:30 +000076 self.interfaces_client = interfaces_client.InterfacesClient(
77 self.auth_provider, **params)
Itzik Browne67ebb52016-05-15 05:34:41 +000078 self.keypairs_client = keypairs_client.KeyPairsClient(
79 self.auth_provider, **params)
Michael Polenchukcd930ba2022-05-16 19:25:50 +040080 self.hosts_client = hosts_client.HostsClient(
Roee Agiman6a0a18a2017-11-16 11:51:56 +020081 self.auth_provider, **params)
Itzik Browne67ebb52016-05-15 05:34:41 +000082
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000083 def _set_identity_clients(self):
84 params = {
85 'service': CONF.identity.catalog_type,
86 'region': CONF.identity.region
87 }
88 params.update(self.default_params_with_timeout_values)
89 params_v2_admin = params.copy()
90 params_v2_admin['endpoint_type'] = CONF.identity.v2_admin_endpoint_type
91 # Client uses admin endpoint type of Keystone API v2
Itzik Browne67ebb52016-05-15 05:34:41 +000092 self.tenants_client = tenants_client.TenantsClient(self.auth_provider,
93 **params_v2_admin)
nanaboatedfe7742017-07-14 22:26:52 +000094 # Client uses admin endpoint type of Keystone API v3
95 self.projects_client = projects_client.ProjectsClient(
96 self.auth_provider, **params_v2_admin)