diff --git a/magnum/common/policy.py b/magnum/common/policy.py index ff98454e03..25cb3c7b39 100644 --- a/magnum/common/policy.py +++ b/magnum/common/policy.py @@ -132,6 +132,14 @@ def add_policy_attributes(target): return target +def get_enforcer(): + # This method is used by oslopolicy CLI scripts in order to generate policy + # files from overrides on disk and defaults in code. + cfg.CONF([], project='magnum') + init() + return _ENFORCER + + def check_is_admin(context): """Whether or not user is admin according to policy setting. diff --git a/setup.cfg b/setup.cfg index dd61784c2a..4e9f4be416 100644 --- a/setup.cfg +++ b/setup.cfg @@ -47,6 +47,9 @@ oslo.config.opts = oslo.config.opts.defaults = magnum = magnum.common.config:set_config_defaults +oslo.policy.enforcer = + magnum = magnum.common.policy:get_enforcer + oslo.policy.policies = magnum = magnum.common.policies:list_rules