Use keystone session in murano_driver
Partial-Bug: #1564115 Partial-Bug: #1563495 Partial-Bug: #1563677 Change-Id: If6223188f182063319e299a9226afd8a137051b9
This commit is contained in:
parent
d2877b3db0
commit
b69228417f
|
@ -19,6 +19,8 @@ from __future__ import absolute_import
|
|||
|
||||
import inspect
|
||||
|
||||
import keystoneauth1.identity.v2 as ksidentity
|
||||
import keystoneauth1.session as kssession
|
||||
import keystoneclient.v2_0.client as ksclient
|
||||
import muranoclient.client
|
||||
from muranoclient.common import exceptions as murano_exceptions
|
||||
|
@ -58,6 +60,14 @@ class MuranoDriver(datasource_driver.PollingDataSourceDriver,
|
|||
datasource_driver.ExecutionDriver.__init__(self)
|
||||
self.creds = args
|
||||
logger.debug("Credentials = %s" % self.creds)
|
||||
# TODO(ekcs): factor session creation out of individual driver
|
||||
# One single keystone session can be shared by all drivers
|
||||
auth = ksidentity.Password(
|
||||
auth_url=self.creds['auth_url'],
|
||||
username=self.creds['username'],
|
||||
password=self.creds['password'],
|
||||
tenant_name=self.creds['tenant_name'])
|
||||
session = kssession.Session(auth=auth)
|
||||
keystone = ksclient.Client(**self.creds)
|
||||
murano_endpoint = keystone.service_catalog.url_for(
|
||||
service_type='application-catalog',
|
||||
|
@ -65,9 +75,7 @@ class MuranoDriver(datasource_driver.PollingDataSourceDriver,
|
|||
logger.debug("murano_endpoint = %s" % murano_endpoint)
|
||||
client_version = "1"
|
||||
self.murano_client = muranoclient.client.Client(
|
||||
client_version,
|
||||
endpoint=murano_endpoint,
|
||||
token=keystone.auth_token)
|
||||
client_version, murano_endpoint, session=session)
|
||||
self.add_executable_client_methods(
|
||||
self.murano_client,
|
||||
'muranoclient.v1.')
|
||||
|
@ -115,12 +123,7 @@ class MuranoDriver(datasource_driver.PollingDataSourceDriver,
|
|||
self._translate_deployments(environments)
|
||||
self._translate_connected()
|
||||
except murano_exceptions.HTTPException as e:
|
||||
if e.code == 401:
|
||||
logger.debug("Obtain keystone token again")
|
||||
keystone = ksclient.Client(**self.creds)
|
||||
self.murano_client.auth_token = keystone.auth_token
|
||||
else:
|
||||
raise e
|
||||
raise e
|
||||
|
||||
@classmethod
|
||||
def get_schema(cls):
|
||||
|
|
Loading…
Reference in New Issue