- turn net.py into a NM plugin and move to plugin directory
authorMarc Fiuczynski <mef@cs.princeton.edu>
Tue, 7 Jul 2009 20:32:36 +0000 (20:32 +0000)
committerMarc Fiuczynski <mef@cs.princeton.edu>
Tue, 7 Jul 2009 20:32:36 +0000 (20:32 +0000)
- pass plc, data, and config to each plugin

nm.py
plugins/codemux.py
plugins/net.py [moved from net.py with 98% similarity]
plugins/vsys.py

diff --git a/nm.py b/nm.py
index 1dd1b67..83a78f2 100755 (executable)
--- a/nm.py
+++ b/nm.py
@@ -24,7 +24,6 @@ import tools
 from config import Config
 from plcapi import PLCAPI 
 import random
 from config import Config
 from plcapi import PLCAPI 
 import random
-import net
 
 id="$Id$"
 savedargv = sys.argv[:]
 
 id="$Id$"
 savedargv = sys.argv[:]
@@ -62,15 +61,11 @@ def GetSlivers(plc, config):
         #  XXX So some modules can at least boostrap.
         logger.log("nm:  Can't contact PLC to GetSlivers().  Continuing.")
         data = {}
         #  XXX So some modules can at least boostrap.
         logger.log("nm:  Can't contact PLC to GetSlivers().  Continuing.")
         data = {}
-    # Set i2 ip list for nodes in I2 nodegroup
-    # and init network interfaces (unless overridden)
-    try: net.GetSlivers(plc, data, config) # TODO - num of args needs to be unified across mods.
-    except: logger.log_exc()
-    #  All other callback modules
+    #  Invoke GetSlivers() functions from the callback modules
     for module in modules:
         try:        
             callback = getattr(module, 'GetSlivers')
     for module in modules:
         try:        
             callback = getattr(module, 'GetSlivers')
-            callback(data, plc, config)
+            callback(plc, data, config)
         except: logger.log_exc()
 
 
         except: logger.log_exc()
 
 
index aa29351..1f8d4b1 100644 (file)
@@ -11,11 +11,10 @@ from config import Config
 
 CODEMUXCONF="/etc/codemux/codemux.conf"
 
 
 CODEMUXCONF="/etc/codemux/codemux.conf"
 
-def start(options, config):
+def start(options, conf):
     pass
 
     pass
 
-
-def GetSlivers(data, plc = None, config = None):
+def GetSlivers(plc, data, config):
     """
     For each sliver with the codemux attribute, parse out "host,port" 
     and make entry in conf.  Restart service after.
     """
     For each sliver with the codemux attribute, parse out "host,port" 
     and make entry in conf.  Restart service after.
similarity index 98%
rename from net.py
rename to plugins/net.py
index 0c8b357..30f44d8 100644 (file)
--- a/net.py
@@ -13,7 +13,10 @@ import sioc, plnet
 # local modules
 import bwlimit, logger, iptables
 
 # local modules
 import bwlimit, logger, iptables
 
-def GetSlivers(plc, data, config):
+def start(options, conf):
+    logger.log("net plugin starting up...")
+
+def GetSlivers(plc, data, conf):
     logger.verbose("net:GetSlivers called.")
     InitInterfaces(plc, data) # writes sysconfig files.
     if 'OVERRIDES' in dir(config): 
     logger.verbose("net:GetSlivers called.")
     InitInterfaces(plc, data) # writes sysconfig files.
     if 'OVERRIDES' in dir(config): 
index dad1b75..3effa58 100644 (file)
@@ -10,11 +10,10 @@ from sets import Set
 VSYSCONF="/etc/vsys.conf"
 VSYSBKEND="/vsys"
 
 VSYSCONF="/etc/vsys.conf"
 VSYSBKEND="/vsys"
 
-def start(options, config):
+def start(options, conf):
     pass
 
     pass
 
-
-def GetSlivers(data, plc = None, config = None):
+def GetSlivers(plc, data, config=None):
     """For each sliver with the vsys attribute, set the script ACL, create the vsys directory in the slice, and restart vsys."""
     # Touch ACLs and create dict of available
     scripts = {}
     """For each sliver with the vsys attribute, set the script ACL, create the vsys directory in the slice, and restart vsys."""
     # Touch ACLs and create dict of available
     scripts = {}