diff options
Diffstat (limited to 'geo-replication/syncdaemon')
-rw-r--r-- | geo-replication/syncdaemon/gsyncd.py | 2 | ||||
-rw-r--r-- | geo-replication/syncdaemon/gsyncdconfig.py | 2 | ||||
-rw-r--r-- | geo-replication/syncdaemon/gsyncdstatus.py | 13 | ||||
-rw-r--r-- | geo-replication/syncdaemon/subcmds.py | 13 |
4 files changed, 26 insertions, 4 deletions
diff --git a/geo-replication/syncdaemon/gsyncd.py b/geo-replication/syncdaemon/gsyncd.py index fbab5cbf386..f58b532bcda 100644 --- a/geo-replication/syncdaemon/gsyncd.py +++ b/geo-replication/syncdaemon/gsyncd.py @@ -129,6 +129,7 @@ def main(): p.add_argument("-c", "--config-file", help="Config File") p.add_argument("--local-path", help="Local Brick Path") p.add_argument("--debug", action="store_true") + p.add_argument("--json", action="store_true") # Config-check p = sp.add_parser("config-check") @@ -146,6 +147,7 @@ def main(): p.add_argument("--show-defaults", action="store_true") p.add_argument("--only-value", action="store_true") p.add_argument("--use-underscore", action="store_true") + p.add_argument("--json", action="store_true") # Config-set p = sp.add_parser("config-set") diff --git a/geo-replication/syncdaemon/gsyncdconfig.py b/geo-replication/syncdaemon/gsyncdconfig.py index 5aa354b8e6a..a5843801671 100644 --- a/geo-replication/syncdaemon/gsyncdconfig.py +++ b/geo-replication/syncdaemon/gsyncdconfig.py @@ -329,7 +329,7 @@ def to_float(value): def to_bool(value): - return True if value == "true" else False + return True if value in ["true", "True"] else False def get(name, default_value=None): diff --git a/geo-replication/syncdaemon/gsyncdstatus.py b/geo-replication/syncdaemon/gsyncdstatus.py index 38ca92c73a9..1df24330438 100644 --- a/geo-replication/syncdaemon/gsyncdstatus.py +++ b/geo-replication/syncdaemon/gsyncdstatus.py @@ -399,6 +399,15 @@ class GeorepStatus(object): return data - def print_status(self, checkpoint_time=0): - for key, value in self.get_status(checkpoint_time).items(): + def print_status(self, checkpoint_time=0, json_output=False): + status_out = self.get_status(checkpoint_time) + if json_output: + out = {} + # Convert all values as string + for k, v in status_out.items(): + out[k] = str(v) + print json.dumps(out) + return + + for key, value in status_out.items(): print ("%s: %s" % (key, value)) 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) |