Fix keystone trust client
* The issue popped up after release of python-keystoneclient 0.7. The issue is caused by new keystoneclient not accepting project_id and trust_id simultaneously as constructor parameters. Change-Id: Id0b7b582e9b794dace0f440df582ff9502b781c5
This commit is contained in:
parent
025343c050
commit
36a84e299e
|
@ -29,14 +29,7 @@ def create_trust(workbook):
|
|||
|
||||
ctx = context.ctx()
|
||||
|
||||
admin_user = CONF.keystone.admin_user
|
||||
admin_password = CONF.keystone.admin_password
|
||||
admin_tenant_name = CONF.keystone.admin_tenant_name
|
||||
|
||||
trustee_id = keystone.client_for_trusts(
|
||||
admin_user,
|
||||
admin_password,
|
||||
project_name=admin_tenant_name).user_id
|
||||
trustee_id = keystone.client_for_admin(ctx['project_id']).user_id
|
||||
|
||||
trust = client.trusts.create(trustor_user=client.user_id,
|
||||
trustee_user=trustee_id,
|
||||
|
@ -53,15 +46,8 @@ def create_context(workbook):
|
|||
if 'trust_id' not in workbook:
|
||||
return
|
||||
|
||||
admin_user = CONF.keystone.admin_user
|
||||
admin_password = CONF.keystone.admin_password
|
||||
|
||||
if CONF.pecan.auth_enable:
|
||||
client = keystone.client_for_trusts(
|
||||
admin_user,
|
||||
admin_password,
|
||||
trust_id=workbook['trust_id'],
|
||||
project_id=workbook['project_id'])
|
||||
client = keystone.client_for_trusts(workbook['trust_id'])
|
||||
|
||||
return context.MistralContext(
|
||||
user_id=client.user_id,
|
||||
|
@ -80,11 +66,5 @@ def delete_trust(workbook):
|
|||
if 'trust_id' not in workbook:
|
||||
return
|
||||
|
||||
admin_user = CONF.keystone.admin_user
|
||||
admin_password = CONF.keystone.admin_password
|
||||
|
||||
keystone_client = keystone.client_for_trusts(
|
||||
admin_user,
|
||||
admin_password,
|
||||
workbook.trust_id)
|
||||
keystone_client = keystone.client_for_trusts(workbook['trust_id'])
|
||||
keystone_client.trusts.delete(workbook.trust_id)
|
||||
|
|
|
@ -171,6 +171,9 @@ class TestExecutor(base.DbTestCase):
|
|||
task['id'])
|
||||
# Ensure the request reached the executor and the action has ran.
|
||||
if db_task['state'] != states.IDLE:
|
||||
# We have to wait sometime due to time interval between set
|
||||
# task state to RUNNING and invocation action.run()
|
||||
time.sleep(0.1)
|
||||
mock_rest_action.assert_called_once_with()
|
||||
self.assertIn(db_task['state'],
|
||||
[states.RUNNING, states.SUCCESS, states.ERROR])
|
||||
|
|
|
@ -34,16 +34,22 @@ def client():
|
|||
return keystone
|
||||
|
||||
|
||||
def client_for_trusts(username, password, project_name=None, trust_id=None,
|
||||
project_id=None):
|
||||
def _admin_client(trust_id=None, project_id=None):
|
||||
auth_url = CONF.keystone.auth_uri
|
||||
|
||||
client = keystone_client.Client(username=username,
|
||||
password=password,
|
||||
tenant_name=project_name,
|
||||
tenant_id=project_id,
|
||||
client = keystone_client.Client(username=CONF.keystone.admin_user,
|
||||
password=CONF.keystone.admin_password,
|
||||
project_id=project_id,
|
||||
auth_url=auth_url,
|
||||
trust_id=trust_id)
|
||||
client.management_url = auth_url
|
||||
|
||||
return client
|
||||
|
||||
|
||||
def client_for_admin(project_id):
|
||||
return _admin_client(project_id=project_id)
|
||||
|
||||
|
||||
def client_for_trusts(trust_id):
|
||||
return _admin_client(trust_id=trust_id)
|
||||
|
|
Loading…
Reference in New Issue