mirror of
https://github.com/samba-team/samba.git
synced 2025-01-26 10:04:02 +03:00
samba-tool drs showrepl: add --pull-summary and --notify-summary
These separate the two halves of --summary (which is still there), allowing the repsto and repsfrom to be separately queried. One motivation for this is testing: it is difficult to assert the success of repsfrom (--notify-summary) in the test framework, because we can't rely on the other end behaving properly and promptly. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
This commit is contained in:
parent
5fcd374602
commit
2c9eeedc84
@ -100,8 +100,17 @@ class cmd_drs_showrepl(Command):
|
|||||||
takes_options = [
|
takes_options = [
|
||||||
Option("--json", help="replication details in JSON format",
|
Option("--json", help="replication details in JSON format",
|
||||||
dest='format', action='store_const', const='json'),
|
dest='format', action='store_const', const='json'),
|
||||||
Option("--summary", help="summarize local DRS health",
|
Option("--summary", help=("summarize overall DRS health as seen "
|
||||||
|
"from this server"),
|
||||||
dest='format', action='store_const', const='summary'),
|
dest='format', action='store_const', const='summary'),
|
||||||
|
Option("--pull-summary", help=("Have we successfully replicated "
|
||||||
|
"from all relevent servers?"),
|
||||||
|
dest='format', action='store_const', const='pull_summary'),
|
||||||
|
Option("--notify-summary", action='store_const',
|
||||||
|
const='notify_summary', dest='format',
|
||||||
|
help=("Have we successfully notified all relevent servers of "
|
||||||
|
"local changes, and did they say they successfully "
|
||||||
|
"replicated?")),
|
||||||
Option("--classic", help="print local replication details",
|
Option("--classic", help="print local replication details",
|
||||||
dest='format', action='store_const', const='classic',
|
dest='format', action='store_const', const='classic',
|
||||||
default=DEFAULT_SHOWREPL_FORMAT),
|
default=DEFAULT_SHOWREPL_FORMAT),
|
||||||
@ -184,6 +193,8 @@ class cmd_drs_showrepl(Command):
|
|||||||
|
|
||||||
output_function = {
|
output_function = {
|
||||||
'summary': self.summary_output,
|
'summary': self.summary_output,
|
||||||
|
'notify_summary': self.notify_summary_output,
|
||||||
|
'pull_summary': self.pull_summary_output,
|
||||||
'json': self.json_output,
|
'json': self.json_output,
|
||||||
'classic': self.classic_output,
|
'classic': self.classic_output,
|
||||||
}.get(format)
|
}.get(format)
|
||||||
@ -198,24 +209,27 @@ class cmd_drs_showrepl(Command):
|
|||||||
del data['server']
|
del data['server']
|
||||||
json.dump(data, self.outf, indent=2)
|
json.dump(data, self.outf, indent=2)
|
||||||
|
|
||||||
def summary_output(self):
|
def summary_output_handler(self, typeof_output):
|
||||||
"""Print a short message if every seems fine, but print details of any
|
"""Print a short message if every seems fine, but print details of any
|
||||||
links that seem broken."""
|
links that seem broken."""
|
||||||
failing_repsto = []
|
failing_repsto = []
|
||||||
failing_repsfrom = []
|
failing_repsfrom = []
|
||||||
|
|
||||||
local_data = self.get_local_repl_data()
|
local_data = self.get_local_repl_data()
|
||||||
for rep in local_data['repsTo']:
|
|
||||||
if rep['is deleted']:
|
|
||||||
continue
|
|
||||||
if rep["consecutive failures"] != 0 or rep["last success"] == 0:
|
|
||||||
failing_repsto.append(rep)
|
|
||||||
|
|
||||||
for rep in local_data['repsFrom']:
|
if typeof_output != "pull_summary":
|
||||||
if rep['is deleted']:
|
for rep in local_data['repsTo']:
|
||||||
continue
|
if rep['is deleted']:
|
||||||
if rep["consecutive failures"] != 0 or rep["last success"] == 0:
|
continue
|
||||||
failing_repsto.append(rep)
|
if rep["consecutive failures"] != 0 or rep["last success"] == 0:
|
||||||
|
failing_repsto.append(rep)
|
||||||
|
|
||||||
|
if typeof_output != "notify_summary":
|
||||||
|
for rep in local_data['repsFrom']:
|
||||||
|
if rep['is deleted']:
|
||||||
|
continue
|
||||||
|
if rep["consecutive failures"] != 0 or rep["last success"] == 0:
|
||||||
|
failing_repsto.append(rep)
|
||||||
|
|
||||||
if failing_repsto or failing_repsfrom:
|
if failing_repsto or failing_repsfrom:
|
||||||
self.message(colour.c_RED("There are failing connections"))
|
self.message(colour.c_RED("There are failing connections"))
|
||||||
@ -233,6 +247,15 @@ class cmd_drs_showrepl(Command):
|
|||||||
self.message(colour.c_GREEN("[ALL GOOD]"))
|
self.message(colour.c_GREEN("[ALL GOOD]"))
|
||||||
|
|
||||||
|
|
||||||
|
def summary_output(self):
|
||||||
|
return self.summary_output_handler("summary")
|
||||||
|
|
||||||
|
def notify_summary_output(self):
|
||||||
|
return self.summary_output_handler("notify_summary")
|
||||||
|
|
||||||
|
def pull_summary_output(self):
|
||||||
|
return self.summary_output_handler("pull_summary")
|
||||||
|
|
||||||
def get_local_repl_data(self):
|
def get_local_repl_data(self):
|
||||||
drsuapi_connect(self)
|
drsuapi_connect(self)
|
||||||
samdb_connect(self)
|
samdb_connect(self)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user