]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
heat engine : workaround lack of no_cache on essex
authorSteven Hardy <shardy@redhat.com>
Mon, 8 Oct 2012 15:21:25 +0000 (16:21 +0100)
committerSteven Hardy <shardy@redhat.com>
Mon, 8 Oct 2012 15:43:26 +0000 (16:43 +0100)
no_cache novaclient fix doesn't work on essex, so try
both the essex and the folsom compatible novaclient
prototypes

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

index 153b2437049813825b74ab54f477d3262ba3ee91..980ea04259b5a81ab4ec4d0126903a89fe2b6437 100644 (file)
@@ -70,13 +70,26 @@ def authenticate(con, service_type='orchestration', service_name='heat'):
     """
 
     if con.password is not None:
-        nova = client.Client(username=con.username,
-                             api_key=con.password,
-                             project_id=con.tenant,
-                             auth_url=con.auth_url,
-                             service_type=service_type,
-                             service_name=service_name,
-                             no_cache=True)
+        try:
+            # Workaround for issues with python-keyring, need no_cache=True
+            # ref https://bugs.launchpad.net/python-novaclient/+bug/1020238
+            # TODO(shardy): May be able to remove when the bug above is fixed
+            nova = client.Client(username=con.username,
+                                api_key=con.password,
+                                project_id=con.tenant,
+                                auth_url=con.auth_url,
+                                service_type=service_type,
+                                service_name=service_name,
+                                no_cache=True)
+        except TypeError:
+            # for compatibility with essex, which doesn't have no_cache=True
+            # TODO(shardy): remove when we no longer support essex
+            nova = client.Client(username=con.username,
+                                api_key=con.password,
+                                project_id=con.tenant,
+                                auth_url=con.auth_url,
+                                service_type=service_type,
+                                service_name=service_name)
         nova.authenticate()
         return nova
     else:
@@ -109,12 +122,25 @@ def authenticate(con, service_type='orchestration', service_name='heat'):
             logger.info("AWS authentication failure.")
             raise exception.AuthorizationFailure()
 
-        nova = client.Client(con.service_user, con.service_password,
-                             con.tenant, con.auth_url,
-                             proxy_token=token_id,
-                             proxy_tenant_id=con.tenant_id,
-                             service_type=service_type,
-                             service_name=service_name,
-                             no_cache=True)
+        try:
+            # Workaround for issues with python-keyring, need no_cache=True
+            # ref https://bugs.launchpad.net/python-novaclient/+bug/1020238
+            # TODO(shardy): May be able to remove when the bug above is fixed
+            nova = client.Client(con.service_user, con.service_password,
+                                 con.tenant, con.auth_url,
+                                 proxy_token=token_id,
+                                 proxy_tenant_id=con.tenant_id,
+                                 service_type=service_type,
+                                 service_name=service_name,
+                                 no_cache=True)
+        except TypeError:
+            # for compatibility with essex, which doesn't have no_cache=True
+            # TODO(shardy): remove when we no longer support essex
+            nova = client.Client(con.service_user, con.service_password,
+                                 con.tenant, con.auth_url,
+                                 proxy_token=token_id,
+                                 proxy_tenant_id=con.tenant_id,
+                                 service_type=service_type,
+                                 service_name=service_name)
         nova.authenticate()
         return nova