[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: Ia7365cc3ae09e2ff916ab9f9ff0ba4fef0dc446b
This commit is contained in:
parent
2ffb8ea237
commit
fa95ef8772
|
@ -3,7 +3,7 @@ Configuration Guide
|
||||||
===================
|
===================
|
||||||
|
|
||||||
The static configuration for Placement lives in two main files: ``placement.conf`` and
|
The static configuration for Placement lives in two main files: ``placement.conf`` and
|
||||||
``policy.json``. These are described below.
|
``policy.yaml``. These are described below.
|
||||||
|
|
||||||
Configuration
|
Configuration
|
||||||
-------------
|
-------------
|
||||||
|
|
|
@ -2,6 +2,14 @@
|
||||||
Placement Policies
|
Placement Policies
|
||||||
==================
|
==================
|
||||||
|
|
||||||
|
.. warning::
|
||||||
|
|
||||||
|
JSON formatted policy file is deprecated since Placement 5.0.0 (Wallaby).
|
||||||
|
The `oslopolicy-convert-json-to-yaml`__ tool will migrate your existing
|
||||||
|
JSON-formatted policy file to YAML in a backward-compatible way.
|
||||||
|
|
||||||
|
.. __: https://docs.openstack.org/oslo.policy/latest/cli/oslopolicy-convert-json-to-yaml.html
|
||||||
|
|
||||||
The following is an overview of all available policies in Placement.
|
The following is an overview of all available policies in Placement.
|
||||||
For a sample configuration file, refer to
|
For a sample configuration file, refer to
|
||||||
:doc:`/configuration/sample-policy`.
|
:doc:`/configuration/sample-policy`.
|
||||||
|
|
|
@ -2,6 +2,14 @@
|
||||||
Sample Placement Policy File
|
Sample Placement Policy File
|
||||||
============================
|
============================
|
||||||
|
|
||||||
|
.. warning::
|
||||||
|
|
||||||
|
JSON formatted policy file is deprecated since Placement 5.0.0 (Wallaby).
|
||||||
|
The `oslopolicy-convert-json-to-yaml`__ tool will migrate your existing
|
||||||
|
JSON-formatted policy file to YAML in a backward-compatible way.
|
||||||
|
|
||||||
|
.. __: https://docs.openstack.org/oslo.policy/latest/cli/oslopolicy-convert-json-to-yaml.html
|
||||||
|
|
||||||
The following is a sample placement policy file for adaptation and use.
|
The following is a sample placement policy file for adaptation and use.
|
||||||
|
|
||||||
The sample policy can also be viewed in :download:`file form
|
The sample policy can also be viewed in :download:`file form
|
||||||
|
|
|
@ -36,16 +36,16 @@ os-service-types==1.2.0
|
||||||
os-traits==2.4.0
|
os-traits==2.4.0
|
||||||
oslo.concurrency==3.26.0
|
oslo.concurrency==3.26.0
|
||||||
oslo.config==6.7.0
|
oslo.config==6.7.0
|
||||||
oslo.context==2.21.0
|
oslo.context==2.22.0
|
||||||
oslo.db==4.40.0
|
oslo.db==4.40.0
|
||||||
oslo.i18n==3.20.0
|
oslo.i18n==3.20.0
|
||||||
oslo.log==4.3.0
|
oslo.log==4.3.0
|
||||||
oslo.middleware==3.31.0
|
oslo.middleware==3.31.0
|
||||||
oslo.policy==1.35.0
|
oslo.policy==3.6.0
|
||||||
oslo.serialization==2.25.0
|
oslo.serialization==2.25.0
|
||||||
oslo.upgradecheck==0.2.0
|
oslo.upgradecheck==1.3.0
|
||||||
oslo.utils==3.37.0
|
oslo.utils==4.5.0
|
||||||
oslotest==3.4.0
|
oslotest==3.5.0
|
||||||
osprofiler==1.4.0
|
osprofiler==1.4.0
|
||||||
pbr==3.1.1
|
pbr==3.1.1
|
||||||
pep8==1.5.7
|
pep8==1.5.7
|
||||||
|
@ -64,7 +64,7 @@ python-keystoneclient==3.15.0
|
||||||
python-mimeparse==1.6.0
|
python-mimeparse==1.6.0
|
||||||
python-subunit==1.2.0
|
python-subunit==1.2.0
|
||||||
pytz==2018.3
|
pytz==2018.3
|
||||||
PyYAML==3.13
|
PyYAML==5.1
|
||||||
repoze.lru==0.7
|
repoze.lru==0.7
|
||||||
requests==2.25.0
|
requests==2.25.0
|
||||||
requestsexceptions==1.4.0
|
requestsexceptions==1.4.0
|
||||||
|
|
|
@ -14,6 +14,7 @@ import sqlalchemy as sa
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
from oslo_upgradecheck import common_checks
|
||||||
from oslo_upgradecheck import upgradecheck
|
from oslo_upgradecheck import upgradecheck
|
||||||
|
|
||||||
from placement import conf
|
from placement import conf
|
||||||
|
@ -105,6 +106,8 @@ class Checks(upgradecheck.UpgradeCommands):
|
||||||
_upgrade_checks = (
|
_upgrade_checks = (
|
||||||
('Missing Root Provider IDs', _check_root_provider_ids),
|
('Missing Root Provider IDs', _check_root_provider_ids),
|
||||||
('Incomplete Consumers', _check_incomplete_consumers),
|
('Incomplete Consumers', _check_incomplete_consumers),
|
||||||
|
("Policy File JSON to YAML Migration",
|
||||||
|
(common_checks.check_policy_json, {'conf': cfg.CONF})),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
from oslo_policy import opts as policy_opts
|
||||||
|
|
||||||
base_options = [
|
base_options = [
|
||||||
cfg.StrOpt(
|
cfg.StrOpt(
|
||||||
|
@ -24,6 +25,19 @@ base_options = [
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def set_lib_defaults():
|
||||||
|
"""Update default value for configuration options from other namespace.
|
||||||
|
|
||||||
|
Example, oslo lib config options. This is needed for
|
||||||
|
config generator tool to pick these default value changes.
|
||||||
|
https://docs.openstack.org/oslo.config/latest/cli/
|
||||||
|
generator.html#modifying-defaults-from-other-namespaces
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Update default value of oslo.policy policy_file config option.
|
||||||
|
policy_opts.set_defaults(cfg.CONF, 'policy.yaml')
|
||||||
|
|
||||||
|
|
||||||
def register_opts(conf):
|
def register_opts(conf):
|
||||||
conf.register_opts(base_options)
|
conf.register_opts(base_options)
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,10 @@ def get_enforcer():
|
||||||
# files from overrides on disk and defaults in code. We can just pass an
|
# files from overrides on disk and defaults in code. We can just pass an
|
||||||
# empty list and let oslo do the config lifting for us.
|
# empty list and let oslo do the config lifting for us.
|
||||||
cfg.CONF([], project='placement')
|
cfg.CONF([], project='placement')
|
||||||
policy_opts.set_defaults(cfg.CONF)
|
# 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
|
||||||
|
policy_opts.set_defaults(cfg.CONF, 'policy.yaml')
|
||||||
return _get_enforcer(cfg.CONF)
|
return _get_enforcer(cfg.CONF)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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.
|
|
@ -12,14 +12,14 @@ requests>=2.25.0 # Apache-2.0
|
||||||
setuptools!=24.0.0,!=34.0.0,!=34.0.1,!=34.0.2,!=34.0.3,!=34.1.0,!=34.1.1,!=34.2.0,!=34.3.0,!=34.3.1,!=34.3.2,!=36.2.0,>=21.0.0 # PSF/ZPL
|
setuptools!=24.0.0,!=34.0.0,!=34.0.1,!=34.0.2,!=34.0.3,!=34.1.0,!=34.1.1,!=34.2.0,!=34.3.0,!=34.3.1,!=34.3.2,!=36.2.0,>=21.0.0 # PSF/ZPL
|
||||||
oslo.concurrency>=3.26.0 # Apache-2.0
|
oslo.concurrency>=3.26.0 # Apache-2.0
|
||||||
oslo.config>=6.7.0 # Apache-2.0
|
oslo.config>=6.7.0 # Apache-2.0
|
||||||
oslo.context>=2.21.0 # Apache-2.0
|
oslo.context>=2.22.0 # Apache-2.0
|
||||||
oslo.log>=4.3.0 # Apache-2.0
|
oslo.log>=4.3.0 # Apache-2.0
|
||||||
oslo.serialization>=2.25.0 # Apache-2.0
|
oslo.serialization>=2.25.0 # Apache-2.0
|
||||||
oslo.utils>=3.37.0 # Apache-2.0
|
oslo.utils>=4.5.0 # Apache-2.0
|
||||||
oslo.db>=4.40.0 # Apache-2.0
|
oslo.db>=4.40.0 # Apache-2.0
|
||||||
oslo.policy>=1.35.0 # Apache-2.0
|
oslo.policy>=3.6.0 # Apache-2.0
|
||||||
oslo.middleware>=3.31.0 # Apache-2.0
|
oslo.middleware>=3.31.0 # Apache-2.0
|
||||||
oslo.upgradecheck>=0.2.0 # Apache-2.0
|
oslo.upgradecheck>=1.3.0 # Apache-2.0
|
||||||
# NOTE(efried): Sync lower-constraints.txt for os-traits & os-resource-classes.
|
# NOTE(efried): Sync lower-constraints.txt for os-traits & os-resource-classes.
|
||||||
os-resource-classes>=0.5.0 # Apache-2.0
|
os-resource-classes>=0.5.0 # Apache-2.0
|
||||||
os-traits>=2.4.0 # Apache-2.0
|
os-traits>=2.4.0 # Apache-2.0
|
||||||
|
|
|
@ -36,6 +36,9 @@ packages =
|
||||||
oslo.config.opts =
|
oslo.config.opts =
|
||||||
placement.conf = placement.conf.opts:list_opts
|
placement.conf = placement.conf.opts:list_opts
|
||||||
|
|
||||||
|
oslo.config.opts.defaults =
|
||||||
|
nova.conf = placement.conf.base:set_lib_defaults
|
||||||
|
|
||||||
oslo.policy.enforcer =
|
oslo.policy.enforcer =
|
||||||
placement = placement.policy:get_enforcer
|
placement = placement.policy:get_enforcer
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ fixtures>=3.0.0 # Apache-2.0/BSD
|
||||||
# don't use it here to keep the consistency with global requirements.
|
# don't use it here to keep the consistency with global requirements.
|
||||||
psycopg2>=2.8 # LGPL/ZPL
|
psycopg2>=2.8 # LGPL/ZPL
|
||||||
PyMySQL>=0.8.0 # MIT License
|
PyMySQL>=0.8.0 # MIT License
|
||||||
oslotest>=3.4.0 # Apache-2.0
|
oslotest>=3.5.0 # Apache-2.0
|
||||||
stestr>=1.0.0 # Apache-2.0
|
stestr>=1.0.0 # Apache-2.0
|
||||||
testtools>=2.2.0 # MIT
|
testtools>=2.2.0 # MIT
|
||||||
bandit>=1.1.0 # Apache-2.0
|
bandit>=1.1.0 # Apache-2.0
|
||||||
|
|
Loading…
Reference in New Issue