Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/nova/policy.py b/nova/policy.py
- index ad1b79c542..ea79e47b83 100644
- --- a/nova/policy.py
- +++ b/nova/policy.py
- @@ -48,6 +48,22 @@ def reset():
- _ENFORCER = None
- +def pick_file(policy_file):
- + if policy_file:
- + return policy file
- +
- + if CONF.policy_file == DEFAULT_POLICY_FILE:
- + if os.path.exists(CONF.policy_file):
- + return CONF.policy_file
- + else:
- + # Do this smarter
- + json_backup = CONF.policy_file.replace('yaml', 'json')
- + if os.path.exists(json_backup):
- + return json_backup
- + # Same behavior if no overrides
- + return CONF.policy_file
- +
- +
- def init(policy_file=None, rules=None, default_rule=None, use_conf=True,
- suppress_deprecation_warnings=False):
- """Init an Enforcer class.
- @@ -68,7 +84,7 @@ def init(policy_file=None, rules=None, default_rule=None, use_conf=True,
- if not _ENFORCER:
- _ENFORCER = policy.Enforcer(CONF,
- - policy_file=policy_file,
- + policy_file=pick_file(policy_file),
- rules=rules,
- default_rule=default_rule,
- use_conf=use_conf)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement