diff options
author | Aravinda VK <avishwan@redhat.com> | 2017-11-23 15:28:07 +0530 |
---|---|---|
committer | Aravinda VK <avishwan@redhat.com> | 2017-11-24 13:59:24 +0000 |
commit | d395387f601c9fb57a5fd9f19385b4de3c870de8 (patch) | |
tree | 522bc9fc7bdecddb90ce84deab5103745ca2b7b4 /geo-replication/syncdaemon/subcmds.py | |
parent | cd27e0ffb8afd69c1df28c38808c49a3af8cc75d (diff) |
geo-rep: JSON output for status and config
For Glusterd2 integration, JSON output of status and config
is very useful from gsyncd
Fixes: #361
Change-Id: I53c61f19033ad4ac601ea49469e4e7c7c8e9af3d
Signed-off-by: Aravinda VK <avishwan@redhat.com>
Diffstat (limited to 'geo-replication/syncdaemon/subcmds.py')
-rw-r--r-- | geo-replication/syncdaemon/subcmds.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/geo-replication/syncdaemon/subcmds.py b/geo-replication/syncdaemon/subcmds.py index 8ce5f219b6a..691c84401c5 100644 --- a/geo-replication/syncdaemon/subcmds.py +++ b/geo-replication/syncdaemon/subcmds.py @@ -32,7 +32,8 @@ def subcmd_status(args): slave_data, gconf.get("pid-file")) checkpoint_time = gconf.get("checkpoint", 0) - brick_status.print_status(checkpoint_time=checkpoint_time) + brick_status.print_status(checkpoint_time=checkpoint_time, + json_output=args.json) def subcmd_monitor(args): @@ -232,6 +233,7 @@ def config_name_format(val): def subcmd_config_get(args): import sys + import json all_config = gconf.getall(show_defaults=args.show_defaults, show_non_configurable=True) @@ -245,6 +247,15 @@ def subcmd_config_get(args): use_underscore=args.use_underscore) return + if args.json: + out = {} + # Convert all values as string + for k, v in all_config.items(): + out[k] = str(v) + + print(json.dumps(out)) + return + for k in sorted(all_config): print_config(k, all_config[k], use_underscore=args.use_underscore) |