the big cleanup: remove max aggregate manager
[sfa.git] / sfa / federica / fdshell.py
1 from sfa.util.sfalogging import logger
2 from sfa.util.py23 import xmlrpc_client
3
4
5 class FdShell:
6     """
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
10     """
11
12     direct_calls = ['listAvailableResources',
13                     'listSliceResources',
14                     'createSlice',
15                     'deleteSlice',
16                     'getRSpecVersion',
17                     'listSlices',
18                     ]
19
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 = xmlrpc_client.ServerProxy(url, verbose = False, allow_none = True)
24         # xxx turn on verbosity
25         self.proxy = xmlrpc_client.ServerProxy(url, verbose=True)
26
27     # xxx get credentials from the config ?
28     # right now basic auth data goes into the URL
29     # so do *not* add any credential at that point
30     def __getattr__(self, name):
31         def func(*args, **kwds):
32             if name not in FdShell.direct_calls:
33                 raise Exception(
34                     "Illegal method call %s for FEDERICA driver" % (name))
35             logger.info("Issuing %s args=%s kwds=%s to federica" %
36                         (name, args, kwds))
37 #            result=getattr(self.proxy, "AggregateManager.%s"%name)(credential, *args, **kwds)
38             result = getattr(self.proxy, "AggregateManager.%s" %
39                              name)(*args, **kwds)
40             logger.debug('FdShell %s (%s) returned ... ' % (name, name))
41             return result
42         return func