summaryrefslogtreecommitdiff
path: root/nova/policy.py
diff options
context:
space:
mode:
authorGhanshyam Mann <gmann@ghanshyammann.com>2019-12-31 02:48:47 +0000
committerMatt Riedemann <mriedem.os@gmail.com>2020-01-07 17:58:09 +0000
commitb0a0a7e00aeb5afc5758377dc925f2536f4a79c1 (patch)
tree7c51d45d268d2abcaa72f89ffbe5ceea62e7c8a2 /nova/policy.py
parent65aae518f81c2754e30429a3547c5cf62a3cf598 (diff)
downloadnova-b0a0a7e00aeb5afc5758377dc925f2536f4a79c1.tar.gz
Fix the suppress of policy deprecation warnings
oslo.policy log the deprected policy warning while loading the policy rule. Flag to suppress the warning was set after load_rule() was called. Moving the setting of suppress_deprecation_warnings flag before load_rule method is called. Closes-Bug: #1858652 Change-Id: I3f30df8f0fdf76d763ee4770af074a2f4f400ee8
Diffstat (limited to 'nova/policy.py')
-rw-r--r--nova/policy.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/nova/policy.py b/nova/policy.py
index 1117b08d42..90f6376400 100644
--- a/nova/policy.py
+++ b/nova/policy.py
@@ -49,7 +49,8 @@ def reset():
_ENFORCER = None
-def init(policy_file=None, rules=None, default_rule=None, use_conf=True):
+def init(policy_file=None, rules=None, default_rule=None, use_conf=True,
+ suppress_deprecation_warnings=False):
"""Init an Enforcer class.
:param policy_file: Custom policy file to use, if none is specified,
@@ -59,6 +60,8 @@ def init(policy_file=None, rules=None, default_rule=None, use_conf=True):
:param default_rule: Default rule to use, CONF.default_rule will
be used if none is specified.
:param use_conf: Whether to load rules from config file.
+ :param suppress_deprecation_warnings: Whether to suppress the
+ deprecation warnings.
"""
global _ENFORCER
@@ -70,6 +73,8 @@ def init(policy_file=None, rules=None, default_rule=None, use_conf=True):
rules=rules,
default_rule=default_rule,
use_conf=use_conf)
+ if suppress_deprecation_warnings:
+ _ENFORCER.suppress_deprecation_warnings = True
register_rules(_ENFORCER)
_ENFORCER.load_rules()