Provide fixes to tungten/patrole plugins
Patrole part of fixes:
1. fixed the search policy mechanism
now it possible to use tempest.conf file
to load contrail.json policy from custom place
Change-Id: Iff6800c7936bab4cae5645cfef54b1b2575d431d
Related-PROD: PROD-23985
diff --git a/patrole_tempest_plugin/policy_authority.py b/patrole_tempest_plugin/policy_authority.py
index 3339a5d..bd1830f 100644
--- a/patrole_tempest_plugin/policy_authority.py
+++ b/patrole_tempest_plugin/policy_authority.py
@@ -99,7 +99,7 @@
# "service:another_test_rule", which means that the default policy
# rule is used: "rule:admin_or_owner".
"""
-
+ service = service.lower()
if extra_target_data is None:
extra_target_data = {}
@@ -145,13 +145,13 @@
``cls.available_services``. Pick the first candidate path found
out of the potential paths in ``[patrole] custom_policy_files``.
"""
- if not hasattr(cls, 'policy_files'):
+ p_files = getattr(cls, 'policy_files', None)
+ if not p_files:
cls.policy_files = {}
for service in cls.available_services:
for candidate_path in CONF.patrole.custom_policy_files:
- if os.path.isfile(candidate_path % service):
- cls.policy_files.setdefault(service,
- candidate_path % service)
+ if service in candidate_path.lower() and os.path.isfile(candidate_path):
+ cls.policy_files.setdefault(service, candidate_path)
def allowed(self, rule_name, role):
"""Checks if a given rule in a policy is allowed with given role.