Fix Bug 870: Getting unauthorized when using keystone as back-end for NBI
[osm/NBI.git] / osm_nbi / auth.py
index 8bb479d..023d286 100644 (file)
@@ -214,7 +214,7 @@ class Authenticator:
         # Loading permissions to MongoDB if there is not any permission.
         if not records or (len(records) == 1 and records[0]["name"] == "admin"):
             with open(self.roles_to_operations_file, "r") as stream:
-                roles_to_operations_yaml = yaml.load(stream)
+                roles_to_operations_yaml = yaml.load(stream, Loader=yaml.Loader)
 
             role_names = []
             for role_with_operations in roles_to_operations_yaml["roles"]:
@@ -282,8 +282,8 @@ class Authenticator:
                     self.backend.update_user({"_id": user_admin_id,
                                               "add_project_role_mappings": [{"project": pid, "role": role_id}]})
                     self.logger.info("Added role system admin to user='{}' project=admin".format(user_admin_id))
-            except Exception:
-                pass
+            except Exception as e:
+                self.logger.error("Error in Authorization DataBase initialization: {}: {}".format(type(e).__name__, e))
 
         self.load_operation_to_allowed_roles()