NFVBENCH-147 Incorrect URL used for admin check in credentials 45/68345/2 3.5.1
authorahothan <ahothan@cisco.com>
Sun, 11 Aug 2019 17:41:21 +0000 (10:41 -0700)
committerahothan <ahothan@cisco.com>
Sun, 11 Aug 2019 17:47:04 +0000 (10:47 -0700)
Change-Id: I7ac59c3dc5832509653bb1d42c26d3f55dcf1c4e
Signed-off-by: ahothan <ahothan@cisco.com>
nfvbench/credentials.py

index 3a18981..9956c6f 100644 (file)
@@ -167,13 +167,20 @@ class Credentials(object):
             self.rc_password = ""
 
         # check if user has admin role in OpenStack project
+        filter = {'service_type': 'identity',
+                  'interface': 'public',
+                  'region_name': self.rc_region_name}
         try:
-            # vX/users URL returns exception (HTTP 403) if user is not admin.
+            # /users URL returns exception (HTTP 403) if user is not admin.
+            # try first without the version in case session already has it in
             # Return HTTP 200 if user is admin
-            self.get_session().get('/v' + str(self.rc_identity_api_version) + '/users',
-                                   endpoint_filter={'service_type': 'identity',
-                                                    'interface': 'public',
-                                                    'region_name': self.rc_region_name})
+            self.get_session().get('/users', endpoint_filter=filter)
             self.is_admin = True
         except Exception as e:
-            LOG.warning("User is not admin, no permission to list user roles. Exception: %s", e)
+            try:
+                # vX/users URL returns exception (HTTP 403) if user is not admin.
+                self.get_session().get('/v' + str(self.rc_identity_api_version) + '/users',
+                                       endpoint_filter=filter)
+                self.is_admin = True
+            except Exception as e:
+                LOG.warning("User is not admin, no permission to list user roles. Exception: %s", e)