oslopolicy-convert-json-to-yaml

Synopsis

oslopolicy-convert-json-to-yaml [-h] [--config-dir DIR] [--config-file PATH]
                                [--namespace NAMESPACE]
                                [--policy-file POLICY_FILE]
                                [--output-file OUTPUT_FILE]

Description

The oslopolicy-convert-json-to-yaml tool can be used to convert the JSON format policy file to YAML format. It takes JSON formatted policy file as input and convert it to a YAML formatted policy file similar to oslopolicy-sample-generator tool except keeping the overridden rule as uncommented. It does the following:

  • Comment out any rules that match the default from policy-in-code.

  • Keep rules uncommented if rule is overridden.

  • Does not auto add the deprecated rules in the file unless it not already present in the file.

  • Keep any extra rules or already exist deprecated rules uncommented but at the end of the file with a warning text.

When to use:

Oslo policy still support the policy file in JSON format, but that lead to multiple issues . One of the key issue came up while nova switched to the new policy with new defaults and scope feature from keystone. Refer this bug for details.

In future release, oslo policy will remove the JSON formatted policy file support and to have a smooth migration to YAML formatted policy file you can use this tool to convert your existing JSON formatted file to YAML file.

Options

-h, --help

Show help message and exit.

--config-dir DIR

Path to a config directory to pull *.conf files from. This file set is sorted, so as to provide a predictable parse order if individual options are overridden. The set is parsed after the file(s) specified via previous --config-file, arguments hence overridden options in the directory take precedence.

This option must be set from the command-line.

--config-file PATH

Path to a config file to use. Multiple config files can be specified, with values in later files taking precedence. Defaults to None. This option must be set from the command-line.

--output-file OUTPUT_FILE

Path of the file to write to. Defaults to stdout.

--exclude-deprecated True

Option allowing the rendered output to be generated without deprecated policy information.

--namespace NAMESPACE

Option namespace(s) under “oslo.policy.policies” in which to query for options.

--policy-file POLICY_FILE

Path to the policy file which need to be converted to yaml format.

Examples

To convert a JSON policy file for a namespace called keystone:

oslopolicy-convert-json-to-yaml --namespace keystone \
  --policy-file keystone-policy.json

To convert a JSON policy file to yaml format directly to a file:

oslopolicy-convert-json-to-yaml --namespace keystone \
  --policy-file keystone-policy.json \
  --output-file keystone-policy.yaml

Use the following to generate help text for additional options and arguments supported by oslopolicy-convert-json-to-yaml:

oslopolicy-convert-json-to-yaml --help

See Also

oslopolicy-sample-generator, oslopolicy-policy-generator, oslopolicy-upgrade