X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fnitos%2Fnitosshell.py;h=8142b1e4a05be3ecfea612875495c49bf9939e8b;hb=32659abc546ba8fd6672d9a41e7eb0fba0a9b2bd;hp=269e367684e17e8a3d43eb4eaffc784280c2ae73;hpb=7fcb8153bd74ce00f9f0d43c8aa090e0b70e345f;p=sfa.git diff --git a/sfa/nitos/nitosshell.py b/sfa/nitos/nitosshell.py index 269e3676..8142b1e4 100644 --- a/sfa/nitos/nitosshell.py +++ b/sfa/nitos/nitosshell.py @@ -1,9 +1,10 @@ import sys -import xmlrpclib import socket from urlparse import urlparse from sfa.util.sfalogging import logger +from sfa.util.py23 import xmlrpc_client + class NitosShell: """ @@ -11,32 +12,35 @@ class NitosShell: This class can receive all NITOS API calls to the underlying testbed For safety this is limited to a set of hard-coded calls """ - - direct_calls = ['getNodes','getChannels','getSlices','getUsers','getReservedNodes', - 'getReservedChannels','getTestbedInfo', - 'reserveNodes','reserveChannels','addSlice','addUser','addUserToSlice', - 'addUserKey','addNode', 'addChannel', - 'updateReservedNodes','updateReservedChannels','updateSlice','updateUser', + + direct_calls = ['getNodes', 'getChannels', 'getSlices', 'getUsers', 'getReservedNodes', + 'getReservedChannels', 'getTestbedInfo', + 'reserveNodes', 'reserveChannels', 'addSlice', 'addUser', 'addUserToSlice', + 'addUserKey', 'addNode', 'addChannel', + 'updateReservedNodes', 'updateReservedChannels', 'updateSlice', 'updateUser', 'updateNode', 'updateChannel', - 'deleteNode','deleteChannel','deleteSlice','deleteUser', 'deleteUserFromSLice', + 'deleteNode', 'deleteChannel', 'deleteSlice', 'deleteUser', 'deleteUserFromSLice', 'deleteKey', 'releaseNodes', 'releaseChannels' ] - - # use the 'capability' auth mechanism for higher performance when the PLC db is local - def __init__ ( self, config ) : + # use the 'capability' auth mechanism for higher performance when the PLC + # db is local + def __init__(self, config): url = config.SFA_NITOS_URL - self.proxy = xmlrpclib.Server(url, verbose = False, allow_none = True) + self.proxy = xmlrpc_client.ServerProxy( + url, verbose=False, allow_none=True) def __getattr__(self, name): def func(*args, **kwds): - actual_name=None - if name in NitosShell.direct_calls: actual_name=name + actual_name = None + if name in NitosShell.direct_calls: + actual_name = name if not actual_name: - raise Exception, "Illegal method call %s for NITOS driver"%(name) + raise Exception( + "Illegal method call %s for NITOS driver" % (name)) actual_name = "scheduler.server." + actual_name - result=getattr(self.proxy, actual_name)(*args, **kwds) - logger.debug('NitosShell %s (%s) returned ... '%(name,actual_name)) + result = getattr(self.proxy, actual_name)(*args, **kwds) + logger.debug('NitosShell %s (%s) returned ... ' % + (name, actual_name)) return result return func -