3 from urlparse import urlparse
5 from sfa.util.sfalogging import logger
6 from sfa.util.py23 import xmlrpc_client
10 A simple xmlrpc shell to a NITOS Scheduler instance
11 This class can receive all NITOS API calls to the underlying testbed
12 For safety this is limited to a set of hard-coded calls
15 direct_calls = ['getNodes','getChannels','getSlices','getUsers','getReservedNodes',
16 'getReservedChannels','getTestbedInfo',
17 'reserveNodes','reserveChannels','addSlice','addUser','addUserToSlice',
18 'addUserKey','addNode', 'addChannel',
19 'updateReservedNodes','updateReservedChannels','updateSlice','updateUser',
20 'updateNode', 'updateChannel',
21 'deleteNode','deleteChannel','deleteSlice','deleteUser', 'deleteUserFromSLice',
22 'deleteKey', 'releaseNodes', 'releaseChannels'
26 # use the 'capability' auth mechanism for higher performance when the PLC db is local
27 def __init__ ( self, config ) :
28 url = config.SFA_NITOS_URL
29 self.proxy = xmlrpc_client.ServerProxy(url, verbose = False, allow_none = True)
31 def __getattr__(self, name):
32 def func(*args, **kwds):
34 if name in NitosShell.direct_calls: actual_name=name
36 raise Exception("Illegal method call %s for NITOS driver"%(name))
37 actual_name = "scheduler.server." + actual_name
38 result=getattr(self.proxy, actual_name)(*args, **kwds)
39 logger.debug('NitosShell %s (%s) returned ... '%(name,actual_name))