summaryrefslogtreecommitdiff
path: root/ironic/common/policy.py
diff options
context:
space:
mode:
Diffstat (limited to 'ironic/common/policy.py')
-rw-r--r--ironic/common/policy.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/ironic/common/policy.py b/ironic/common/policy.py
index 811198206..efb92c5a5 100644
--- a/ironic/common/policy.py
+++ b/ironic/common/policy.py
@@ -21,6 +21,7 @@ import sys
from oslo_concurrency import lockutils
from oslo_config import cfg
from oslo_log import log
+from oslo_policy import opts
from oslo_policy import policy
from ironic.common import exception
@@ -29,6 +30,13 @@ _ENFORCER = None
CONF = cfg.CONF
LOG = log.getLogger(__name__)
+
+# TODO(gmann): Remove setting the default value of config policy_file
+# once oslo_policy change the default value to 'policy.yaml'.
+# https://github.com/openstack/oslo.policy/blob/a626ad12fe5a3abd49d70e3e5b95589d279ab578/oslo_policy/opts.py#L49
+DEFAULT_POLICY_FILE = 'policy.yaml'
+opts.set_defaults(cfg.CONF, DEFAULT_POLICY_FILE)
+
default_policies = [
# Legacy setting, don't remove. Likely to be overridden by operators who
# forget to update their policy.json configuration file.
@@ -591,10 +599,11 @@ def init_enforcer(policy_file=None, rules=None,
# loaded exactly once - when this module-global is initialized.
# Defining these in the relevant API modules won't work
# because API classes lack singletons and don't use globals.
- _ENFORCER = policy.Enforcer(CONF, policy_file=policy_file,
- rules=rules,
- default_rule=default_rule,
- use_conf=use_conf)
+ _ENFORCER = policy.Enforcer(
+ CONF, policy_file=policy_file,
+ rules=rules,
+ default_rule=default_rule,
+ use_conf=use_conf)
_ENFORCER.register_defaults(list_policies())