diff --git a/magnum/common/policy.py b/magnum/common/policy.py index d4bfff77b5..b08914ef9f 100644 --- a/magnum/common/policy.py +++ b/magnum/common/policy.py @@ -119,6 +119,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 d62a56bef2..14c8dae9bd 100644 --- a/setup.cfg +++ b/setup.cfg @@ -45,6 +45,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