mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
kcc: Remove DN translation for Site GUID
Signed-off-by: Garming Sam <garming@catalyst.net.nz> Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
parent
99d4efc917
commit
d583913337
@ -1439,11 +1439,12 @@ class Site(object):
|
|||||||
ssdn = "CN=NTDS Site Settings,%s" % self.site_dnstr
|
ssdn = "CN=NTDS Site Settings,%s" % self.site_dnstr
|
||||||
attrs = ["options",
|
attrs = ["options",
|
||||||
"interSiteTopologyFailover",
|
"interSiteTopologyFailover",
|
||||||
"interSiteTopologyGenerator",
|
"interSiteTopologyGenerator"]
|
||||||
"objectGUID"]
|
|
||||||
try:
|
try:
|
||||||
res = samdb.search(base=ssdn, scope=ldb.SCOPE_BASE,
|
res = samdb.search(base=ssdn, scope=ldb.SCOPE_BASE,
|
||||||
attrs=attrs)
|
attrs=attrs)
|
||||||
|
self_res = samdb.search(base=self.site_dnstr, scope=ldb.SCOPE_BASE,
|
||||||
|
attrs=['objectGUID'])
|
||||||
except ldb.LdbError, (enum, estr):
|
except ldb.LdbError, (enum, estr):
|
||||||
raise Exception("Unable to find site settings for (%s) - (%s)" %
|
raise Exception("Unable to find site settings for (%s) - (%s)" %
|
||||||
(ssdn, estr))
|
(ssdn, estr))
|
||||||
@ -1458,6 +1459,7 @@ class Site(object):
|
|||||||
if "interSiteTopologyFailover" in msg:
|
if "interSiteTopologyFailover" in msg:
|
||||||
self.site_topo_failover = int(msg["interSiteTopologyFailover"][0])
|
self.site_topo_failover = int(msg["interSiteTopologyFailover"][0])
|
||||||
|
|
||||||
|
msg = self_res[0]
|
||||||
if "objectGUID" in msg:
|
if "objectGUID" in msg:
|
||||||
self.site_guid = misc.GUID(samdb.schema_format_value("objectGUID",
|
self.site_guid = misc.GUID(samdb.schema_format_value("objectGUID",
|
||||||
msg["objectGUID"][0]))
|
msg["objectGUID"][0]))
|
||||||
@ -2131,7 +2133,7 @@ class SiteLink(object):
|
|||||||
"siteList" ]
|
"siteList" ]
|
||||||
try:
|
try:
|
||||||
res = samdb.search(base=self.dnstr, scope=ldb.SCOPE_BASE,
|
res = samdb.search(base=self.dnstr, scope=ldb.SCOPE_BASE,
|
||||||
attrs=attrs)
|
attrs=attrs, controls=['extended_dn:0'])
|
||||||
|
|
||||||
except ldb.LdbError, (enum, estr):
|
except ldb.LdbError, (enum, estr):
|
||||||
raise Exception("Unable to find SiteLink for (%s) - (%s)" %
|
raise Exception("Unable to find SiteLink for (%s) - (%s)" %
|
||||||
@ -2154,9 +2156,9 @@ class SiteLink(object):
|
|||||||
if "siteList" in msg:
|
if "siteList" in msg:
|
||||||
for value in msg["siteList"]:
|
for value in msg["siteList"]:
|
||||||
dsdn = dsdb_Dn(samdb, value)
|
dsdn = dsdb_Dn(samdb, value)
|
||||||
dnstr = str(dsdn.dn)
|
guid = misc.GUID(dsdn.dn.get_extended_component('GUID'))
|
||||||
if dnstr not in self.site_list:
|
if guid not in self.site_list:
|
||||||
self.site_list.append(dnstr)
|
self.site_list.append(guid)
|
||||||
|
|
||||||
def is_sitelink(self, site1_dnstr, site2_dnstr):
|
def is_sitelink(self, site1_dnstr, site2_dnstr):
|
||||||
"""Given a siteLink object, determine if it is a link
|
"""Given a siteLink object, determine if it is a link
|
||||||
|
@ -75,8 +75,6 @@ class KCC(object):
|
|||||||
self.kcc_failed_links = {}
|
self.kcc_failed_links = {}
|
||||||
self.kcc_failed_connections = set()
|
self.kcc_failed_connections = set()
|
||||||
|
|
||||||
self.site_dn_to_guid = {}
|
|
||||||
|
|
||||||
# Used in inter-site topology computation. A list
|
# Used in inter-site topology computation. A list
|
||||||
# of connections (by NTDSConnection object) that are
|
# of connections (by NTDSConnection object) that are
|
||||||
# to be kept when pruning un-needed NTDS Connections
|
# to be kept when pruning un-needed NTDS Connections
|
||||||
@ -163,8 +161,6 @@ class KCC(object):
|
|||||||
self.my_site_guid = site.site_guid
|
self.my_site_guid = site.site_guid
|
||||||
self.my_site = site
|
self.my_site = site
|
||||||
|
|
||||||
self.site_dn_to_guid[self.my_site_dnstr.lower()] = str(self.my_site_guid)
|
|
||||||
|
|
||||||
def load_all_sites(self):
|
def load_all_sites(self):
|
||||||
"""Discover all sites and instantiate and load each
|
"""Discover all sites and instantiate and load each
|
||||||
NTDS Site settings.
|
NTDS Site settings.
|
||||||
@ -191,8 +187,6 @@ class KCC(object):
|
|||||||
|
|
||||||
self.site_table[str(site.site_guid)] = site
|
self.site_table[str(site.site_guid)] = site
|
||||||
|
|
||||||
self.site_dn_to_guid[sitestr.lower()] = str(site.site_guid)
|
|
||||||
|
|
||||||
def load_my_dsa(self):
|
def load_my_dsa(self):
|
||||||
"""Discover my nTDSDSA dn thru the rootDSE entry
|
"""Discover my nTDSDSA dn thru the rootDSE entry
|
||||||
|
|
||||||
@ -1029,8 +1023,7 @@ class KCC(object):
|
|||||||
for transport_guid, transport in self.transport_table.items():
|
for transport_guid, transport in self.transport_table.items():
|
||||||
# Currently only ever "IP"
|
# Currently only ever "IP"
|
||||||
for site_link_dn, site_link in self.sitelink_table.items():
|
for site_link_dn, site_link in self.sitelink_table.items():
|
||||||
new_edge = create_edge(transport_guid, site_link, guid_to_vertex,
|
new_edge = create_edge(transport_guid, site_link, guid_to_vertex)
|
||||||
self.site_dn_to_guid)
|
|
||||||
connected_vertices.update(new_edge.vertices)
|
connected_vertices.update(new_edge.vertices)
|
||||||
g.edges.add(new_edge)
|
g.edges.add(new_edge)
|
||||||
|
|
||||||
@ -2617,16 +2610,13 @@ def write_search_result(samdb, f, res):
|
|||||||
lstr = samdb.write_ldif(msg, ldb.CHANGETYPE_NONE)
|
lstr = samdb.write_ldif(msg, ldb.CHANGETYPE_NONE)
|
||||||
f.write("%s" % lstr)
|
f.write("%s" % lstr)
|
||||||
|
|
||||||
def create_edge(con_type, site_link, guid_to_vertex, site_dn_to_guid):
|
def create_edge(con_type, site_link, guid_to_vertex):
|
||||||
e = MultiEdge()
|
e = MultiEdge()
|
||||||
e.site_link = site_link
|
e.site_link = site_link
|
||||||
e.vertices = []
|
e.vertices = []
|
||||||
for site_dn in site_link.site_list:
|
for site_guid in site_link.site_list:
|
||||||
site_guid = site_dn_to_guid.get(site_dn.lower())
|
if str(site_guid) in guid_to_vertex:
|
||||||
if site_guid is None:
|
e.vertices.extend(guid_to_vertex.get(str(site_guid)))
|
||||||
continue
|
|
||||||
if site_guid in guid_to_vertex:
|
|
||||||
e.vertices.extend(guid_to_vertex.get(site_guid))
|
|
||||||
e.repl_info.cost = site_link.cost
|
e.repl_info.cost = site_link.cost
|
||||||
e.repl_info.options = site_link.options
|
e.repl_info.options = site_link.options
|
||||||
e.repl_info.interval = site_link.interval
|
e.repl_info.interval = site_link.interval
|
||||||
|
Loading…
Reference in New Issue
Block a user