blob: e3174d448340a69d5831752192894f1249d7db45 [file] [log] [blame]
ZhiQiang Fan39f97222013-09-20 04:49:44 +08001# Copyright 2012 OpenStack Foundation
Jay Pipes051075a2012-04-28 17:39:37 -04002# 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
Andrea Frittoli (andreaf)23950142016-06-13 12:39:29 +010016from oslo_log import log as logging
17
Andrea Frittoli (andreaf)e07579c2016-08-05 07:27:02 +010018from tempest import clients as tempest_clients
Andrea Frittolif9cde7e2014-02-18 09:57:04 +000019from tempest import config
Andrea Frittoli (andreaf)e07579c2016-08-05 07:27:02 +010020from tempest.lib.services import clients
Jay Pipes051075a2012-04-28 17:39:37 -040021
Andrea Frittolif9cde7e2014-02-18 09:57:04 +000022CONF = config.CONF
Andrea Frittoli (andreaf)23950142016-06-13 12:39:29 +010023LOG = logging.getLogger(__name__)
Andrea Frittolif9cde7e2014-02-18 09:57:04 +000024
Jay Pipes051075a2012-04-28 17:39:37 -040025
Andrea Frittoli (andreaf)e07579c2016-08-05 07:27:02 +010026class Manager(clients.ServiceClients):
Andrea Frittoli (andreaf)23950142016-06-13 12:39:29 +010027 """Service client manager class for backward compatibility
Jay Pipes051075a2012-04-28 17:39:37 -040028
Andrea Frittoli (andreaf)23950142016-06-13 12:39:29 +010029 The former manager.Manager is not a stable interface in Tempest,
30 nonetheless it is consumed by a number of plugins already. This class
31 exists to provide some grace time for the move to tempest.lib.
Jay Pipes051075a2012-04-28 17:39:37 -040032 """
33
Andrea Frittoli (andreaf)3e82af72016-05-05 22:53:38 +010034 def __init__(self, credentials, scope='project'):
Andrea Frittoli (andreaf)23950142016-06-13 12:39:29 +010035 msg = ("tempest.manager.Manager is not a stable interface and as such "
36 "it should not imported directly. It will be removed as "
37 "soon as the client manager becomes available in tempest.lib.")
38 LOG.warning(msg)
Daniel Melladocad3f3d2016-08-19 14:17:16 +000039 dscv = CONF.identity.disable_ssl_certificate_validation
Andrea Frittoli (andreaf)e07579c2016-08-05 07:27:02 +010040 _, uri = tempest_clients.get_auth_provider_class(credentials)
Andrea Frittoli (andreaf)23950142016-06-13 12:39:29 +010041 super(Manager, self).__init__(
42 credentials=credentials, scope=scope,
43 identity_uri=uri,
44 disable_ssl_certificate_validation=dscv,
Daniel Melladocad3f3d2016-08-19 14:17:16 +000045 ca_certs=CONF.identity.ca_certificates_file,
Andrea Frittoli (andreaf)23950142016-06-13 12:39:29 +010046 trace_requests=CONF.debug.trace_requests)
Andrea Frittoli90012352015-02-25 21:58:02 +000047
48
Andrea Frittoli (andreaf)3e82af72016-05-05 22:53:38 +010049def get_auth_provider(credentials, pre_auth=False, scope='project'):
Andrea Frittoli (andreaf)23950142016-06-13 12:39:29 +010050 """Shim to get_auth_provider in clients.py
51
52 get_auth_provider used to be hosted in this module, but it has been
53 moved to clients.py now as a more permanent location.
54 This module will be removed eventually, and this shim is only
55 maintained for the benefit of plugins already consuming this interface.
56 """
57 msg = ("tempest.manager.get_auth_provider is not a stable interface and "
58 "as such it should not imported directly. It will be removed as "
59 "the client manager becomes available in tempest.lib.")
60 LOG.warning(msg)
ghanshyam9d7bac42016-08-08 13:29:25 +090061 return tempest_clients.get_auth_provider(credentials=credentials,
62 pre_auth=pre_auth, scope=scope)