From 8a1572a7e89c10b2d88ac41bb3d11ddf64f74832 Mon Sep 17 00:00:00 2001 From: Nikolay Mahotkin Date: Wed, 9 Aug 2017 11:49:09 +0300 Subject: [PATCH] [Triggers] Fix running openstack actions via triggers Change-Id: I49f77861825e6c7bd91f7de74f44ff02cefb04c8 Closes-Bug: #1709566 --- mistral/services/security.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mistral/services/security.py b/mistral/services/security.py index a9b76999a..93e3c207b 100644 --- a/mistral/services/security.py +++ b/mistral/services/security.py @@ -64,10 +64,18 @@ def create_context(trust_id, project_id): if CONF.pecan.auth_enable: client = keystone.client_for_trusts(trust_id) + if client.session: + # Method get_token is deprecated, using get_auth_headers. + token = client.session.get_auth_headers().get('X-Auth-Token') + user_id = client.session.get_user_id() + else: + token = client.auth_token + user_id = client.user_id + return auth_ctx.MistralContext( - user=client.user_id, + user=user_id, tenant=project_id, - auth_token=client.auth_token, + auth_token=token, is_trust_scoped=True, trust_id=trust_id, )