From c2d262e6b26d0dd14c6f6c76100e78a4154fef08 Mon Sep 17 00:00:00 2001 From: Steven Hardy Date: Fri, 19 Oct 2012 19:11:51 +0100 Subject: [PATCH] heat engine : Resource.keystone handle auth_token Handle auth_token as well as username/password Fixes #268 Change-Id: I7015556d74e026977fdd04f4ce9a378c0fac7695 Signed-off-by: Steven Hardy --- heat/engine/resources.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/heat/engine/resources.py b/heat/engine/resources.py index 2e5879af..a305bab3 100644 --- a/heat/engine/resources.py +++ b/heat/engine/resources.py @@ -221,10 +221,27 @@ class Resource(object): return self._keystone con = self.context - self._keystone = kc.Client(username=con.username, - password=con.password, - tenant_name=con.tenant, - auth_url=con.auth_url) + args = { + 'tenant_name': con.tenant, + 'tenant_id': con.tenant_id, + 'auth_url': con.auth_url, + } + + if con.password is not None: + args['username'] = con.username + args['password'] = con.password + elif con.auth_token is not None: + args['username'] = con.service_user + args['password'] = con.service_password + args['token'] = con.auth_token + else: + logger.error("Keystone connectio failed, no password or " + + "auth_token!") + return None + + client = kc.Client(**args) + client.authenticate() + self._keystone = client return self._keystone def nova(self, service_type='compute'): -- 2.45.2