Skip to content

Commit

Permalink
fix(create-policy): create and skip if exists (#698)
Browse files Browse the repository at this point in the history
  • Loading branch information
vpsx authored Sep 18, 2019
1 parent 4e80b35 commit 79ca3cf
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions fence/sync/sync_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,9 @@ def _update_arborist(self, session, user_yaml):
policies = user_yaml.rbac.get("policies", [])
for policy in policies:
try:
response = self.arborist_client.put_policy(policy)
response = self.arborist_client.create_policy(
policy, skip_if_exists=True
)
if response:
self._created_policies.add(policy["id"])
except ArboristError as e:
Expand Down Expand Up @@ -1188,13 +1190,14 @@ def _update_authz_in_arborist(self, session, user_projects, user_yaml=None):
policy_id = _format_policy_id(path, permission)
if policy_id not in self._created_policies:
try:
self.arborist_client.put_policy(
self.arborist_client.create_policy(
{
"id": policy_id,
"description": "policy created by fence sync",
"role_ids": [permission],
"resource_paths": [path],
}
},
skip_if_exists=True,
)
except ArboristError as e:
self.logger.info(
Expand Down

0 comments on commit 79ca3cf

Please sign in to comment.