diff --git a/lower-constraints.txt b/lower-constraints.txt index 071c7ea6582d64e291bce733fdb4160abfcecf04..c30a9678f8c6a08492789df0811a95f369ae0eb0 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -6,3 +6,4 @@ oslotest==3.5.0 stestr==2.0.0 oslo.serialization==2.21.1 oslo.utils==4.5.0 +oslo.policy==2.0.0 diff --git a/oslo_upgradecheck/common_checks.py b/oslo_upgradecheck/common_checks.py index 1881980e77194f6055a4bee5c65051f9d88e5359..6085070fe2016028ec08df806b93d11ba36d0d08 100644 --- a/oslo_upgradecheck/common_checks.py +++ b/oslo_upgradecheck/common_checks.py @@ -10,6 +10,7 @@ # License for the specific language governing permissions and limitations # under the License. +from oslo_policy import opts as policy_opts from oslo_utils import fileutils from oslo_upgradecheck import upgradecheck @@ -21,6 +22,13 @@ Common checks which can be used by multiple services. def check_policy_json(self, conf): "Checks to see if policy file is JSON-formatted policy file." + + # NOTE(gmann): This method need [oslo_policy].policy_file + # config value so register those options in case they + # are not register by services. + conf.register_opts(policy_opts._options, + group=policy_opts._option_group) + msg = ("Your policy file is JSON-formatted which is " "deprecated. You need to switch to YAML-formatted file. " "Use the ``oslopolicy-convert-json-to-yaml`` " diff --git a/oslo_upgradecheck/tests/test_common_checks.py b/oslo_upgradecheck/tests/test_common_checks.py index c5c54a2719133a68c8831a3f5b10ec068378f042..da9ec24b0737a9a2b637bce08e1e16fbd8555dc3 100644 --- a/oslo_upgradecheck/tests/test_common_checks.py +++ b/oslo_upgradecheck/tests/test_common_checks.py @@ -17,6 +17,7 @@ import yaml from oslo_config import cfg from oslo_config import fixture as config +from oslo_policy import opts as policy_opts from oslo_serialization import jsonutils from oslotest import base @@ -31,10 +32,8 @@ class TestUpgradeCheckPolicyJSON(base.BaseTestCase): conf_fixture = self.useFixture(config.Config()) conf_fixture.load_raw_values() self.conf = conf_fixture.conf - policy_file_opt = cfg.StrOpt('policy_file', - default='policy.json', - help='policy file') - self.conf.register_opt(policy_file_opt, group="oslo_policy") + self.conf.register_opts(policy_opts._options, + group=policy_opts._option_group) self.cmd = upgradecheck.UpgradeCommands() self.cmd._upgrade_checks = (('Policy File JSON to YAML Migration', diff --git a/requirements.txt b/requirements.txt index 4b136972d9ef35a9fe553d8864682dc9431dfe5b..2f5f0247a8751b620173bb5bc7f398b10d3342a3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,3 +6,4 @@ oslo.config>=5.2.0 # Apache-2.0 oslo.i18n>=3.15.3 # Apache-2.0 PrettyTable<0.8,>=0.7.1 # BSD oslo.utils>=4.5.0 # Apache-2.0 +oslo.policy>=2.0.0 # Apache-2.0