KCC: Help RW DCs to ignore RODCs when doing kcc
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Fri, 27 Mar 2015 05:08:53 +0000 (18:08 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 29 May 2015 09:08:21 +0000 (11:08 +0200)
As far as writable DCs are concerned, RODCs don't even exist. So we make
tables that leave out the RO ones.

An RODC needs to know itself as well as writable DCs, so we add it in
that case.

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>
python/samba/kcc_utils.py
source4/scripting/bin/samba_kcc

index 426a826c7612f99357b38e1e5b2c1fca19d4747b..bc1c92af26b6f601e3c2a7b8185b494b6e7d69b5 100644 (file)
@@ -1391,6 +1391,7 @@ class Site(object):
         self.site_topo_generator = None
         self.site_topo_failover = 0  # appears to be in minutes
         self.dsa_table = {}
+        self.rw_dsa_table = {}
         self.unix_now = unix_now
 
     def load_site(self, samdb):
@@ -1454,8 +1455,11 @@ class Site(object):
             # Assign this dsa to my dsa table
             # and index by dsa dn
             self.dsa_table[dnstr] = dsa
+            if not dsa.is_ro():
+                self.rw_dsa_table[dnstr] = dsa
 
-    def get_dsa_by_guidstr(self, guidstr):
+
+    def get_dsa_by_guidstr(self, guidstr): #XXX unused
         for dsa in self.dsa_table.values():
             if str(dsa.dsa_guid) == guidstr:
                 return dsa
@@ -1506,7 +1510,7 @@ class Site(object):
         # Which is a fancy way of saying "sort all the nTDSDSA objects
         # in the site by guid in ascending order".   Place sorted list
         # in D_sort[]
-        D_sort = sorted(self.dsa_table.values(), cmp=sort_dsa_by_guid)
+        D_sort = sorted(self.rw_dsa_table.values(), cmp=sort_dsa_by_guid)
 
         ntnow = unix2nttime(self.unix_now) # double word number of 100 nanosecond
                                            # intervals since 1600s
index b627a3916172983430afe97dc2d2fa29eb348d53..0a5268fca353f139f526337d0fccc29056f6fd49 100755 (executable)
@@ -245,6 +245,16 @@ class KCC(object):
 
         self.my_dsa = self.my_site.get_dsa(self.my_dsa_dnstr)
 
+        if self.my_dsa_dnstr not in self.dsa_by_dnstr:
+            DEBUG_DARK_YELLOW("my_dsa %s isn't in self.dsas_by_dnstr: it must be RODC."
+                              "Let's add it, because my_dsa is a special case!\n"
+                              "(likewise for self.dsa_by_guid of course)" %
+                              self.my_dsas_dnstr)
+
+            self.dsa_by_dnstr[self.my_dsa_dnstr] = self.my_dsa
+            self.dsa_by_guid[str(self.my_dsa.dsa_guid)] = self.my_dsa
+
+
     def load_all_partitions(self):
         """Discover all NCs thru the Partitions dn and
         instantiate and load the NCs.
@@ -1142,8 +1152,8 @@ class KCC(object):
             DEBUG_RED("get_all_bridgeheads with %s, part%s, partial_ok %s"
                       " detect_failed %s" % (site.site_dnstr, part.partstr,
                                              partial_ok, detect_failed))
-        logger.debug(site.dsa_table)
-        for key, dsa in site.dsa_table.items():
+        logger.debug(site.rw_dsa_table)
+        for dsa in site.rw_dsa_table.values():
 
             pdnstr = dsa.get_parent_dnstr()