Don't manipulate config for admin creds
Soon this will be global tempest config, so modifying it is not an option. Instead the client manager can now be replaced with one which uses admin credentials when setup_clients_for_admin is called. blueprint tempest-plugin-support Change-Id: I9c1b80ec2048d227cc99c06808da90745fcf516e
This commit is contained in:
parent
00a1814d5e
commit
80b8ce19f3
@ -67,8 +67,10 @@ class ClientManager(object):
|
||||
NOVA_API_VERSION = '2.1'
|
||||
CEILOMETER_VERSION = '2'
|
||||
|
||||
def __init__(self, conf):
|
||||
def __init__(self, conf, admin_credentials=False):
|
||||
self.conf = conf
|
||||
self.admin_credentials = admin_credentials
|
||||
|
||||
if self.conf.auth_url.find('/v'):
|
||||
self.auth_version = self.conf.auth_url.split('/v')[1]
|
||||
else:
|
||||
@ -85,6 +87,21 @@ class ClientManager(object):
|
||||
self.object_client = self._get_object_client()
|
||||
self.metering_client = self._get_metering_client()
|
||||
|
||||
def _username(self):
|
||||
if self.admin_credentials:
|
||||
return self.conf.admin_username
|
||||
return self.conf.username
|
||||
|
||||
def _password(self):
|
||||
if self.admin_credentials:
|
||||
return self.conf.admin_password
|
||||
return self.conf.password
|
||||
|
||||
def _tenant_name(self):
|
||||
if self.admin_credentials:
|
||||
return self.conf.admin_tenant_name
|
||||
return self.conf.tenant_name
|
||||
|
||||
def _get_orchestration_client(self):
|
||||
endpoint = os.environ.get('HEAT_URL')
|
||||
if os.environ.get('OS_NO_CLIENT_AUTH') == 'True':
|
||||
@ -102,16 +119,16 @@ class ClientManager(object):
|
||||
self.HEATCLIENT_VERSION,
|
||||
endpoint,
|
||||
token=token,
|
||||
username=self.conf.username,
|
||||
password=self.conf.password)
|
||||
username=self._username(),
|
||||
password=self._password())
|
||||
|
||||
def _get_identity_client(self):
|
||||
user_domain_name = self.conf.user_domain_name
|
||||
project_domain_name = self.conf.project_domain_name
|
||||
kwargs = {
|
||||
'username': self.conf.username,
|
||||
'password': self.conf.password,
|
||||
'tenant_name': self.conf.tenant_name,
|
||||
'username': self._username(),
|
||||
'password': self._password(),
|
||||
'tenant_name': self._tenant_name(),
|
||||
'auth_url': self.conf.auth_url
|
||||
}
|
||||
# keystone v2 can't ignore domain details
|
||||
@ -166,8 +183,8 @@ class ClientManager(object):
|
||||
# swiftclient does not support keystone sessions yet
|
||||
args = {
|
||||
'auth_version': self.auth_version,
|
||||
'tenant_name': self.conf.tenant_name,
|
||||
'user': self.conf.username,
|
||||
'tenant_name': self._tenant_name(),
|
||||
'user': self._username(),
|
||||
'key': self.conf.password,
|
||||
'authurl': self.conf.auth_url,
|
||||
'os_options': {'endpoint_type': 'publicURL'},
|
||||
|
@ -89,8 +89,8 @@ class HeatIntegrationTest(testscenarios.WithScenarios,
|
||||
else:
|
||||
self.verify_cert = self.conf.ca_file or True
|
||||
|
||||
def setup_clients(self, conf):
|
||||
self.manager = clients.ClientManager(conf)
|
||||
def setup_clients(self, conf, admin_credentials=False):
|
||||
self.manager = clients.ClientManager(conf, admin_credentials)
|
||||
self.identity_client = self.manager.identity_client
|
||||
self.orchestration_client = self.manager.orchestration_client
|
||||
self.compute_client = self.manager.compute_client
|
||||
@ -102,15 +102,7 @@ class HeatIntegrationTest(testscenarios.WithScenarios,
|
||||
self.client = self.orchestration_client
|
||||
|
||||
def setup_clients_for_admin(self):
|
||||
self.assertIsNotNone(self.conf.admin_username,
|
||||
'No admin username configured')
|
||||
self.assertIsNotNone(self.conf.admin_password,
|
||||
'No admin password configured')
|
||||
conf = config.init_conf().heat_plugin
|
||||
conf.username = self.conf.admin_username
|
||||
conf.password = self.conf.admin_password
|
||||
conf.tenant_name = self.conf.admin_tenant_name
|
||||
self.setup_clients(conf)
|
||||
self.setup_clients(self.conf, True)
|
||||
|
||||
def get_remote_client(self, server_or_ip, username, private_key=None):
|
||||
if isinstance(server_or_ip, six.string_types):
|
||||
|
Loading…
Reference in New Issue
Block a user