[PATCH] samba-tool drs showrepl --summary

Andrew Bartlett abartlet at samba.org
Sun Jun 10 19:09:07 UTC 2018


On Sun, 2018-06-10 at 13:56 +0200, Andrew Bartlett wrote:
> On Sun, 2018-06-10 at 06:41 +0200, Andrew Bartlett via samba-technical
> wrote:
> > On Sun, 2018-06-10 at 09:08 +1200, Douglas Bagnall via samba-technical
> > wrote:
> > > A while ago I added a --json option to make `samba-tool drs showrepl`
> > > produce machine readable output. This time I'm aiming for *human*
> > > readable output with a --summary option. It differs from what is now
> > > called --classic (still the default) in that it doesn't go on and on
> > > describing things that are perfectly normal. When it finds a problem
> > > it reverts to verbosity in the classic style.
> > > 
> > > A typical conversation with it should look like this:
> > > 
> > >   $ samba-tool drs showrepl --summary $DC $CREDS
> > >   [ALL GOOD]
> > >   $
> > > 
> > > Soon I'll have a patch for `samba-tool drs showrepl --global` which
> > > looks around the network and tries to verify that it is in good
> > > health.
> > > 
> > > cheers,
> > 
> > Thanks Douglas,
> > 
> > In time we should make this the default, it is much more useful.
> > 
> > Reviewed-by: Andrew Bartlett <abartlet at samba.org>
> > 
> > pushed to autobuild
> 
> The tests for --summary failed, so I've tried without those.  I'll mail
> you the full output directly.

I have a fix for this, see attached.  Essentially we need to ignore
deleted DSAs.  These only show up in the full test environment. 

CI: https://gitlab.com/catalyst-samba/samba/pipelines/23590669

Please review and push if the CI indicates

> Also, if you could make it use self.runsubcmd() to call directly into
> the samba-tool code rather than re-exec()ig python etc that would be
> good.

I've not done this bit yet and this is no different to the other code
here so there may be a reason.

Thanks,

Andrew Bartlett
-- 
Andrew Bartlett                       http://samba.org/~abartlet/
Authentication Developer, Samba Team  http://samba.org
Samba Developer, Catalyst IT          http://catalyst.net.nz/services/samba
-------------- next part --------------
From b989bb93a6efdcd75843e77fe95e34c3e6dcc32b Mon Sep 17 00:00:00 2001
From: Andrew Bartlett <abartlet at samba.org>
Date: Sun, 10 Jun 2018 21:03:47 +0200
Subject: [PATCH] samba-tool drs showrepl: Skip deleted DSAs when checking for
 success

The deleted DSAs are ignored by the server replication code, so ignore past failures
here also.

The repsFrom and repsTo entries will eventually be removed by the KCC.

Signed-off-by: Andrew Bartlett <abartlet at samba.org>
---
 python/samba/netcmd/drs.py | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/python/samba/netcmd/drs.py b/python/samba/netcmd/drs.py
index 83cfac8694a..9a6c4b8a6ea 100644
--- a/python/samba/netcmd/drs.py
+++ b/python/samba/netcmd/drs.py
@@ -193,10 +193,14 @@ class cmd_drs_showrepl(Command):
 
         local_data = self.get_local_repl_data()
         for rep in local_data['repsTo']:
+            if "is deleted" in rep:
+                continue
             if rep["consecutive failures"] != 0 or rep["last success"] == 0:
                 failing_repsto.append(rep)
 
         for rep in local_data['repsFrom']:
+            if "is deleted" in rep:
+                continue
             if rep["consecutive failures"] != 0 or rep["last success"] == 0:
                 failing_repsto.append(rep)
 
@@ -274,6 +278,32 @@ class cmd_drs_showrepl(Command):
                 a = str(r).split(':')
                 d['replicates NC'].append((a[3], int(a[2])))
 
+        for rep in repsfrom:
+            dsa_objectguid = rep["DSA objectGUID"]
+            try:
+                self.samdb.search(base="<GUID=%s>" % dsa_objectguid,
+                                  scope=ldb.SCOPE_BASE,
+                                  attrs=[])
+            except ldb.LdbError as e:
+                (errno, _) = e.args
+                if errno == ldb.ERR_NO_SUCH_OBJECT:
+                    d['is deleted'] = True
+                else:
+                    raise
+
+        for rep in repsto:
+            dsa_objectguid = rep["DSA objectGUID"]
+            try:
+                self.samdb.search(base="<GUID=%s>" % dsa_objectguid,
+                                  scope=ldb.SCOPE_BASE,
+                                  attrs=[])
+            except ldb.LdbError as e:
+                (errno, _) = e.args
+                if errno == ldb.ERR_NO_SUCH_OBJECT:
+                    d['is deleted'] = True
+                else:
+                    raise
+
         return {
             'dsa': dsa_details,
             'repsFrom': repsfrom,
-- 
2.14.4



More information about the samba-technical mailing list