From: Marc Fiuczynski Date: Tue, 7 Jul 2009 20:32:36 +0000 (+0000) Subject: - turn net.py into a NM plugin and move to plugin directory X-Git-Tag: NodeManager-1.8-8~18 X-Git-Url: http://git.onelab.eu/?p=nodemanager.git;a=commitdiff_plain;h=b994d0a94352d9c4f3fc430c317f7a37dd3414d4 - turn net.py into a NM plugin and move to plugin directory - pass plc, data, and config to each plugin --- diff --git a/nm.py b/nm.py index 1dd1b67..83a78f2 100755 --- a/nm.py +++ b/nm.py @@ -24,7 +24,6 @@ import tools from config import Config from plcapi import PLCAPI import random -import net 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 = {} - # 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') - callback(data, plc, config) + callback(plc, data, config) except: logger.log_exc() diff --git a/plugins/codemux.py b/plugins/codemux.py index aa29351..1f8d4b1 100644 --- a/plugins/codemux.py +++ b/plugins/codemux.py @@ -11,11 +11,10 @@ from config import Config CODEMUXCONF="/etc/codemux/codemux.conf" -def start(options, config): +def start(options, conf): 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. diff --git a/net.py b/plugins/net.py similarity index 98% rename from net.py rename to plugins/net.py index 0c8b357..30f44d8 100644 --- a/net.py +++ b/plugins/net.py @@ -13,7 +13,10 @@ import sioc, plnet # 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): diff --git a/plugins/vsys.py b/plugins/vsys.py index dad1b75..3effa58 100644 --- a/plugins/vsys.py +++ b/plugins/vsys.py @@ -10,11 +10,10 @@ from sets import Set VSYSCONF="/etc/vsys.conf" VSYSBKEND="/vsys" -def start(options, config): +def start(options, conf): 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 = {}