5 A simple xmlrpc shell to a myplc instance
6 This class can receive all PLCAPI calls to the underlying testbed
7 For safety this is limited to a set of hard-coded calls
10 direct_calls = ['AddNode', 'AddPerson', 'AddPersonKey', 'AddPersonToSite',
11 'AddPersonToSlice', 'AddRoleToPerson', 'AddSite', 'AddSiteTag', 'AddSlice',
12 'AddSliceTag', 'AddSliceToNodes', 'BindObjectToPeer', 'DeleteKey',
13 'DeleteNode', 'DeletePerson', 'DeletePersonFromSlice', 'DeleteSite',
14 'DeleteSlice', 'DeleteSliceFromNodes', 'DeleteSliceTag', 'GetInitScripts',
15 'GetInterfaces', 'GetKeys', 'GetNodeTags', 'GetPeers',
16 'GetPersons', 'GetSlices', 'GetSliceTags', 'GetTagTypes',
17 'UnBindObjectFromPeer', 'UpdateNode', 'UpdatePerson', 'UpdateSite',
18 'UpdateSlice', 'UpdateSliceTag',
19 # also used as-is in importer
20 'GetSites','GetNodes',
22 # support for other names - this is experimental
23 alias_calls = { 'get_authorities':'GetSites',
24 'get_nodes':'GetNodes',
27 def __init__ ( self, config ) :
28 self.plauth = {'Username': config.SFA_PLC_USER,
29 'AuthMethod': 'password',
30 'AuthString': config.SFA_PLC_PASSWORD}
32 self.url = config.SFA_PLC_URL
33 self.plauth = {'Username': 'root@test.onelab.eu',
34 'AuthMethod': 'password',
35 'AuthString': 'test++'}
36 self.proxy_server = xmlrpclib.Server(self.url, verbose = 0, allow_none = True)
38 def __getattr__(self, name):
39 def func(*args, **kwds):
41 if name in PlShell.direct_calls: actual_name=name
42 if name in PlShell.alias_calls: actual_name=PlShell.alias_calls[name]
44 raise Exception, "Illegal method call %s for PL driver"%(name)
45 return getattr(self.proxy_server, actual_name)(self.plauth, *args, **kwds)