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