aboutsummaryrefslogtreecommitdiffstats
path: root/moonv4
diff options
context:
space:
mode:
authorasteroide <thomas.duval@orange.com>2017-05-05 11:12:53 +0200
committerasteroide <thomas.duval@orange.com>2017-05-05 11:12:53 +0200
commit67369036badcb4ae84fb7c1c7d7dabfab27326e6 (patch)
tree805c102220f21c861b99ecf3ffca3f457b55cfb8 /moonv4
parentbbd3dd78e209225c86ac71107a9d55d5d7615ad6 (diff)
Fix a bug when updating a perimeter element
Change-Id: I99e163634074b6f5fc5974cdf6417b118021a249
Diffstat (limited to 'moonv4')
-rw-r--r--moonv4/moon_manager/moon_manager/api/policies.py27
1 files changed, 15 insertions, 12 deletions
diff --git a/moonv4/moon_manager/moon_manager/api/policies.py b/moonv4/moon_manager/moon_manager/api/policies.py
index 88c762a4..3c876fae 100644
--- a/moonv4/moon_manager/moon_manager/api/policies.py
+++ b/moonv4/moon_manager/moon_manager/api/policies.py
@@ -76,10 +76,11 @@ class Perimeter(object):
try:
if not ctx["perimeter_id"]:
data = self.manager.get_subjects(user_id=ctx["user_id"], policy_id=None)
- for data_id, data_value in data.items():
- if data_value['name'] == args['name']:
- ctx["perimeter_id"] = data_id
- break
+ if 'name' in args:
+ for data_id, data_value in data.items():
+ if data_value['name'] == args['name']:
+ ctx["perimeter_id"] = data_id
+ break
data = self.manager.add_subject(user_id=ctx["user_id"], policy_id=ctx["id"],
perimeter_id=ctx["perimeter_id"], value=args)
except Exception as e:
@@ -112,10 +113,11 @@ class Perimeter(object):
def set_object(self, ctx, args):
try:
data = self.manager.get_objects(user_id=ctx["user_id"], policy_id=None)
- for data_id, data_value in data.items():
- if data_value['name'] == args['name']:
- ctx["perimeter_id"] = data_id
- break
+ if 'name' in args:
+ for data_id, data_value in data.items():
+ if data_value['name'] == args['name']:
+ ctx["perimeter_id"] = data_id
+ break
data = self.manager.add_object(user_id=ctx["user_id"], policy_id=ctx["id"],
perimeter_id=ctx["perimeter_id"], value=args)
except Exception as e:
@@ -148,10 +150,11 @@ class Perimeter(object):
def set_action(self, ctx, args):
try:
data = self.manager.get_actions(user_id=ctx["user_id"], policy_id=None)
- for data_id, data_value in data.items():
- if data_value['name'] == args['name']:
- ctx["perimeter_id"] = data_id
- break
+ if 'name' in args:
+ for data_id, data_value in data.items():
+ if data_value['name'] == args['name']:
+ ctx["perimeter_id"] = data_id
+ break
data = self.manager.add_action(user_id=ctx["user_id"], policy_id=ctx["id"],
perimeter_id=ctx["perimeter_id"], value=args)
except Exception as e: