]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
KCC: helper function to find config NC replica for a DSA
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Fri, 6 Mar 2015 02:17:24 +0000 (15:17 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 28 May 2015 05:25:09 +0000 (07:25 +0200)
This logic is going to be used elsewhere (for dot debugging).

Also add a dedicated KCC Exception class.

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

index fd1c478fcc3012ce29859842e88b1fe6dcd7a31f..6072fa5eedffac5b3a37d5fb9308c0772f27a927 100644 (file)
@@ -29,6 +29,8 @@ from samba.dcerpc import (
 from samba.common import dsdb_Dn
 from samba.ndr import (ndr_unpack, ndr_pack)
 
+class KCCError(Exception):
+    pass
 
 class NCType(object):
     (unknown, schema, domain, config, application) = range(0, 5)
@@ -1487,14 +1489,7 @@ class Site(object):
             mydsa.dsa_is_istg = True
             return True
 
-        # Find configuration NC replica for my DSA
-        for c_rep in mydsa.current_rep_table.values():
-            if c_rep.is_config():
-                break
-
-        if not c_rep.is_config():
-            raise Exception("Unable to find config NC replica for (%s)" %
-                            mydsa.dsa_dnstr)
+        c_rep = get_dsa_config_rep(mydsa)
 
         # Load repsFrom and replUpToDateVector if not already loaded so we can get the current
         # state of the config replica and whether we are getting updates
@@ -2277,6 +2272,16 @@ class InternalEdge(object):
 ##################################################
 MAX_DWORD = 2 ** 32 - 1
 
+def get_dsa_config_rep(dsa):
+    # Find configuration NC replica for the DSA
+    for c_rep in dsa.current_rep_table.values():
+        if c_rep.is_config():
+            return c_rep
+
+    raise KCCError("Unable to find config NC replica for (%s)" %
+                   dsa.dsa_dnstr)
+
+
 def sort_dsa_by_guid(dsa1, dsa2):
     return cmp(dsa1.dsa_guid, dsa2.dsa_guid)