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 | |
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>
-rwxr-xr-x | ipatests/ipa-test-config | 17 | ||||
-rw-r--r-- | ipatests/man/ipa-test-config.1 | 25 |
2 files changed, 40 insertions, 2 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): diff --git a/ipatests/man/ipa-test-config.1 b/ipatests/man/ipa-test-config.1 index 317bd40d8..320d1fe1f 100644 --- a/ipatests/man/ipa-test-config.1 +++ b/ipatests/man/ipa-test-config.1 @@ -30,7 +30,7 @@ The FreeIPA integration test suite is configured by setting environment variables. The ipa\-run\-tests command reads these variables and prints detailed configuration for shell-based scripts to standard output. -The output of ipa\-run\-tests consists of export statements that can be +The default output of ipa\-run\-tests consists of export statements that can be sourced by Bash. If run without arguments, it prints out configuration specific to the local @@ -68,10 +68,33 @@ Output configuration for the host with the given role. \fB\-\-no\-simple\fR Do not output Simple Vars. These are normally included for backwards compatibility. +.TP +\fB\-\-yaml\fR +Output configuration in YAML format instead of Bash script. +This requires the PyYAML library to be installed. +.TP +\fB\-\-json\fR +Output configuration in JSON format instead of Bash script. .SH "ENVIRONMENT VARIABLES" .TP +File\-based configuration: + +.TP +\fB$IPATEST_YAML_CONFIG\fR + Specifies a file that contains configuration in YAML format, + as given by \fBipa\-test\-config \-\-global \-\-yaml\fR. + If given, the other environment variables are ignored. + This requires the PyYAML library to be installed. + +.TP +\fB$IPATEST_JSON_CONFIG\fR + Specifies a file that contains configuration in JSON format, + as given by \fBipa\-test\-config \-\-global \-\-json\fR. + If given, the other environment variables are ignored. + +.TP Domain configuration: Domain is implicitly defined by _envX suffix of the environment variables, if either AD_envX or MASTER_envX is defined. |