diff options
author | mbeierl <mark.beierl@dell.com> | 2016-12-09 13:34:35 -0500 |
---|---|---|
committer | mbeierl <mark.beierl@dell.com> | 2016-12-16 16:16:30 -0500 |
commit | ab2c2817ec8d3a60d7bc61249217107e2b99a18c (patch) | |
tree | f66f6ae51969fe615caf0cbda095a3588589dca6 | |
parent | c5b07343a75f1a440721f66158e10965838ce194 (diff) |
Use v3 Auth
Change to detect environment variable and use v3 authentication
instead if present.
Change-Id: Iada49741b3297f20b740e232b2b35bec92fda91a
JIRA: STORPERF-88
Signed-off-by: mbeierl <mark.beierl@dell.com>
-rwxr-xr-x | ci/verify.sh | 3 | ||||
-rw-r--r-- | docker/requirements.pip | 1 | ||||
-rw-r--r-- | storperf/logging.json | 2 | ||||
-rw-r--r-- | storperf/storperf_master.py | 73 |
4 files changed, 45 insertions, 34 deletions
diff --git a/ci/verify.sh b/ci/verify.sh index 22d0186..a0de93a 100755 --- a/ci/verify.sh +++ b/ci/verify.sh @@ -29,6 +29,7 @@ pip install flask-swagger==0.2.12 pip install funcsigs==0.4 pip install flake8==2.5.4 pip install html2text==2016.1.8 +pip install keystoneauth1==2.12.1 pip install matplotlib==1.3.1 pip install mock==1.3.0 pip install nose==1.3.7 @@ -66,4 +67,4 @@ then exit $flake8rc fi -exit $rc
\ No newline at end of file +exit $rc diff --git a/docker/requirements.pip b/docker/requirements.pip index 2e41608..df5c339 100644 --- a/docker/requirements.pip +++ b/docker/requirements.pip @@ -5,6 +5,7 @@ python-novaclient==2.28.1 python-glanceclient==1.1.0 python-cinderclient==1.6.0 python-keystoneclient==1.6.0 +keystoneauth1==2.12.1 matplotlib==1.3.1 flask==0.10 flask-restful==0.3.5 diff --git a/storperf/logging.json b/storperf/logging.json index 74df494..2a0bbce 100644 --- a/storperf/logging.json +++ b/storperf/logging.json @@ -48,4 +48,4 @@ "level": "INFO" } } -}
\ No newline at end of file +} diff --git a/storperf/storperf_master.py b/storperf/storperf_master.py index 2975afd..ecf5be6 100644 --- a/storperf/storperf_master.py +++ b/storperf/storperf_master.py @@ -8,22 +8,23 @@ ############################################################################## from datetime import datetime +from storperf.db.configuration_db import ConfigurationDB +from storperf.db.graphite_db import GraphiteDB +from storperf.db.job_db import JobDB +from threading import Thread +from time import sleep import logging import os import socket -from threading import Thread -from time import sleep -import paramiko +from cinderclient import client as cinderclient +from keystoneauth1 import loading +from keystoneauth1 import session from scp import SCPClient +import paramiko -import cinderclient.v2 as cinderclient -import heatclient.client as heatclient -import keystoneclient.v2_0 as ksclient -from storperf.db.configuration_db import ConfigurationDB -from storperf.db.graphite_db import GraphiteDB -from storperf.db.job_db import JobDB from test_executor import TestExecutor +import heatclient.client as heatclient class ParameterError(Exception): @@ -50,13 +51,6 @@ class StorPerfMaster(object): self.logger.debug( "Loaded agent-resource template as: " + self._agent_resource_hot) - self._username = os.environ.get('OS_USERNAME') - self._password = os.environ.get('OS_PASSWORD') - self._tenant_name = os.environ.get('OS_TENANT_NAME') - self._tenant_id = os.environ.get('OS_TENANT_ID') - self._project_name = os.environ.get('OS_PROJECT_NAME') - self._auth_url = os.environ.get('OS_AUTH_URL') - self._cinder_client = None self._heat_client = None self._test_executor = TestExecutor() @@ -161,7 +155,8 @@ class StorPerfMaster(object): @property def volume_quota(self): self._attach_to_openstack() - quotas = self._cinder_client.quotas.get(self._tenant_id) + quotas = self._cinder_client.quotas.get( + os.environ.get('OS_TENANT_NAME')) return int(quotas.volumes) @property @@ -252,6 +247,7 @@ class StorPerfMaster(object): str(self.agent_count) + " > " + str(self.volume_quota) raise ParameterError(message) + self.logger.debug("Creating stack") stack = self._heat_client.stacks.create( stack_name="StorPerfAgentGroup", template=self._agent_group_hot, @@ -394,24 +390,37 @@ class StorPerfMaster(object): time_since_last_auth = datetime.now() - self._last_openstack_auth - if (self._cinder_client is None or + if (self._heat_client is None or time_since_last_auth.total_seconds() > 600): self._last_openstack_auth = datetime.now() - self.logger.debug("Authenticating with OpenStack") + creds = { + "username": os.environ.get('OS_USERNAME'), + "password": os.environ.get('OS_PASSWORD'), + "auth_url": os.environ.get('OS_AUTH_URL'), + "project_name": os.environ.get('OS_PROJECT_NAME'), + "project_id": os.environ.get('OS_PROJECT_ID'), + "tenant_name": os.environ.get('OS_TENANT_NAME'), + "user_domain_id": os.environ.get('OS_USER_DOMAIN_ID') + } + + loader = loading.get_plugin_loader('password') + auth = loader.load_from_options(**creds) + sess = session.Session(auth=auth) - self._cinder_client = cinderclient.Client( - self._username, self._password, self._project_name, - self._auth_url, service_type='volumev2') - self._cinder_client.authenticate() + self.logger.debug("Looking up orchestration endpoint") + heat_endpoint = sess.get_endpoint(auth=auth, + service_type="orchestration", + endpoint_type='publicURL') + + self.logger.debug("Orchestration endpoint is %s" % heat_endpoint) + token = sess.get_token(auth=auth) - self._keystone_client = ksclient.Client( - auth_url=self._auth_url, - username=self._username, - password=self._password, - tenant_name=self._tenant_name) - heat_endpoint = self._keystone_client.service_catalog.url_for( - service_type='orchestration') self._heat_client = heatclient.Client( - '1', endpoint=heat_endpoint, - token=self._keystone_client.auth_token) + "1", + endpoint=heat_endpoint, + token=token) + + self.logger.debug("Creating cinder client") + self._cinder_client = cinderclient.Client("2", session=sess) + self.logger.debug("OpenStack authentication complete") |