def _check_policy_json(self): "Checks to see if policy file is JSON-formatted policy file." msg = _("Your policy file is JSON-formatted which is " "deprecated since Victoria release (Nova 22.0.0). " "You need to switch to YAML-formatted file. You can use the " "``oslopolicy-convert-json-to-yaml`` tool to convert existing " "JSON-formatted files to YAML-formatted files in a " "backwards-compatible manner: " "https://docs.openstack.org/oslo.policy/" "latest/cli/oslopolicy-convert-json-to-yaml.html.") status = upgradecheck.Result(upgradecheck.Code.SUCCESS) # Check if policy file exist and is JSON-formatted. policy_path = CONF.find_file(CONF.oslo_policy.policy_file) if policy_path and fileutils.is_json(policy_path): status = upgradecheck.Result(upgradecheck.Code.FAILURE, msg) return status
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`` " "tool to convert the existing JSON-formatted files to " "YAML in a backwards-compatible manner: " "https://docs.openstack.org/oslo.policy/" "latest/cli/oslopolicy-convert-json-to-yaml.html.") status = upgradecheck.Result(upgradecheck.Code.SUCCESS) # Check if policy file exist and is JSON-formatted. policy_path = conf.find_file(conf.oslo_policy.policy_file) if policy_path and fileutils.is_json(policy_path): status = upgradecheck.Result(upgradecheck.Code.FAILURE, msg) return status
def test_is_json(self): self.assertTrue(fileutils.is_json(self.json_file)) self.assertFalse(fileutils.is_json(self.yaml_file))