1 from sfa.util.sfalogging import logger
2 from sfa.util.py23 import xmlrpc_client
6 A simple xmlrpc shell to a federica API server
7 This class can receive the XMLRPC calls to the federica testbed
8 For safety this is limited to a set of hard-coded calls
11 direct_calls = [ 'listAvailableResources',
19 def __init__ ( self, config ) :
20 url=config.SFA_FEDERICA_URL
21 # xxx not sure if java xmlrpc has support for None
22 # self.proxy = xmlrpc_client.ServerProxy(url, verbose = False, allow_none = True)
23 # xxx turn on verbosity
24 self.proxy = xmlrpc_client.ServerProxy(url, verbose = True)
26 # xxx get credentials from the config ?
27 # right now basic auth data goes into the URL
28 # so do *not* add any credential at that point
29 def __getattr__(self, name):
30 def func(*args, **kwds):
31 if name not in FdShell.direct_calls:
32 raise Exception("Illegal method call %s for FEDERICA driver"%(name))
33 logger.info("Issuing %s args=%s kwds=%s to federica"%\
35 # result=getattr(self.proxy, "AggregateManager.%s"%name)(credential, *args, **kwds)
36 result=getattr(self.proxy, "AggregateManager.%s"%name)(*args, **kwds)
37 logger.debug('FdShell %s (%s) returned ... '%(name,name))