summaryrefslogtreecommitdiff
path: root/oslo_policy
diff options
context:
space:
mode:
authorGhanshyam Mann <gmann@ghanshyammann.com>2021-01-28 10:17:38 -0600
committerGhanshyam <gmann@ghanshyammann.com>2021-01-29 00:15:44 +0000
commitb7489eb75a9bde1c1fd36e5e1e547bf60b7bc189 (patch)
treee8cc40f1f710f6e53c9c27e01921dc747673d8d7 /oslo_policy
parente103baa002e54303b08630c436dfc7b0b8a013de (diff)
downloadoslo-policy-b7489eb75a9bde1c1fd36e5e1e547bf60b7bc189.tar.gz
Add debug log in pick_default_policy_file
We have many if else condition to pick the right policy filebut there is no debugging log to have useful info to know if expected policy file is not picked. Change-Id: I507c58a6dca06d0cc6f306bcd063c700c18cc5f7
Diffstat (limited to 'oslo_policy')
-rw-r--r--oslo_policy/policy.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/oslo_policy/policy.py b/oslo_policy/policy.py
index f21ebe9..38a5e30 100644
--- a/oslo_policy/policy.py
+++ b/oslo_policy/policy.py
@@ -370,15 +370,25 @@ def pick_default_policy_file(conf, fallback_to_json_file=True):
new_default_policy_file = 'policy.yaml'
old_default_policy_file = 'policy.json'
+ policy_file = None
if ((conf.oslo_policy.policy_file == new_default_policy_file) and
fallback_to_json_file):
location = conf.get_location('policy_file', 'oslo_policy').location
if conf.find_file(conf.oslo_policy.policy_file):
- return conf.oslo_policy.policy_file
+ policy_file = conf.oslo_policy.policy_file
elif location in [cfg.Locations.opt_default,
cfg.Locations.set_default]:
+ LOG.debug('Searching old policy.json file.')
if conf.find_file(old_default_policy_file):
- return old_default_policy_file
+ policy_file = old_default_policy_file
+ if policy_file:
+ LOG.debug(
+ 'Picking default policy file: %s. Config location: %s',
+ policy_file, location)
+ return policy_file
+ LOG.debug(
+ 'No default policy file present, picking the configured '
+ 'one: %s.', conf.oslo_policy.policy_file)
# Return overridden policy file
return conf.oslo_policy.policy_file