Merge "Support v2 Keystone API in client"
This commit is contained in:
@@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from keystoneclient.v3 import client as keystone_client
|
|
||||||
|
|
||||||
from mistralclient.api import httpclient
|
from mistralclient.api import httpclient
|
||||||
from mistralclient.api import workbooks
|
from mistralclient.api import workbooks
|
||||||
from mistralclient.api import executions
|
from mistralclient.api import executions
|
||||||
@@ -77,18 +75,17 @@ class Client(object):
|
|||||||
raise RuntimeError('Only user name or user id'
|
raise RuntimeError('Only user name or user id'
|
||||||
' should be set')
|
' should be set')
|
||||||
|
|
||||||
if "v2.0" in auth_url:
|
keystone_client = _get_keystone_client(auth_url)
|
||||||
raise RuntimeError('Mistral supports only v3 '
|
|
||||||
'keystone API. Please see help and '
|
|
||||||
'configure the correct auth url.')
|
|
||||||
|
|
||||||
keystone = keystone_client.Client(username=username,
|
keystone = keystone_client.Client(
|
||||||
user_id=user_id,
|
username=username,
|
||||||
password=api_key,
|
user_id=user_id,
|
||||||
token=auth_token,
|
password=api_key,
|
||||||
project_id=project_id,
|
token=auth_token,
|
||||||
project_name=project_name,
|
tenant_id=project_id,
|
||||||
auth_url=auth_url)
|
tenant_name=project_name,
|
||||||
|
auth_url=auth_url,
|
||||||
|
endpoint=auth_url)
|
||||||
|
|
||||||
keystone.authenticate()
|
keystone.authenticate()
|
||||||
token = keystone.auth_token
|
token = keystone.auth_token
|
||||||
@@ -105,3 +102,11 @@ class Client(object):
|
|||||||
mistral_url = service[0].get('url') if service else None
|
mistral_url = service[0].get('url') if service else None
|
||||||
|
|
||||||
return mistral_url, token, project_id, user_id
|
return mistral_url, token, project_id, user_id
|
||||||
|
|
||||||
|
|
||||||
|
def _get_keystone_client(auth_url):
|
||||||
|
if "v2.0" in auth_url:
|
||||||
|
from keystoneclient.v2_0 import client
|
||||||
|
else:
|
||||||
|
from keystoneclient.v3 import client
|
||||||
|
return client
|
||||||
|
Reference in New Issue
Block a user