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