blob: eb39882b07675f57b2771ef9bac9b185bb6ecb6f [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
Armando Migliacciod0113402016-08-18 19:24:40 -070016from oslo_config import cfg
17
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
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000021from tempest import manager
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000022
23from neutron.tests.tempest import config
Itzik Browne67ebb52016-05-15 05:34:41 +000024from neutron.tests.tempest.services.network.json import network_client
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000025
26CONF = config.CONF
27
28
29class Manager(manager.Manager):
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000030 """
31 Top level manager for OpenStack tempest clients
32 """
Armando Migliacciod0113402016-08-18 19:24:40 -070033 try:
34 default_params = {
35 'disable_ssl_certificate_validation':
36 CONF.service_clients.disable_ssl_certificate_validation,
37 'ca_certs': CONF.service_clients.ca_certificates_file,
38 'trace_requests': CONF.debug.trace_requests
39 }
40 except cfg.NoSuchOptError:
41 # TODO(armax): remove this except when a new tempest release
42 # > 12.1.0 includes change 1afca56b05
43 default_params = {
44 'disable_ssl_certificate_validation':
45 CONF.identity.disable_ssl_certificate_validation,
46 'ca_certs': CONF.identity.ca_certificates_file,
47 'trace_requests': CONF.debug.trace_requests
48 }
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000049
50 # NOTE: Tempest uses timeout values of compute API if project specific
51 # timeout values don't exist.
52 default_params_with_timeout_values = {
53 'build_interval': CONF.compute.build_interval,
54 'build_timeout': CONF.compute.build_timeout
55 }
56 default_params_with_timeout_values.update(default_params)
57
58 def __init__(self, credentials=None, service=None):
59 super(Manager, self).__init__(credentials=credentials)
60
61 self._set_identity_clients()
62
Itzik Browne67ebb52016-05-15 05:34:41 +000063 self.network_client = network_client.NetworkClientJSON(
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000064 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 Browne67ebb52016-05-15 05:34:41 +000072 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)
86 self.keypairs_client = keypairs_client.KeyPairsClient(
87 self.auth_provider, **params)
88
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000089 def _set_identity_clients(self):
90 params = {
91 'service': CONF.identity.catalog_type,
92 'region': CONF.identity.region
93 }
94 params.update(self.default_params_with_timeout_values)
95 params_v2_admin = params.copy()
96 params_v2_admin['endpoint_type'] = CONF.identity.v2_admin_endpoint_type
97 # Client uses admin endpoint type of Keystone API v2
Itzik Browne67ebb52016-05-15 05:34:41 +000098 self.tenants_client = tenants_client.TenantsClient(self.auth_provider,
99 **params_v2_admin)