Skip to content

Commit 8d09169

Browse files
author
Ghanshyam Mann
committed
Fix oslo policy file genrator tool for Magnum
oslo tool to generate the policy or sample policy file does not work for magnum service. ``oslopolicy-policy-generator --namespace magnum`` end up with below error: ModuleNotFoundError: No module named 'magnum.policy' same error with oslopolicy-sample-generator --namespace magnum oslo.policy policy generator tool look for the service oslo policy enforcer entry and does not find it. setup.cfg file is missing the entry point for magnum oslo policy enforcer. - https://lists.openstack.org/archives/list/[email protected]/thread/5ZRWWL3YKWX3XCFGTC4G2KP6PCJMBL64/ Closes-Bug: #2068519 Change-Id: Iff94f7dea491b0ea465b17cd60c37423224f9ffa
1 parent b758df6 commit 8d09169

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

magnum/common/policy.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,14 @@ def add_policy_attributes(target):
132132
return target
133133

134134

135+
def get_enforcer():
136+
# This method is used by oslopolicy CLI scripts in order to generate policy
137+
# files from overrides on disk and defaults in code.
138+
cfg.CONF([], project='magnum')
139+
init()
140+
return _ENFORCER
141+
142+
135143
def check_is_admin(context):
136144
"""Whether or not user is admin according to policy setting.
137145

setup.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ oslo.config.opts =
4747
oslo.config.opts.defaults =
4848
magnum = magnum.common.config:set_config_defaults
4949

50+
oslo.policy.enforcer =
51+
magnum = magnum.common.policy:get_enforcer
52+
5053
oslo.policy.policies =
5154
magnum = magnum.common.policies:list_rules
5255

0 commit comments

Comments
 (0)