From: Steven Hardy Date: Fri, 19 Oct 2012 18:11:51 +0000 (+0100) Subject: heat engine : Resource.keystone handle auth_token X-Git-Tag: 2014.1~1288 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=c2d262e6b26d0dd14c6f6c76100e78a4154fef08;p=openstack-build%2Fheat-build.git 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 --- 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'):