Add oslo.policy.enforcer entry point

this will allow usage of many oslo.policy scripts, e.g.
to generate current effective policy, or to list redundant polices
defined in policy files.

Change-Id: I1de9b6cc16be2896136c7e99cf150c4b8e4603e9
Closes-Bug: #2004421
This commit is contained in:
Pavlo Shchelokovskyy 2023-01-31 20:56:45 +02:00 committed by Michael Johnson
parent a9cf887da1
commit 6389eb4c68
2 changed files with 11 additions and 0 deletions

View File

@ -106,3 +106,11 @@ def enforce_new_defaults():
if CONF.get('oslo_policy'):
return CONF['oslo_policy'].get('enforce_new_defaults', False)
return False
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='designate')
init()
return _ENFORCER

View File

@ -42,6 +42,9 @@ oslo.config.opts.defaults =
oslo.policy.policies =
designate = designate.common.policies:list_rules
oslo.policy.enforcer =
designate = designate.policy:get_enforcer
console_scripts =
designate-rootwrap = oslo_rootwrap.cmd:main
designate-api = designate.cmd.api:main