Fix bug 742 26/7626/1
authorEduardo Sousa <eduardo.sousa@canonical.com>
Thu, 6 Jun 2019 14:00:50 +0000 (15:00 +0100)
committerEduardo Sousa <eduardo.sousa@canonical.com>
Thu, 6 Jun 2019 14:00:50 +0000 (15:00 +0100)
Change-Id: I66406b2afcdbbb6a0717197a728d65fde45e7b27
Signed-off-by: Eduardo Sousa <eduardo.sousa@canonical.com>
osm_nbi/admin_topics.py
osm_nbi/engine.py

index 71fb83b..76d4de8 100644 (file)
@@ -508,8 +508,9 @@ class UserTopicAuth(UserTopic):
             self.format_on_new(content, session["project_id"], make_public=session["public"])
             _id = self.auth.create_user(content["username"], content["password"])["_id"]
 
-            for mapping in content["project_role_mappings"]:
-                self.auth.assign_role_to_user(_id, mapping["project"], mapping["role"])
+            if "project_role_mappings" in content.keys():
+                for mapping in content["project_role_mappings"]:
+                    self.auth.assign_role_to_user(_id, mapping["project"], mapping["role"])
 
             rollback.append({"topic": self.topic, "_id": _id})
             del content["password"]
index f7bc012..d8409ea 100644 (file)
@@ -128,12 +128,12 @@ class Engine(object):
                         if path.isfile(config_file):
                             resources_to_operations_file = config_file
                             break
-                    if not resources_to_operations_file:                        
+                    if not resources_to_operations_file:                   
                         raise EngineException("Invalid permission configuration: resources_to_operations file missing")
-                
+
                 with open(resources_to_operations_file, 'r') as f:
                     resources_to_operations = yaml.load(f)
-                
+
                 self.operations = []
 
                 for _, value in resources_to_operations["resources_to_operations"].items():