From: Eduardo Sousa Date: Thu, 6 Jun 2019 14:00:50 +0000 (+0100) Subject: Fix bug 742 X-Git-Tag: v6.0.0~8 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=a519a962c9bf008ddbee26500557b1de287f323a;p=osm%2FNBI.git Fix bug 742 Change-Id: I66406b2afcdbbb6a0717197a728d65fde45e7b27 Signed-off-by: Eduardo Sousa --- 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():