oops, too much messing about
[nodemanager.git] / net.py
diff --git a/net.py b/net.py
index b67acf4..b962864 100644 (file)
--- a/net.py
+++ b/net.py
@@ -1,6 +1,3 @@
-# $Id$
-# $URL$
-
 """network configuration"""
 
 # system provided modules
@@ -10,21 +7,38 @@ import os, string, time, socket
 import sioc, plnet
 
 # local modules
-import bwlimit, logger, iptables, tools
+import plnode.bwlimit as bwlimit
+import logger, iptables, tools
 
 # we can't do anything without a network
 priority=1
 
 dev_default = tools.get_default_if()
 
-def start(options, conf):
+
+def start():
     logger.log("net: plugin starting up...")
 
 def GetSlivers(data, config, plc):
+    # added by caglar
+    # band-aid for short period as old API returns networks instead of interfaces
+    global KEY_NAME
+    KEY_NAME = "interfaces"
+    #################
+
     logger.verbose("net: GetSlivers called.")
     if not 'interfaces' in data:
-        logger.log_missing_data('net.GetSlivers','interfaces')
-        return
+        # added by caglar
+        # band-aid for short period as old API returns networks instead of interfaces
+        # logger.log_missing_data('net.GetSlivers','interfaces')
+        # return
+        if not 'networks' in data:
+            logger.log_missing_data('net.GetSlivers','interfaces')
+            return
+        else:
+            KEY_NAME = "networks"
+        ##################
+
     plnet.InitInterfaces(logger, plc, data)
     if 'OVERRIDES' in dir(config):
         if config.OVERRIDES.get('net_max_rate') == '-1':
@@ -50,7 +64,7 @@ def InitNodeLimit(data):
     for dev in devs:
         macs[sioc.gifhwaddr(dev).lower()] = dev
 
-    for interface in data['interfaces']:
+    for interface in data[KEY_NAME]:
         # Get interface name preferably from MAC address, falling
         # back on IP address.
         hwaddr=interface['mac']
@@ -118,7 +132,7 @@ def InitNAT(plc, data):
         macs[sioc.gifhwaddr(dev).lower()] = dev
 
     ipt = iptables.IPTables()
-    for interface in data['interfaces']:
+    for interface in data[KEY_NAME]:
         # Get interface name preferably from MAC address, falling
         # back on IP address.
         hwaddr=interface['mac']
@@ -156,6 +170,3 @@ def InitNAT(plc, data):
                         fields['source'] = "0.0.0.0/0"
                     ipt.add_pf(fields)
     ipt.commit()
-
-def start(options, config):
-    pass