Add ``oslopolicy-convert-json-to-yaml`` tool which can be used to convert the json formatted 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. This tool 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. I did not add the new functionality in existing 'oslopolicy-policy-upgrade' tool because the above listed features of new tool end up creating a complete different code path instead of reusing it from existing tool so it better to have separate tool which can be removed in future once all deployments are migrated to YAML formatted file. This commits add doc and reno also for this tool Partial implement blueprint policy-json-to-yaml Change-Id: Icc245951b2992cc09a891516ffd14f3d4c009920
2.6 KiB
oslopolicy-convert-json-to-yaml
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
Examples
To convert a JSON policy file for a namespace called
keystone:
oslopolicy-convert-json-to-yaml --namespace keystone \
--policy-file keystone-policy.jsonTo 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.yamlUse the following to generate help text for additional options and
arguments supported by oslopolicy-convert-json-to-yaml:
oslopolicy-convert-json-to-yaml --helpSee Also
oslopolicy-sample-generator, oslopolicy-policy-generator, oslopolicy-upgrade