4 """Trellis configurator. Toggles network namespace based on slice attribute"""
10 def start(options, config):
14 """For each sliver with the netns attribute, write the value to /etc/vservers/<slice>/spaces/net"""
15 # Parse attributes and update dict of scripts
16 for sliver in data['slivers']:
17 for attribute in sliver['attributes']:
18 if attribute['name'] == 'netns':
19 writeConf(sliver['name'], attribute['value'])
21 def writeConf(slicename, value):
22 SLICEDIR="/etc/vservers/%s/" % slicename
23 SPACESDIR="%s/spaces/" % SLICEDIR
24 if os.path.exists(SLICEDIR):
25 if not os.path.exists(SPACESDIR):
29 logger.log("trellis: could not create %s\n" % SPACESDIR)
31 f = open("%s/net" % SPACESDIR, "w")
32 f.write("%s\n" % value)