Add entry_point for oslo policy scripts
With the setup.cfg entry it can be called directly from oslo.policy. $oslopolicy-policy-generator --namespace heat This will get the effective policy that’s being executed. Change-Id: Iad2e71819f4847f47dd17d3cd4afa78e6b3f52a7 Story: #2005055 Task: 29573
This commit is contained in:
parent
87b4a92a62
commit
5bdcaeff01
|
@ -51,6 +51,8 @@ class Enforcer(object):
|
||||||
|
|
||||||
# register rules
|
# register rules
|
||||||
self.enforcer.register_defaults(policies.list_rules())
|
self.enforcer.register_defaults(policies.list_rules())
|
||||||
|
self.file_rules = self.enforcer.file_rules
|
||||||
|
self.registered_rules = self.enforcer.registered_rules
|
||||||
|
|
||||||
def set_rules(self, rules, overwrite=True):
|
def set_rules(self, rules, overwrite=True):
|
||||||
"""Create a new Rules object based on the provided dict of rules."""
|
"""Create a new Rules object based on the provided dict of rules."""
|
||||||
|
@ -118,6 +120,13 @@ class Enforcer(object):
|
||||||
is_registered_policy=True)
|
is_registered_policy=True)
|
||||||
|
|
||||||
|
|
||||||
|
def get_policy_enforcer():
|
||||||
|
# This method is used by oslopolicy CLI scripts to generate policy
|
||||||
|
# files from overrides on disk and defaults in code.
|
||||||
|
CONF([], project='heat')
|
||||||
|
return get_enforcer()
|
||||||
|
|
||||||
|
|
||||||
def get_enforcer():
|
def get_enforcer():
|
||||||
global ENFORCER
|
global ENFORCER
|
||||||
if ENFORCER is None:
|
if ENFORCER is None:
|
||||||
|
|
|
@ -60,6 +60,9 @@ oslo.config.opts =
|
||||||
oslo.config.opts.defaults =
|
oslo.config.opts.defaults =
|
||||||
heat.common.config = heat.common.config:set_config_defaults
|
heat.common.config = heat.common.config:set_config_defaults
|
||||||
|
|
||||||
|
oslo.policy.enforcer =
|
||||||
|
heat = heat.common.policy:get_policy_enforcer
|
||||||
|
|
||||||
oslo.policy.policies =
|
oslo.policy.policies =
|
||||||
heat = heat.policies:list_rules
|
heat = heat.policies:list_rules
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue