Can add and remove bw accounting without reboots.
authorFaiyaz Ahmed <faiyaza@cs.princeton.edu>
Fri, 30 Jan 2009 23:50:47 +0000 (23:50 +0000)
committerFaiyaz Ahmed <faiyaza@cs.princeton.edu>
Fri, 30 Jan 2009 23:50:47 +0000 (23:50 +0000)
bwmon.py
net.py
nm.py

index 6f5c90e..8a9e96f 100644 (file)
--- a/bwmon.py
+++ b/bwmon.py
@@ -685,8 +685,10 @@ def run():
         nmdbcopy = copy.deepcopy(database.db)
         database.db_lock.release()
         try:  
         nmdbcopy = copy.deepcopy(database.db)
         database.db_lock.release()
         try:  
-            if getDefaults(nmdbcopy): sync(nmdbcopy)
-            else: logger.log("bwmon:  DISABLED.")
+            if getDefaults(nmdbcopy) and len(bwlimit.tc("class show dev eth0")) > 0:
+                # class show to check if net:InitNodeLimit:bwlimit.init has run.
+                sync(nmdbcopy)
+            else: logger.log("bwmon:  BW limits DISABLED.")
         except: logger.log_exc()
         lock.clear()
 
         except: logger.log_exc()
         lock.clear()
 
diff --git a/net.py b/net.py
index ba48959..1c34b2b 100644 (file)
--- a/net.py
+++ b/net.py
@@ -14,12 +14,17 @@ import sioc, plnet
 import bwlimit, logger, iptables
 
 def GetSlivers(plc, data, config):
 import bwlimit, logger, iptables
 
 def GetSlivers(plc, data, config):
+    logger.verbose("net:GetSlivers called.")
     InitInterfaces(plc, data) # writes sysconfig files.
     InitInterfaces(plc, data) # writes sysconfig files.
-    if ('OVERRIDES' in dir(config)) and (config.OVERRIDES.get('net_max_rate') == -1):
-        logger.log("Slice and node BW Limits disabled.")
-        if len(bwlimit.get()): 
-            logger.verbose("*** DISABLING NODE BW LIMITS ***")
-            bwlimit.stop()
+    if 'OVERRIDES' in dir(config): 
+        if config.OVERRIDES.get('net_max_rate') == '-1':
+            logger.log("net: Slice and node BW Limits disabled.")
+            if len(bwlimit.tc("class show dev eth0")): 
+                logger.verbose("*** DISABLING NODE BW LIMITS ***")
+                bwlimit.stop()
+        else:
+            InitNodeLimit(data)
+            InitI2(plc, data)
     else:
         InitNodeLimit(data)
         InitI2(plc, data)
     else:
         InitNodeLimit(data)
         InitI2(plc, data)
diff --git a/nm.py b/nm.py
index 78c7bfa..744ba76 100755 (executable)
--- a/nm.py
+++ b/nm.py
@@ -84,7 +84,8 @@ def getPLCDefaults(data, config):
             if len(attr_dict):
                 logger.verbose("Found default slice overrides.\n %s" % attr_dict)
                 config.OVERRIDES = attr_dict
             if len(attr_dict):
                 logger.verbose("Found default slice overrides.\n %s" % attr_dict)
                 config.OVERRIDES = attr_dict
-            elif 'OVERRIDES' in dir(config): del config.OVERRIDES
+            return 
+    if 'OVERRIDES' in dir(config): del config.OVERRIDES
 
 
 def run():
 
 
 def run():