[goal] Deprecate the JSON formatted policy file
As per the community goal of migrating the policy file the format from JSON to YAML[1], we need to do two things: 1. Change the default value of '[oslo_policy] policy_file'' config option from 'policy.json' to 'policy.yaml' with upgrade checks. 2. Deprecate the JSON formatted policy file on the project side via warning in doc and releasenotes. Also replace policy.json to policy.yaml ref from doc and tests. [1]https://governance.openstack.org/tc/goals/selected/wallaby/migrate-policy-format-from-json-to-yaml.html Change-Id: Ibfb162f88cb04c0b2af3fbf41cfcd96bc7e351be
This commit is contained in:
parent
90754d0b78
commit
dea6f95c15
@ -753,7 +753,7 @@ driver = monasca_api.common.messaging.kafka_publisher:KafkaPublisher
|
||||
#enforce_scope = false
|
||||
|
||||
# The file that defines policies (string value)
|
||||
#policy_file = policy.json
|
||||
#policy_file = policy.yaml
|
||||
|
||||
# Default rule. Enforced when a requested rule is not found (string value)
|
||||
#policy_default_rule = default
|
||||
|
@ -54,16 +54,16 @@ os-api-ref==1.4.0
|
||||
os-client-config==1.28.0
|
||||
os-testr==1.0.0
|
||||
oslo.concurrency==3.25.0
|
||||
oslo.config==5.2.0
|
||||
oslo.context==2.19.2
|
||||
oslo.config==6.8.0
|
||||
oslo.context==2.22.0
|
||||
oslo.db==6.0.0
|
||||
oslo.i18n==3.15.3
|
||||
oslo.log==3.36.0
|
||||
oslo.middleware==3.31.0
|
||||
oslo.policy==1.30.0
|
||||
oslo.policy==3.6.0
|
||||
oslo.serialization==2.18.0
|
||||
oslo.utils==3.33.0
|
||||
oslo.upgradecheck==0.1.0 # Apache-2.0
|
||||
oslo.utils==4.5.0
|
||||
oslo.upgradecheck==1.3.0 # Apache-2.0
|
||||
oslotest==3.2.0
|
||||
paramiko==2.0.0
|
||||
PasteDeploy==1.5.0
|
||||
@ -85,13 +85,13 @@ python-keystoneclient==3.8.0
|
||||
python-mimeparse==1.6.0
|
||||
python-subunit==1.0.0
|
||||
pytz==2013.6
|
||||
PyYAML==3.13
|
||||
PyYAML==5.1
|
||||
reno==3.1.0
|
||||
requests==2.14.2
|
||||
requests==2.20.0
|
||||
requestsexceptions==1.2.0
|
||||
requests-mock==1.2.0
|
||||
restructuredtext-lint==1.1.1
|
||||
rfc3986==0.3.1
|
||||
rfc3986==1.2.0
|
||||
simplejson==3.8.1
|
||||
six==1.12.0
|
||||
smmap==0.9.0
|
||||
|
@ -20,6 +20,7 @@ https://governance.openstack.org/tc/goals/stein/upgrade-checkers.html
|
||||
import sys
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_upgradecheck import common_checks
|
||||
from oslo_upgradecheck import upgradecheck
|
||||
|
||||
|
||||
@ -34,11 +35,6 @@ class Checks(upgradecheck.UpgradeCommands):
|
||||
and added to _upgrade_checks tuple.
|
||||
"""
|
||||
|
||||
def _check_placeholder(self):
|
||||
# This is just a placeholder for upgrade checks, it should be
|
||||
# removed when the actual checks are added
|
||||
return upgradecheck.Result(upgradecheck.Code.SUCCESS)
|
||||
|
||||
# The format of the check functions is to return an
|
||||
# oslo_upgradecheck.upgradecheck.Result
|
||||
# object with the appropriate
|
||||
@ -47,8 +43,8 @@ class Checks(upgradecheck.UpgradeCommands):
|
||||
# in the returned Result's "details" attribute. The
|
||||
# summary will be rolled up at the end of the check() method.
|
||||
_upgrade_checks = (
|
||||
# In the future there should be some real checks added here
|
||||
(_('Placeholder'), _check_placeholder),
|
||||
(_('Policy File JSON to YAML Migration'),
|
||||
(common_checks.check_policy_json, {'conf': cfg.CONF})),
|
||||
)
|
||||
|
||||
|
||||
|
@ -22,6 +22,7 @@ import sys
|
||||
|
||||
import logging
|
||||
from oslo_config import cfg
|
||||
from oslo_policy import opts
|
||||
from oslo_policy import policy
|
||||
|
||||
from monasca_api.common.policy.i18n import _LW
|
||||
@ -41,6 +42,13 @@ _ENFORCER = None
|
||||
saved_file_rules = []
|
||||
|
||||
|
||||
# TODO(gmann): Remove setting the default value of config policy_file
|
||||
# once oslo_policy change the default value to 'policy.yaml'.
|
||||
# https://github.com/openstack/oslo.policy/blob/a626ad12fe5a3abd49d70e3e5b95589d279ab578/oslo_policy/opts.py#L49
|
||||
DEFAULT_POLICY_FILE = 'policy.yaml'
|
||||
opts.set_defaults(cfg.CONF, DEFAULT_POLICY_FILE)
|
||||
|
||||
|
||||
def reset():
|
||||
"""Reset Enforcer class."""
|
||||
global _ENFORCER
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
import unittest
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_upgradecheck.upgradecheck import Code
|
||||
|
||||
from monasca_api.cmd import status
|
||||
@ -25,9 +26,13 @@ class TestUpgradeChecks(unittest.TestCase):
|
||||
def setUp(self):
|
||||
super(TestUpgradeChecks, self).setUp()
|
||||
self.cmd = status.Checks()
|
||||
cfg.CONF(args=[], project='magnum')
|
||||
|
||||
def test__check_placeholder(self):
|
||||
check_result = self.cmd._check_placeholder()
|
||||
self.assertEqual(
|
||||
Code.SUCCESS, check_result.code,
|
||||
"Placeholder should always succeed.")
|
||||
def test_checks(self):
|
||||
for name, func in self.cmd._upgrade_checks:
|
||||
if isinstance(func, tuple):
|
||||
func_name, kwargs = func
|
||||
result = func_name(self, **kwargs)
|
||||
else:
|
||||
result = func(self)
|
||||
self.assertEqual(Code.SUCCESS, result.code)
|
||||
|
@ -0,0 +1,20 @@
|
||||
---
|
||||
upgrade:
|
||||
- |
|
||||
The default value of ``[oslo_policy] policy_file`` config option has
|
||||
been changed from ``policy.json`` to ``policy.yaml``.
|
||||
Operators who are utilizing customized or previously generated
|
||||
static policy JSON files (which are not needed by default), should
|
||||
generate new policy files or convert them in YAML format. Use the
|
||||
`oslopolicy-convert-json-to-yaml
|
||||
<https://docs.openstack.org/oslo.policy/latest/cli/oslopolicy-convert-json-to-yaml.html>`_
|
||||
tool to convert a JSON to YAML formatted policy file in
|
||||
backward compatible way.
|
||||
deprecations:
|
||||
- |
|
||||
Use of JSON policy files was deprecated by the ``oslo.policy`` library
|
||||
during the Victoria development cycle. As a result, this deprecation is
|
||||
being noted in the Wallaby cycle with an anticipated future removal of support
|
||||
by ``oslo.policy``. As such operators will need to convert to YAML policy
|
||||
files. Please see the upgrade notes for details on migration of any
|
||||
custom policy files.
|
@ -2,14 +2,14 @@
|
||||
# of appearance. Changing the order has an impact on the overall integration
|
||||
# process, which may cause wedges in the gate later.
|
||||
oslo.db>=6.0.0 # Apache-2.0
|
||||
oslo.config>=5.2.0 # Apache-2.0
|
||||
oslo.context>=2.19.2 # Apache-2.0
|
||||
oslo.config>=6.8.0 # Apache-2.0
|
||||
oslo.context>=2.22.0 # Apache-2.0
|
||||
oslo.log>=3.36.0 # Apache-2.0
|
||||
oslo.middleware>=3.31.0 # Apache-2.0
|
||||
oslo.policy>=1.30.0 # Apache-2.0
|
||||
oslo.policy>=3.6.0 # Apache-2.0
|
||||
oslo.serialization!=2.19.1,>=2.18.0 # Apache-2.0
|
||||
oslo.upgradecheck>=0.1.0 # Apache-2.0
|
||||
oslo.utils>=3.33.0 # Apache-2.0
|
||||
oslo.upgradecheck>=1.3.0 # Apache-2.0
|
||||
oslo.utils>=4.5.0 # Apache-2.0
|
||||
|
||||
python-keystoneclient>=3.8.0 # Apache-2.0
|
||||
|
||||
|
2
tox.ini
2
tox.ini
@ -138,7 +138,7 @@ description = Generates sample configuration file for monasca-api
|
||||
commands = oslo-config-generator --config-file=config-generator/monasca-api.conf
|
||||
|
||||
[testenv:genpolicy]
|
||||
description = Generates sample policy.json file for monasca-api
|
||||
description = Generates sample policy.yaml file for monasca-api
|
||||
commands = oslopolicy-sample-generator --config-file=config-generator/policy.conf
|
||||
|
||||
[testenv:venv]
|
||||
|
Loading…
Reference in New Issue
Block a user