From 28992edd0cab541081af9093a25208fc26949131 Mon Sep 17 00:00:00 2001 From: Faiyaz Ahmed Date: Wed, 6 Feb 2008 22:05:32 +0000 Subject: [PATCH] long awaited vsys callback. Still in progress. --- vsys.py | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 vsys.py diff --git a/vsys.py b/vsys.py new file mode 100644 index 0000000..6f6d14f --- /dev/null +++ b/vsys.py @@ -0,0 +1,50 @@ +# $Id$ +# $URL$ + +"""vsys configurator. Maintains ACLs and script pipes inside vservers based on slice attributes.""" + +import logger +import os + + +def start(options, config): + pass + +def GetSlivers(data): + """For each sliver with the vsys attribute, set the script ACL, create the vsys directory in the slice, and restart vsys.""" + confedSlivers = parseConf("/etc/vsys.conf") + newSlivers = [] + for sliver in data['slivers']: + for attribute in sliver['attributes']: + if attribute['name'] == 'vsys': + # As the name implies, when we find an attribute, we + createVsysDir(sliver) + if sliver['name'] not in confedSlivers: newSlivers.append(sliver['name']) + + writeConf(confedSlivers + newSlivers, "/etc/vsys.conf") + +def secureScripts(): + +def createVsysDir(sliver): + '''Create /vsys directory in slice. Update vsys conf file.''' + try: os.makedirs("/vservers/%s/vsys" % sliver['name']) + except OSError: pass + + +def parseConf(file): + '''Parse the vserver conf. Return [slices] in conf.''' + slices = [] + f = open(file) + for line in f.readlines(): + (slice, path) = line.split() + slices.append(slice) + f.close() + return slices + + +def writeConf(slivers, file): + f = open(file,"w") + for sliver in slivers: + f.write("/vservers/%(name)s/vsys %(name)s\n" % {"name": sliver}) + f.truncate() + f.close() -- 2.45.2