def run(self, H=None, output=None, shorten_names=False, key=True, talk_to_remote=False, sambaopts=None, credopts=None, versionopts=None, color=None, color_scheme=None, utf8=False, format=None, importldif=None, xdot=False, partition=None, max_digits=3): if not talk_to_remote: print( "this won't work without talking to the remote servers " "(use -r)", file=self.outf) return # We use the KCC libraries in readonly mode to get the # replication graph. lp = sambaopts.get_loadparm() creds = credopts.get_credentials(lp, fallback_machine=True) local_kcc, dsas = self.get_kcc_and_dsas(H, lp, creds) self.samdb = local_kcc.samdb partition = get_partition(self.samdb, partition) short_partitions, long_partitions = get_partition_maps(self.samdb) color_scheme = self.calc_distance_color_scheme(color, color_scheme, output) for part_name, part_dn in short_partitions.items(): if partition not in (part_dn, None): continue # we aren't doing this partition cursors = self.get_utdv(self.samdb, part_dn) # we talk to each remote and make a matrix of the vectors # -- for each partition # normalise by oldest utdv_edges = {} for dsa_dn in dsas: res = local_kcc.samdb.search(dsa_dn, scope=SCOPE_BASE, attrs=["dNSHostName"]) ldap_url = "ldap://%s" % res[0]["dNSHostName"][0] try: samdb = self.get_db(ldap_url, sambaopts, credopts) cursors = self.get_utdv(samdb, part_dn) own_usn, own_time = self.get_own_cursor(samdb) remotes = {dsa_dn: own_usn} for dn, guid, usn, t in cursors: remotes[dn] = usn except LdbError as e: print("Could not contact %s (%s)" % (ldap_url, e), file=sys.stderr) continue utdv_edges[dsa_dn] = remotes distances = {} max_distance = 0 for dn1 in dsas: try: peak = utdv_edges[dn1][dn1] except KeyError as e: peak = 0 d = {} distances[dn1] = d for dn2 in dsas: if dn2 in utdv_edges: if dn1 in utdv_edges[dn2]: dist = peak - utdv_edges[dn2][dn1] d[dn2] = dist if dist > max_distance: max_distance = dist else: print("Missing dn %s from UTD vector" % dn1, file=sys.stderr) else: print("missing dn %s from UTD vector list" % dn2, file=sys.stderr) digits = min(max_digits, len(str(max_distance))) if digits < 1: digits = 1 c_scale = 10**digits s = full_matrix(distances, utf8=utf8, colour=color_scheme, shorten_names=shorten_names, generate_key=key, grouping_function=get_dnstr_site, colour_scale=c_scale, digits=digits, ylabel='DC', xlabel='out-of-date-ness') self.write('\n%s\n\n%s' % (part_name, s), output)
def run(self, H=None, output=None, shorten_names=False, key=True, talk_to_remote=False, sambaopts=None, credopts=None, versionopts=None, color=None, color_scheme=None, utf8=False, format=None, importldif=None, xdot=False, partition=None, max_digits=3): if not talk_to_remote: print("this won't work without talking to the remote servers " "(use -r)", file=self.outf) return # We use the KCC libraries in readonly mode to get the # replication graph. lp = sambaopts.get_loadparm() creds = credopts.get_credentials(lp, fallback_machine=True) local_kcc, dsas = self.get_kcc_and_dsas(H, lp, creds) self.samdb = local_kcc.samdb partition = get_partition(self.samdb, partition) short_partitions, long_partitions = get_partition_maps(self.samdb) color_scheme = self.calc_distance_color_scheme(color, color_scheme, output) for part_name, part_dn in short_partitions.items(): if partition not in (part_dn, None): continue # we aren't doing this partition cursors = self.get_utdv(self.samdb, part_dn) # we talk to each remote and make a matrix of the vectors # -- for each partition # normalise by oldest utdv_edges = {} for dsa_dn in dsas: res = local_kcc.samdb.search(dsa_dn, scope=SCOPE_BASE, attrs=["dNSHostName"]) ldap_url = "ldap://%s" % res[0]["dNSHostName"][0] try: samdb = self.get_db(ldap_url, sambaopts, credopts) cursors = self.get_utdv(samdb, part_dn) own_usn, own_time = self.get_own_cursor(samdb) remotes = {dsa_dn: own_usn} for dn, guid, usn, t in cursors: remotes[dn] = usn except LdbError as e: print("Could not contact %s (%s)" % (ldap_url, e), file=sys.stderr) continue utdv_edges[dsa_dn] = remotes distances = {} max_distance = 0 for dn1 in dsas: try: peak = utdv_edges[dn1][dn1] except KeyError as e: peak = 0 d = {} distances[dn1] = d for dn2 in dsas: if dn2 in utdv_edges: if dn1 in utdv_edges[dn2]: dist = peak - utdv_edges[dn2][dn1] d[dn2] = dist if dist > max_distance: max_distance = dist else: print("Missing dn %s from UTD vector" % dn1, file=sys.stderr) else: print("missing dn %s from UTD vector list" % dn2, file=sys.stderr) digits = min(max_digits, len(str(max_distance))) if digits < 1: digits = 1 c_scale = 10 ** digits s = full_matrix(distances, utf8=utf8, colour=color_scheme, shorten_names=shorten_names, generate_key=key, grouping_function=get_dnstr_site, colour_scale=c_scale, digits=digits, ylabel='DC', xlabel='out-of-date-ness') self.write('\n%s\n\n%s' % (part_name, s), output)
def run(self, H=None, output=None, shorten_names=False, key=True, talk_to_remote=False, sambaopts=None, credopts=None, versionopts=None, color=None, color_scheme=None, utf8=False, format=None, importldif=None, xdot=False, partition=None, max_digits=3): if not talk_to_remote: print( "this won't work without talking to the remote servers " "(use -r)", file=self.outf) return # We use the KCC libraries in readonly mode to get the # replication graph. lp = sambaopts.get_loadparm() creds = credopts.get_credentials(lp, fallback_machine=True) local_kcc, dsas = get_kcc_and_dsas(H, lp, creds) self.samdb = local_kcc.samdb partition = get_partition(self.samdb, partition) short_partitions, long_partitions = get_partition_maps(self.samdb) color_scheme = self.calc_distance_color_scheme(color, color_scheme, output) for part_name, part_dn in short_partitions.items(): if partition not in (part_dn, None): continue # we aren't doing this partition utdv_edges = get_utdv_edges(local_kcc, dsas, part_dn, lp, creds) distances = get_utdv_distances(utdv_edges, dsas) max_distance = get_utdv_max_distance(distances) digits = min(max_digits, len(str(max_distance))) if digits < 1: digits = 1 c_scale = 10**digits s = full_matrix(distances, utf8=utf8, colour=color_scheme, shorten_names=shorten_names, generate_key=key, grouping_function=get_dnstr_site, colour_scale=c_scale, digits=digits, ylabel='DC', xlabel='out-of-date-ness') self.write('\n%s\n\n%s' % (part_name, s), output)