diff options
| author | Petr Viktorin <pviktori@redhat.com> | 2013-12-12 10:19:56 +0100 |
|---|---|---|
| committer | Petr Viktorin <pviktori@redhat.com> | 2014-03-05 10:00:58 +0100 |
| commit | 87a36db6bcb701048228402887ed0c97c6fee70e (patch) | |
| tree | 58b0b86e83b2af35fb91fb9e1a5417d3a063d4a5 /ipatests/ipa-test-config | |
| parent | 2150481f2aa9615c7ae89af8501831a37be9d660 (diff) | |
| download | freeipa-87a36db6bcb701048228402887ed0c97c6fee70e.tar.gz freeipa-87a36db6bcb701048228402887ed0c97c6fee70e.tar.xz freeipa-87a36db6bcb701048228402887ed0c97c6fee70e.zip | |
ipa-test-config: Add --json and --yaml output options
Also update the man page.
Part of the work for: https://fedorahosted.org/freeipa/ticket/3938
Reviewed-By: Tomas Babej <tbabej@redhat.com>
Diffstat (limited to 'ipatests/ipa-test-config')
| -rwxr-xr-x | ipatests/ipa-test-config | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/ipatests/ipa-test-config b/ipatests/ipa-test-config index 75e5f6c08..dc94b8afb 100755 --- a/ipatests/ipa-test-config +++ b/ipatests/ipa-test-config @@ -22,6 +22,7 @@ import sys import os import argparse +import json from ipalib.constants import FQDN from ipatests.test_integration import config @@ -59,6 +60,14 @@ def main(argv): help='Do not print Simple Vars ' '(normally included backwards-compatibility)') + parser.add_argument('--yaml', action='store_const', dest='output_format', + const='yaml', + help='Output configuration in YAML format') + + parser.add_argument('--json', action='store_const', dest='output_format', + const='json', + help='Output configuration in JSON format') + args = parser.parse_args(argv) hostsargs = [bool(args.host), bool(args.master), bool(args.replica), @@ -77,7 +86,13 @@ def main(argv): conf = config.Config.from_env(os.environ) - return config.env_to_script(get_object(conf, args).to_env(**kwargs)) + if args.output_format == 'json': + return json.dumps(conf.to_dict(), indent=2) + elif args.output_format == 'yaml': + import yaml + return yaml.safe_dump(conf.to_dict(), default_flow_style=False) + else: + return config.env_to_script(get_object(conf, args).to_env(**kwargs)) def get_object(conf, args): |
