3 from sfa.util.sfalogging import logger
7 A simple xmlrpc shell to a federica API server
8 This class can receive the XMLRPC calls to the federica testbed
9 For safety this is limited to a set of hard-coded calls
12 direct_calls = [ 'listAvailableResources',
20 def __init__ ( self, config ) :
21 url=config.SFA_FEDERICA_URL
22 # xxx not sure if java xmlrpc has support for None
23 # self.proxy = xmlrpclib.Server(url, verbose = False, allow_none = True)
24 # xxx turn on verbosity
25 self.proxy = xmlrpclib.Server(url, verbose = True)
27 def __getattr__(self, name):
28 def func(*args, **kwds):
29 if name not in FdShell.direct_calls:
30 raise Exception, "Illegal method call %s for FEDERICA driver"%(name)
31 # xxx get credentials from the config ?
32 # right now basic auth data goes into the URL
33 # the API still provides for a first credential arg though
34 credential='xxx-unused-xxx'
35 logger.info("Issuing %s args=%s kwds=%s to federica"%\
37 result=getattr(self.proxy, "AggregateManager.%s"%name)(credential, *args, **kwds)
38 logger.debug('FdShell %s (%s) returned ... '%(name,name))