summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRabi Mishra <ramishra@redhat.com>2019-02-20 14:51:20 +0530
committerRabi Mishra <ramishra@redhat.com>2019-04-23 11:40:07 +0000
commit7120d18b502865470cde879bc801274c47157355 (patch)
tree19187f2bbe9614a4d926d2b3ad97f134bc54810c
parentdf958c99af859ff673cd09adf1bbef1571bc9662 (diff)
downloadheat-7120d18b502865470cde879bc801274c47157355.tar.gz
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 (cherry picked from commit 5bdcaeff018782a956fd8228e04ddd2169c353c6)
-rw-r--r--heat/common/policy.py9
-rw-r--r--setup.cfg3
2 files changed, 12 insertions, 0 deletions
diff --git a/heat/common/policy.py b/heat/common/policy.py
index 4707c9673..312608c93 100644
--- a/heat/common/policy.py
+++ b/heat/common/policy.py
@@ -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:
diff --git a/setup.cfg b/setup.cfg
index 8a9935cfb..3c82e9a21 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -59,6 +59,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