Merge from head.
[nodemanager.git] / nm.py
diff --git a/nm.py b/nm.py
index 1df65be..f951765 100644 (file)
--- a/nm.py
+++ b/nm.py
@@ -15,7 +15,8 @@ import tools
 
 from config import Config
 from plcapi import PLCAPI 
-
+import random
+import net
 
 savedargv = sys.argv[:]
 
@@ -31,13 +32,9 @@ modules = []
 
 def GetSlivers(plc):
     data = plc.GetSlivers()
-    # net needs access to API for i2 nodes.
     for module in modules:
-        if module.__name__ == 'net':
-            module.GetSlivers(plc, data)
-        else:
-            callback = getattr(module, 'GetSlivers')
-            callback(data)
+        callback = getattr(module, 'GetSlivers')
+        callback(data)
 
 def run():
     try:
@@ -55,7 +52,7 @@ def run():
             print "Warning while writing PID file:", err
 
         # Load and start modules
-        for module in ['net', 'proper', 'conf_files', 'sm']:
+        for module in ['proper', 'conf_files', 'sm', 'bwmon']:
             try:
                 m = __import__(module)
                 m.start(options, config)
@@ -73,6 +70,10 @@ def run():
         plc = PLCAPI(config.plc_api_uri, config.cacert, session, timeout=options.period/2)
 
         while True:
+                       # Set i2 ip list for nodes in I2 nodegroup.
+            try: net.GetSlivers(plc, data)
+            except: logger.log_exc()
+                       # Main NM Loop
             try: GetSlivers(plc)
             except: logger.log_exc()
             time.sleep(options.period + random.randrange(0,301))