9 def __getattr__(self, method):
13 def __call__(self, *args):
15 sfa_slice = "pl_genicw"
16 python = "/usr/bin/python"
17 vserver_path = "/vservers/%s" % (sfa_slice)
19 path = "%(vserver_path)s/%(script_path)s" % locals()
20 (fd, filename) = tempfile.mkstemp(dir=path)
21 scriptname = script_path + os.sep + filename.split(os.sep)[-1:][0]
22 # define the script to execute
26 s = xmlrpclib.ServerProxy('http://127.0.0.1:812')
27 print s.%(method)s%(args)s""" % locals()
30 # write the script to a temporary file
31 f = open(filename, 'w')
32 f.write(script % locals())
34 # make the file executeable
35 chmod_cmd = "/bin/chmod 775 %(filename)s" % locals()
37 (status, output) = commands.getstatusoutput(chmod_cmd)
39 # execute the commad as a slice with root NM privs
40 cmd = 'su - %(sfa_slice)s -c "%(python)s %(scriptname)s"' % locals()
42 (status, output) = commands.getstatusoutput(cmd)
43 return (status, output)
44 finally: os.unlink(filename)