X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Ffederica%2Ffdshell.py;h=179c8516d24f1133fe38e2d2991aec6a38634aae;hb=fd395e1944dcd49f10a4d5b27ce4983ad389fb96;hp=7195b5650e562eb005d15fcef7dc105294d833bf;hpb=e252a445e0fca9d358f60b58b6627a1e1896e60d;p=sfa.git diff --git a/sfa/federica/fdshell.py b/sfa/federica/fdshell.py index 7195b565..179c8516 100644 --- a/sfa/federica/fdshell.py +++ b/sfa/federica/fdshell.py @@ -1,6 +1,6 @@ -import xmlrpclib - from sfa.util.sfalogging import logger +from sfa.util.py23 import xmlrpc_client + class FdShell: """ @@ -8,38 +8,35 @@ class FdShell: This class can receive the XMLRPC calls to the federica testbed For safety this is limited to a set of hard-coded calls """ - - direct_calls = [ 'listAvailableResources', - 'listSliceResources', - 'createSlice', - 'deleteSlice', - 'getRSpecVersion', - 'listSlices', + + direct_calls = ['listAvailableResources', + 'listSliceResources', + 'createSlice', + 'deleteSlice', + 'getRSpecVersion', + 'listSlices', ] - def __init__ ( self, config ) : - # xxx to be configurable - SFA_FEDERICA_URL = "http://%s:%s@%s:%s/"%\ - (config.SFA_FEDERICA_USER,config.SFA_FEDERICA_PASSWORD, - config.SFA_FEDERICA_HOSTNAME,config.SFA_FEDERICA_PORT) - url=SFA_FEDERICA_URL + def __init__(self, config): + url = config.SFA_FEDERICA_URL # xxx not sure if java xmlrpc has support for None - # self.proxy = xmlrpclib.Server(url, verbose = False, allow_none = True) + # self.proxy = xmlrpc_client.ServerProxy(url, verbose = False, allow_none = True) # xxx turn on verbosity - self.proxy = xmlrpclib.Server(url, verbose = True) + self.proxy = xmlrpc_client.ServerProxy(url, verbose=True) + # xxx get credentials from the config ? + # right now basic auth data goes into the URL + # so do *not* add any credential at that point def __getattr__(self, name): def func(*args, **kwds): if name not in FdShell.direct_calls: - raise Exception, "Illegal method call %s for FEDERICA driver"%(name) - # xxx get credentials from the config ? - # right now basic auth data goes into the URL - # the API still provides for a first credential arg though - credential='xxx-unused-xxx' - logger.info("Issuing %s args=%s kwds=%s to federica"%\ - (name,args,kwds)) - result=getattr(self.proxy, "AggregateManager.%s"%name)(credential, *args, **kwds) - logger.debug('FdShell %s (%s) returned ... '%(name,name)) + raise Exception( + "Illegal method call %s for FEDERICA driver" % (name)) + logger.info("Issuing %s args=%s kwds=%s to federica" % + (name, args, kwds)) +# result=getattr(self.proxy, "AggregateManager.%s"%name)(credential, *args, **kwds) + result = getattr(self.proxy, "AggregateManager.%s" % + name)(*args, **kwds) + logger.debug('FdShell %s (%s) returned ... ' % (name, name)) return result return func -