blob: ee0289c42ee705374c88087fe9ff631b903a9fe6 [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
Roee Agiman6a0a18a2017-11-16 11:51:56 +020016from tempest.lib.services.compute import availability_zone_client
17from tempest.lib.services.compute import hypervisor_client
Hongbin Lu965b03d2018-04-25 22:32:30 +000018from tempest.lib.services.compute import interfaces_client
Itzik Browne67ebb52016-05-15 05:34:41 +000019from tempest.lib.services.compute import keypairs_client
20from tempest.lib.services.compute import servers_client
Ken'ichi Ohmichib35c6cd2016-06-30 12:19:37 -070021from tempest.lib.services.identity.v2 import tenants_client
nanaboatedfe7742017-07-14 22:26:52 +000022from tempest.lib.services.identity.v3 import projects_client
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000023from tempest import manager
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000024
Chandan Kumar667d3d32017-09-22 12:24:06 +053025from neutron_tempest_plugin import config
26from neutron_tempest_plugin.services.network.json import network_client
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000027
28CONF = config.CONF
29
30
31class Manager(manager.Manager):
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000032 """
33 Top level manager for OpenStack tempest clients
34 """
Armando Migliaccioa2275dc2016-08-22 15:14:38 +000035 default_params = {
36 'disable_ssl_certificate_validation':
37 CONF.identity.disable_ssl_certificate_validation,
38 'ca_certs': CONF.identity.ca_certificates_file,
Federico Ressi7b410ed2018-04-12 13:59:56 +020039 'trace_requests': CONF.debug.trace_requests,
40 'proxy_url': CONF.service_clients.proxy_url
Armando Migliaccioa2275dc2016-08-22 15:14:38 +000041 }
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000042
43 # NOTE: Tempest uses timeout values of compute API if project specific
44 # timeout values don't exist.
45 default_params_with_timeout_values = {
46 'build_interval': CONF.compute.build_interval,
47 'build_timeout': CONF.compute.build_timeout
48 }
49 default_params_with_timeout_values.update(default_params)
50
51 def __init__(self, credentials=None, service=None):
52 super(Manager, self).__init__(credentials=credentials)
53
54 self._set_identity_clients()
55
Itzik Browne67ebb52016-05-15 05:34:41 +000056 self.network_client = network_client.NetworkClientJSON(
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000057 self.auth_provider,
58 CONF.network.catalog_type,
59 CONF.network.region or CONF.identity.region,
60 endpoint_type=CONF.network.endpoint_type,
61 build_interval=CONF.network.build_interval,
62 build_timeout=CONF.network.build_timeout,
63 **self.default_params)
64
Itzik Browne67ebb52016-05-15 05:34:41 +000065 params = {
66 'service': CONF.compute.catalog_type,
67 'region': CONF.compute.region or CONF.identity.region,
68 'endpoint_type': CONF.compute.endpoint_type,
69 'build_interval': CONF.compute.build_interval,
70 'build_timeout': CONF.compute.build_timeout
71 }
72 params.update(self.default_params)
73
74 self.servers_client = servers_client.ServersClient(
75 self.auth_provider,
76 enable_instance_password=CONF.compute_feature_enabled
77 .enable_instance_password,
78 **params)
Hongbin Lu965b03d2018-04-25 22:32:30 +000079 self.interfaces_client = interfaces_client.InterfacesClient(
80 self.auth_provider, **params)
Itzik Browne67ebb52016-05-15 05:34:41 +000081 self.keypairs_client = keypairs_client.KeyPairsClient(
82 self.auth_provider, **params)
Roee Agiman6a0a18a2017-11-16 11:51:56 +020083 self.hv_client = hypervisor_client.HypervisorClient(
84 self.auth_provider, **params)
85 self.az_client = availability_zone_client.AvailabilityZoneClient(
86 self.auth_provider, **params)
Itzik Browne67ebb52016-05-15 05:34:41 +000087
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000088 def _set_identity_clients(self):
89 params = {
90 'service': CONF.identity.catalog_type,
91 'region': CONF.identity.region
92 }
93 params.update(self.default_params_with_timeout_values)
94 params_v2_admin = params.copy()
95 params_v2_admin['endpoint_type'] = CONF.identity.v2_admin_endpoint_type
96 # Client uses admin endpoint type of Keystone API v2
Itzik Browne67ebb52016-05-15 05:34:41 +000097 self.tenants_client = tenants_client.TenantsClient(self.auth_provider,
98 **params_v2_admin)
nanaboatedfe7742017-07-14 22:26:52 +000099 # Client uses admin endpoint type of Keystone API v3
100 self.projects_client = projects_client.ProjectsClient(
101 self.auth_provider, **params_v2_admin)