summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>2018-02-08 15:52:01 +1300
committerAndrew Bartlett <abartlet@samba.org>2018-02-15 00:18:29 +0100
commited15a452e7db6d76e231e5fbd45fa236c57a87f3 (patch)
treeefa144d1bc9e0f12e58f1fd5b3283e189363a227 /python
parent90d0c638ef1817337a58babd0c02be5c9c4611c6 (diff)
downloadsamba-ed15a452e7db6d76e231e5fbd45fa236c57a87f3.tar.gz
samba-tool drs showrepl: add --json option for JSON output
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'python')
-rw-r--r--python/samba/netcmd/drs.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/python/samba/netcmd/drs.py b/python/samba/netcmd/drs.py
index dc86f2e1fd9..a45b9062827 100644
--- a/python/samba/netcmd/drs.py
+++ b/python/samba/netcmd/drs.py
@@ -95,6 +95,10 @@ class cmd_drs_showrepl(Command):
"credopts": options.CredentialsOptions,
}
+ takes_options = [
+ Option("--json", help="output in JSON format", action='store_true'),
+ ]
+
takes_args = ["DC?"]
def parse_neighbour(self, n):
@@ -144,7 +148,7 @@ class cmd_drs_showrepl(Command):
return (info_type, info)
def run(self, DC=None, sambaopts=None,
- credopts=None, versionopts=None, server=None):
+ credopts=None, versionopts=None, server=None, json=False):
self.lp = sambaopts.get_loadparm()
if DC is None:
@@ -209,6 +213,17 @@ class cmd_drs_showrepl(Command):
a = str(r).split(':')
d['replicates NC'].append((a[3], int(a[2])))
+ if json:
+ import json as json_mod
+ data = {
+ 'dsa': dsa_details,
+ 'repsFrom': repsfrom,
+ 'repsTo': repsto,
+ 'NTDSConnections': conn_details
+ }
+ json_mod.dump(data, self.outf, indent=2)
+ return
+
self.message("%s\\%s" % (site, server))
self.message("DSA Options: 0x%08x" % dsa_details["options"])
self.message("DSA object GUID: %s" % dsa_details["objectGUID"])