removed another bunch of references to geni
[sfa.git] / sfa / plc / remoteshell.py
1 # remoteshell.py
2 #
3 # interface to the PLC api via xmlrpc
4 #
5 # RemoteShell() exports an API that looks identical to that exported by
6 # PLC.Shell.Shell(). It's meant to be a drop in replacement for running
7 # SFA on a different machine than PLC.
8
9 ### $Id$
10 ### $URL$
11
12 import xmlrpclib
13
14 class RemoteShell:
15     def __init__(self):
16         self.servers = {}
17
18     def call(self, name, pl_auth, *args):
19
20         key = pl_auth["Url"] + "#" + pl_auth["Username"]
21
22         if not (key in self.servers):
23             server = xmlrpclib.Server(pl_auth["Url"], verbose = 0, allow_none=True)
24             #server.AdmAuthCheck(pl_auth)
25             server.AuthCheck(pl_auth)
26             self.servers[key] = server
27
28         server = self.servers[key]
29
30         arglist = ["pl_auth"]
31         for arg in args:
32             arglist.append(repr(arg))
33
34         str = "server." + name + "(" + ",".join(arglist) + ")"
35         result = eval(str)
36
37         return result
38
39     # TODO: there's probably an automatic way to import all these stubs
40
41     def AddInitScript(self, pl_auth, *args):
42         return self.call("AddInitScript", pl_auth, *args)
43
44     def AddNode(self, pl_auth, *args):
45         return self.call("AddNode", pl_auth, *args)
46
47     def AddPerson(self, pl_auth, *args):
48         return self.call("AddPerson", pl_auth, *args)
49
50     def AddPersonToSlice(self, pl_auth, *args):
51         return self.call("AddPersonToSlice", pl_auth, *args)
52
53     def AddSite(self, pl_auth, *args):
54         return self.call("AddSite", pl_auth, *args)
55
56     def AddSlice(self, pl_auth, *args):
57         return self.call("AddSlice", pl_auth, *args)
58
59     def DeleteNode(self, pl_auth, *args):
60         return self.call("DeleteNode", pl_auth, *args)
61
62     def DeletePerson(self, pl_auth, *args):
63         return self.call("DeletePerson", pl_auth, *args)
64
65     def DeletePersonFromSlice(self, pl_auth, *args):
66         return self.call("DeletePersonFromSlice", pl_auth, *args)
67
68     def DeleteSite(self, pl_auth, *args):
69         return self.call("DeleteSite", pl_auth, *args)
70
71     def DeleteSlice(self, pl_auth, *args):
72         return self.call("DeleteSlice", pl_auth, *args)
73
74     def GetInitScripts(self, pl_auth, *args):
75         return self.call("GetInitScripts", pl_auth, *args)
76
77     def GetKeys(self, pl_auth, *args):
78         return self.call("GetKeys", pl_auth, *args)
79
80     def GetNodes(self, pl_auth, *args):
81         return self.call("GetNodes", pl_auth, *args)
82
83     def GetPersons(self, pl_auth, *args):
84         return self.call("GetPersons", pl_auth, *args)
85
86     def GetSites(self, pl_auth, *args):
87         return self.call("GetSites", pl_auth, *args)
88
89     def GetSliceAttributes(self, pl_auth, *args):
90         return self.call("GetSliceAttributes", pl_auth, *args)
91
92     def GetSlices(self, pl_auth, *args):
93         return self.call("GetSlices", pl_auth, *args)
94
95     def UpdateNode(self, pl_auth, *args):
96         return self.call("UpdateNode", pl_auth, *args)
97
98     def UpdatePerson(self, pl_auth, *args):
99         return self.call("UpdatePerson", pl_auth, *args)
100
101     def UpdateSite(self, pl_auth, *args):
102         return self.call("UpdateSite", pl_auth, *args)
103
104     def UpdateSlice(self, pl_auth, *args):
105         return self.call("UpdateSlice", pl_auth, *args)
106
107