mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
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>
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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,9 +68,32 @@ 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,
|
||||
|
||||
Reference in New Issue
Block a user