KCC: shift ReplInfo, MAX_DWORD from kcc.kcc_utils to kcc.graph
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Mon, 4 May 2015 23:12:30 +0000 (11:12 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 12 Jun 2015 04:57:15 +0000 (06:57 +0200)
They are only used in graph.py.

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/graph.py
python/samba/kcc/kcc_utils.py

index 9b7a11541ba3de2bed93825f73fa4d8b890c9c7f..95c2c057dc929a923c5914e4cc17d0211ab407bc 100644 (file)
@@ -28,8 +28,35 @@ from samba.dcerpc import misc
 
 from samba.kcc.debug import DEBUG, DEBUG_FN
 
-from samba.kcc.kcc_utils import MAX_DWORD
-from samba.kcc.kcc_utils import ReplInfo, total_schedule
+MAX_DWORD = 2 ** 32 - 1
+
+
+class ReplInfo(object):
+    def __init__(self):
+        self.cost = 0
+        self.interval = 0
+        self.options = 0
+        self.schedule = None
+
+
+def total_schedule(schedule):
+    """Return the total number of 15 minute windows in which the schedule
+    is set to replicate in a week. If the schedule is None it is
+    assumed that the replication will happen in every 15 minute
+    window.
+
+    This is essentially a bit population count.
+    """
+
+    if schedule is None:
+        return 84 * 8  # 84 bytes = 84 * 8 bits
+
+    total = 0
+    for byte in schedule:
+        while byte != 0:
+            total += byte & 1
+            byte >>= 1
+    return total
 
 
 def convert_schedule_to_repltimes(schedule):
index fa8659f0b853dc3b8f685a3531d4d0c33142bb7a..684459b03352575f44f615993754ee24a4cebdb8 100644 (file)
@@ -2111,19 +2111,9 @@ class KCCFailedObject(object):
         self.dns_name = dns_name
 
 
-class ReplInfo(object):
-    def __init__(self):
-        self.cost = 0
-        self.interval = 0
-        self.options = 0
-        self.schedule = None
-
-
 ##################################################
 # Global Functions and Variables
 ##################################################
-MAX_DWORD = 2 ** 32 - 1
-
 
 def get_dsa_config_rep(dsa):
     # Find configuration NC replica for the DSA
@@ -2140,18 +2130,6 @@ def sort_dsa_by_guid(dsa1, dsa2):
     return cmp(ndr_pack(dsa1.dsa_guid), ndr_pack(dsa2.dsa_guid))
 
 
-def total_schedule(schedule):
-    if schedule is None:
-        return 84 * 8  # 84 bytes = 84 * 8 bits
-
-    total = 0
-    for byte in schedule:
-        while byte != 0:
-            total += byte & 1
-            byte >>= 1
-    return total
-
-
 def new_connection_schedule():
     """Create a default schedule for an NTDSConnection or Sitelink. This
     is packed differently from the repltimes schedule used elsewhere