summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Baker <sbaker@redhat.com>2016-08-01 22:05:37 +0000
committerSteve Baker <sbaker@redhat.com>2016-08-13 09:51:11 +1200
commit80b8ce19f390573b0bce2047d59a419701c51e76 (patch)
tree30d44fc8952920c3be5a38ab7fad543437651b1b
parent00a1814d5e456143518e4806c049cd1bf61ca48b (diff)
downloadheat-80b8ce19f390573b0bce2047d59a419701c51e76.tar.gz
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
-rw-r--r--heat_integrationtests/common/clients.py33
-rw-r--r--heat_integrationtests/common/test.py14
2 files changed, 28 insertions, 19 deletions
diff --git a/heat_integrationtests/common/clients.py b/heat_integrationtests/common/clients.py
index 9f58678ca..96a34b7c5 100644
--- a/heat_integrationtests/common/clients.py
+++ b/heat_integrationtests/common/clients.py
@@ -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'},
diff --git a/heat_integrationtests/common/test.py b/heat_integrationtests/common/test.py
index 413e51f15..2bf77714c 100644
--- a/heat_integrationtests/common/test.py
+++ b/heat_integrationtests/common/test.py
@@ -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):