Merge "Remove duplicate policy file format check"
This commit is contained in:
@@ -84,32 +84,8 @@ class Checks(upgradecheck.UpgradeCommands):
|
||||
return upgradecheck.Result(upgradecheck.Code.SUCCESS,
|
||||
_('AmphoraV2 provider is not enabled.'))
|
||||
|
||||
def _check_yaml_policy(self):
|
||||
if CONF.oslo_policy.policy_file.lower().endswith('yaml'):
|
||||
return upgradecheck.Result(upgradecheck.Code.SUCCESS,
|
||||
_('The [oslo_policy] policy_file '
|
||||
'setting is configured for YAML '
|
||||
'policy file format.'))
|
||||
if CONF.oslo_policy.policy_file.lower().endswith('json'):
|
||||
return upgradecheck.Result(
|
||||
upgradecheck.Code.WARNING,
|
||||
_('The [oslo_policy] policy_file setting is configured for '
|
||||
'JSON policy file format. JSON format policy files have '
|
||||
'been deprecated by oslo policy. Please use the oslo policy '
|
||||
'tool to convert your policy file to YAML format. See this '
|
||||
'patch for more information: '
|
||||
'https://review.opendev.org/733650'))
|
||||
return upgradecheck.Result(upgradecheck.Code.FAILURE,
|
||||
_('Unable to determine the [oslo_policy] '
|
||||
'policy_file setting file format. '
|
||||
'Please make sure your policy file is '
|
||||
'in YAML format and has the suffix of '
|
||||
'.yaml for the filename. Oslo policy '
|
||||
'has deprecated the JSON file format.'))
|
||||
|
||||
_upgrade_checks = (
|
||||
(_('AmphoraV2 Check'), _check_amphorav2),
|
||||
(_('YAML Policy File'), _check_yaml_policy),
|
||||
(_('Policy File JSON to YAML Migration'),
|
||||
(common_checks.check_policy_json, {'conf': CONF})),
|
||||
)
|
||||
|
@@ -19,7 +19,6 @@ from oslo_upgradecheck.upgradecheck import Code
|
||||
|
||||
from octavia.cmd import status
|
||||
from octavia.common import constants
|
||||
from octavia.common import policy
|
||||
from octavia.tests.unit import base
|
||||
|
||||
|
||||
@@ -125,20 +124,3 @@ class TestUpgradeChecks(base.TestCase):
|
||||
check_result = self.cmd._check_amphorav2()
|
||||
self.assertEqual(
|
||||
Code.FAILURE, check_result.code)
|
||||
|
||||
def test__check_yaml_policy(self):
|
||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||
self.conf.conf(args=[], project='octavia')
|
||||
policy.Policy()
|
||||
|
||||
self.conf.config(group='oslo_policy', policy_file='test.yaml')
|
||||
check_result = self.cmd._check_yaml_policy()
|
||||
self.assertEqual(Code.SUCCESS, check_result.code)
|
||||
|
||||
self.conf.config(group='oslo_policy', policy_file='test.json')
|
||||
check_result = self.cmd._check_yaml_policy()
|
||||
self.assertEqual(Code.WARNING, check_result.code)
|
||||
|
||||
self.conf.config(group='oslo_policy', policy_file='test')
|
||||
check_result = self.cmd._check_yaml_policy()
|
||||
self.assertEqual(Code.FAILURE, check_result.code)
|
||||
|
Reference in New Issue
Block a user