]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
heat engine : Resource.keystone handle auth_token
authorSteven Hardy <shardy@redhat.com>
Fri, 19 Oct 2012 18:11:51 +0000 (19:11 +0100)
committerSteven Hardy <shardy@redhat.com>
Fri, 19 Oct 2012 18:17:38 +0000 (19:17 +0100)
Handle auth_token as well as username/password

Fixes #268

Change-Id: I7015556d74e026977fdd04f4ce9a378c0fac7695
Signed-off-by: Steven Hardy <shardy@redhat.com>
heat/engine/resources.py

index 2e5879af24495d537c8857cbecde9d1f0fe47d4c..a305bab3467b52630ad6a0f54b63e60dad76a59f 100644 (file)
@@ -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'):