Browse Source

Merge "Add entry_point for oslo policy scripts"

tags/13.0.0.0rc1
Zuul 7 months ago
parent
commit
2d617cb44c
2 changed files with 12 additions and 0 deletions
  1. +9
    -0
      heat/common/policy.py
  2. +3
    -0
      setup.cfg

+ 9
- 0
heat/common/policy.py View File

@@ -51,6 +51,8 @@ class Enforcer(object):

# register 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):
"""Create a new Rules object based on the provided dict of rules."""
@@ -118,6 +120,13 @@ class Enforcer(object):
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():
global ENFORCER
if ENFORCER is None:

+ 3
- 0
setup.cfg View File

@@ -60,6 +60,9 @@ oslo.config.opts =
oslo.config.opts.defaults =
heat.common.config = heat.common.config:set_config_defaults

oslo.policy.enforcer =
heat = heat.common.policy:get_policy_enforcer

oslo.policy.policies =
heat = heat.policies:list_rules


Loading…
Cancel
Save