From 4f04767359981da2906f6c4a0315e5da147db3bf Mon Sep 17 00:00:00 2001 From: Daniel Hokka Zakrisson Date: Mon, 24 Nov 2008 17:09:46 +0000 Subject: [PATCH] Merge changeset 11123 from the trunk --- NodeManager.spec | 2 ++ nm.py | 6 ++++++ codemux.py => plugins/codemux.py | 7 +++++-- vsys.py => plugins/vsys.py | 4 ++-- 4 files changed, 15 insertions(+), 4 deletions(-) rename codemux.py => plugins/codemux.py (96%) rename vsys.py => plugins/vsys.py (98%) diff --git a/NodeManager.spec b/NodeManager.spec index 185db5c..093eba6 100644 --- a/NodeManager.spec +++ b/NodeManager.spec @@ -97,7 +97,9 @@ rm -rf $RPM_BUILD_ROOT %defattr(-,root,root,-) %doc %dir %{_datadir}/NodeManager +%dir %{_datadir}/NodeManager/plugins %{_datadir}/NodeManager/* +%{_datadir}/NodeManager/plugins/* %{_bindir}/forward_api_calls %{_initrddir}/nm %{_initrddir}/conf_files diff --git a/nm.py b/nm.py index bb0a2ab..36d121b 100755 --- a/nm.py +++ b/nm.py @@ -39,9 +39,15 @@ parser.add_option('-k', '--session', action='store', dest='session', default='/e parser.add_option('-p', '--period', action='store', dest='period', default=600, help='Polling interval (sec)') parser.add_option('-r', '--random', action='store', dest='random', default=301, help='Range for additional random polling interval (sec)') parser.add_option('-v', '--verbose', action='store_true', dest='verbose', default=False, help='more verbose log') +parser.add_option('-P', '--path', action='store', dest='path', default='/usr/share/NodeManager/plugins', help='Path to plugins directory') parser.add_option('-m', '--module', action='store', dest='module', default='', help='run a single module among '+' '.join(known_modules)) (options, args) = parser.parse_args() +# Deal with plugins directory +if os.path.exists(options.path): + sys.path.append(options.path) + known_modules += [i[:-3] for i in os.listdir(options.path) if i.endswith(".py") and (i[:-3] not in known_modules)] + modules = [] def GetSlivers(plc): diff --git a/codemux.py b/plugins/codemux.py similarity index 96% rename from codemux.py rename to plugins/codemux.py index 7b11350..ce69e4a 100644 --- a/codemux.py +++ b/plugins/codemux.py @@ -16,7 +16,10 @@ def start(options, config): def GetSlivers(data): - """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. + """ logger.log("codemux: Starting.", 2) # slices already in conf slicesinconf = parseConf() @@ -30,7 +33,7 @@ def GetSlivers(data): # Parse attributes and update dict of scripts for sliver in data['slivers']: for attribute in sliver['attributes']: - if attribute['name'] == 'codemux': + if attribute['tagname'] == 'codemux': # add to conf. Attribute is [host, port] params = {'host': attribute['value'].split(",")[0], 'port': attribute['value'].split(",")[1]} diff --git a/vsys.py b/plugins/vsys.py similarity index 98% rename from vsys.py rename to plugins/vsys.py index c72941c..d26ee4a 100644 --- a/vsys.py +++ b/plugins/vsys.py @@ -25,7 +25,7 @@ def GetSlivers(data): # Parse attributes and update dict of scripts for sliver in data['slivers']: for attribute in sliver['attributes']: - if attribute['name'] == 'vsys': + if attribute['tagname'] == 'vsys': if sliver['name'] not in slices: # add to conf slices.append(sliver['name']) @@ -46,7 +46,7 @@ def createVsysDir(sliver): try: os.mkdir("/vservers/%s/vsys" % sliver) return True - except OSError: + except OSError: return False -- 2.43.0