From: Douglas Bagnall Date: Thu, 7 Jun 2018 02:27:52 +0000 (+1200) Subject: samba-tool drs show_repl: simplify the collection of DC lists X-Git-Tag: tevent-0.9.37~206 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3a1b710eacc38c868e4b09848e751fdb5733cd98;p=thirdparty%2Fsamba.git samba-tool drs show_repl: simplify the collection of DC lists Signed-off-by: Douglas Bagnall Reviewed-by: Andrew Bartlett --- diff --git a/python/samba/netcmd/drs.py b/python/samba/netcmd/drs.py index 613f56c8a4f..1999c1e130d 100644 --- a/python/samba/netcmd/drs.py +++ b/python/samba/netcmd/drs.py @@ -18,7 +18,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # - import samba.getopt as options import ldb import logging @@ -147,9 +146,7 @@ class cmd_drs_showrepl(Command): self.message("\t\tLast success @ %s" % d['last success']) self.message("") - def drsuapi_ReplicaInfo(self, info_type): - '''call a DsReplicaInfo''' - + def get_neighbours(self, info_type): req1 = drsuapi.DsReplicaGetInfoRequest1() req1.info_type = info_type try: @@ -157,7 +154,9 @@ class cmd_drs_showrepl(Command): self.drsuapi_handle, 1, req1) except Exception as e: raise CommandError("DsReplicaGetInfo of type %u failed" % info_type, e) - return (info_type, info) + + reps = [self.parse_neighbour(n) for n in info.array] + return reps def run(self, DC=None, sambaopts=None, credopts=None, versionopts=None, @@ -240,12 +239,8 @@ class cmd_drs_showrepl(Command): } conn = self.samdb.search(base=ntds_dn, expression="(objectClass=nTDSConnection)") - info = self.drsuapi_ReplicaInfo( - drsuapi.DRSUAPI_DS_REPLICA_INFO_NEIGHBORS)[1] - repsfrom = [self.parse_neighbour(n) for n in info.array] - info = self.drsuapi_ReplicaInfo( - drsuapi.DRSUAPI_DS_REPLICA_INFO_REPSTO)[1] - repsto = [self.parse_neighbour(n) for n in info.array] + repsfrom = self.get_neighbours(drsuapi.DRSUAPI_DS_REPLICA_INFO_NEIGHBORS) + repsto = self.get_neighbours(drsuapi.DRSUAPI_DS_REPLICA_INFO_REPSTO) conn_details = [] for c in conn: