Bump build. 1.5-4.
[nodemanager.git] / nm.py
diff --git a/nm.py b/nm.py
index c4760fc..a7f1f70 100644 (file)
--- a/nm.py
+++ b/nm.py
@@ -1,5 +1,7 @@
 #!/usr/bin/python
 
+# $Id: $
+
 """Node Manager"""
 
 import optparse
@@ -15,7 +17,8 @@ import tools
 
 from config import Config
 from plcapi import PLCAPI 
-
+import random
+import net
 
 savedargv = sys.argv[:]
 
@@ -31,13 +34,15 @@ modules = []
 
 def GetSlivers(plc):
     data = plc.GetSlivers()
-    # net needs access to API for i2 nodes.
+    # Set i2 ip list for nodes in I2 nodegroup.
+    try: net.GetSlivers(plc, data)
+    except: logger.log_exc()
+    #  All other callback modules
     for module in modules:
-        if module.__name__ == 'net':
-            module.GetSlivers(plc, data)
-        else:
+        try:        
             callback = getattr(module, 'GetSlivers')
             callback(data)
+        except: logger.log_exc()
 
 def run():
     try:
@@ -55,7 +60,7 @@ def run():
             print "Warning while writing PID file:", err
 
         # Load and start modules
-        for module in ['net', 'proper', 'conf_files', 'sm', 'bwmon']:
+        for module in ['proper', 'conf_files', 'sm', 'bwmon']:
             try:
                 m = __import__(module)
                 m.start(options, config)
@@ -73,9 +78,9 @@ def run():
         plc = PLCAPI(config.plc_api_uri, config.cacert, session, timeout=options.period/2)
 
         while True:
-            try: GetSlivers(plc)
-            except: logger.log_exc()
-            time.sleep(options.period)
+        # Main NM Loop
+            GetSlivers(plc)
+            time.sleep(options.period + random.randrange(0,301))
     except: logger.log_exc()