From a519a962c9bf008ddbee26500557b1de287f323a Mon Sep 17 00:00:00 2001 From: Eduardo Sousa Date: Thu, 6 Jun 2019 15:00:50 +0100 Subject: [PATCH] Fix bug 742 Change-Id: I66406b2afcdbbb6a0717197a728d65fde45e7b27 Signed-off-by: Eduardo Sousa --- osm_nbi/admin_topics.py | 5 +++-- osm_nbi/engine.py | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/osm_nbi/admin_topics.py b/osm_nbi/admin_topics.py index 71fb83b..76d4de8 100644 --- a/osm_nbi/admin_topics.py +++ b/osm_nbi/admin_topics.py @@ -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"] diff --git a/osm_nbi/engine.py b/osm_nbi/engine.py index f7bc012..d8409ea 100644 --- a/osm_nbi/engine.py +++ b/osm_nbi/engine.py @@ -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(): -- 2.25.1