mirror of
https://github.com/samba-team/samba.git
synced 2025-01-08 21:18:16 +03:00
KCC: add an option to list the graph verification options
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
parent
d474bfa3c3
commit
7c39344767
@ -2376,6 +2376,8 @@ class KCCGraphError(Exception):
|
||||
pass
|
||||
|
||||
def verify_graph_fully_connected(edges, vertices, edge_vertices):
|
||||
"""The graph is complete, which is to say there is an edge between
|
||||
every pair of nodes."""
|
||||
for v in vertices:
|
||||
remotes = set()
|
||||
for a, b in edges:
|
||||
@ -2388,6 +2390,7 @@ def verify_graph_fully_connected(edges, vertices, edge_vertices):
|
||||
|
||||
|
||||
def verify_graph_connected(edges, vertices, edge_vertices):
|
||||
"""There is a path between any two nodes."""
|
||||
if not edges:
|
||||
if len(vertices) <= 1:
|
||||
return
|
||||
@ -2418,6 +2421,8 @@ def verify_graph_connected(edges, vertices, edge_vertices):
|
||||
|
||||
|
||||
def verify_graph_forest(edges, vertices, edge_vertices):
|
||||
"""The graph contains no loops. A forest that is also connected is a
|
||||
tree."""
|
||||
trees = [set(e) for e in edges]
|
||||
while True:
|
||||
for a, b in itertools.combinations(trees, 2):
|
||||
@ -2467,12 +2472,14 @@ def verify_graph_multi_edge_forest(edges, vertices, edge_vertices):
|
||||
|
||||
|
||||
def verify_graph_no_lonely_vertices(edges, vertices, edge_vertices):
|
||||
"""There are no vertices without edges."""
|
||||
lonely = vertices - edge_vertices
|
||||
if lonely:
|
||||
raise KCCGraphError("some vertices are not connected:\n%s" % '\n'.join(sorted(lonely)))
|
||||
|
||||
|
||||
def verify_graph_no_unknown_vertices(edges, vertices, edge_vertices):
|
||||
"""The edge endpoints contain no vertices that are otherwise unknown."""
|
||||
unknown = edge_vertices - vertices
|
||||
if unknown:
|
||||
raise KCCGraphError("some edge vertices are seemingly unknown:\n%s" % '\n'.join(sorted(unknown)))
|
||||
@ -2534,3 +2541,12 @@ def verify_and_dot(basename, edges, vertices=None, label=None, destdir=None,
|
||||
if dot_files:
|
||||
write_dot_file(basename, edges, vertices=vertices, label=label, destdir=destdir,
|
||||
reformat_labels=reformat_labels, directed=directed)
|
||||
|
||||
def list_verify_tests():
|
||||
for k, v in sorted(globals().items()):
|
||||
if k.startswith('verify_graph_'):
|
||||
print k.replace('verify_graph_', '')
|
||||
if v.__doc__:
|
||||
print ' %s%s%s' %(GREY, v.__doc__, C_NORMAL)
|
||||
else:
|
||||
print
|
||||
|
@ -3080,6 +3080,10 @@ parser.add_option("--verify",
|
||||
help="verify that assorted invariants are kept",
|
||||
action="store_true")
|
||||
|
||||
parser.add_option("--list-verify-tests",
|
||||
help="list what verification actions are available and do nothing else",
|
||||
action="store_true")
|
||||
|
||||
parser.add_option("--no-dot-files", dest='dot_files',
|
||||
help="Don't write dot graph files in /tmp",
|
||||
default=True, action="store_false")
|
||||
@ -3133,8 +3137,9 @@ creds = credopts.get_credentials(lp, fallback_machine=True)
|
||||
|
||||
opts, args = parser.parse_args()
|
||||
|
||||
if opts.readonly is None:
|
||||
opts.readonly = False
|
||||
if opts.list_verify_tests:
|
||||
list_verify_tests()
|
||||
sys.exit(0)
|
||||
|
||||
if opts.debug:
|
||||
logger.setLevel(logging.DEBUG)
|
||||
|
Loading…
Reference in New Issue
Block a user