%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
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):
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()
# 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]}
# 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'])
try:
os.mkdir("/vservers/%s/vsys" % sliver)
return True
- except OSError:
+ except OSError:
return False