]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Fix swift client token authentication
authorSteve Baker <sbaker@redhat.com>
Tue, 26 Mar 2013 04:11:47 +0000 (17:11 +1300)
committerSteve Baker <sbaker@redhat.com>
Tue, 26 Mar 2013 04:11:47 +0000 (17:11 +1300)
Triggered by launching a stack containing swift containers
through Horizon.

The swift client does its own endpoint lookup if we don't know
it, so we don't have to do it ourselves. Also, our endpoint lookup
was broken in the auth_token codepath.

Part of blueprint auth-token-only

Change-Id: I1876f233001a58cb17e7dd7d5cf8883e295a9b87

heat/engine/clients.py

index e2ac0739be7a592a4b176593d943d84fff503348..9b30581fd63d97d24e30c471b9ff3939ece95fd3 100644 (file)
@@ -120,34 +120,24 @@ class OpenStackClients(object):
 
         con = self.context
         args = {
-            'auth_version': '2'
+            'auth_version': '2',
+            'tenant_name': con.tenant,
+            'authurl': con.auth_url,
+            'user': con.username
         }
 
         if con.password is not None:
-            args['user'] = con.username
             args['key'] = con.password
-            args['authurl'] = con.auth_url
-            args['tenant_name'] = con.tenant
         elif con.auth_token is not None:
-            args['user'] = None
-            args['key'] = None
-            args['authurl'] = None
-            args['preauthtoken'] = con.auth_token
-            # Lookup endpoint for object-store service type
-            service_type = 'object-store'
-            endpoints = self.keystone().service_catalog.get_endpoints(
-                service_type=service_type)
-            if len(endpoints[service_type]) == 1:
-                args['preauthurl'] = endpoints[service_type][0]['publicURL']
-            else:
-                logger.error("No endpoint found for %s service type" %
-                             service_type)
-                return None
+            args['os_options'] = {
+                'tenant_id': con.tenant_id,
+                'auth_token': con.auth_token,
+                'tenant_name': con.tenant
+            }
         else:
             logger.error("Swift connection failed, no password or " +
                          "auth_token!")
             return None
-
         self._swift = swiftclient.Connection(**args)
         return self._swift