X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=plcapi.py;h=4da9e4883b8f5ad61122c434b6e0f68623bc4535;hb=refs%2Fheads%2Fplanetlab-4_0-branch;hp=fd04b6a5e9394483350d4bb5d46c7b8d5a681c7e;hpb=f25305ef9eaf0aa2f83f78dcdc1b7a545e81ca64;p=nodemanager.git diff --git a/plcapi.py b/plcapi.py index fd04b6a..4da9e48 100644 --- a/plcapi.py +++ b/plcapi.py @@ -1,9 +1,9 @@ -import xmlrpclib +import safexmlrpc import hmac, sha class PLCAPI: """ - Wrapper around xmlrpclib.ServerProxy to automagically add an Auth + Wrapper around safexmlrpc.ServerProxy to automagically add an Auth struct as the first argument to every XML-RPC call. Initialize auth with either: @@ -15,7 +15,7 @@ class PLCAPI: the new session-based method. """ - def __init__(self, uri, auth, **kwds): + def __init__(self, uri, cacert, auth, timeout = 300, **kwds): if isinstance(auth, (tuple, list)): (self.node_id, self.key) = auth self.session = None @@ -23,7 +23,7 @@ class PLCAPI: self.node_id = self.key = None self.session = auth - self.server = xmlrpclib.ServerProxy(uri, allow_none = 1, **kwds) + self.server = safexmlrpc.ServerProxy(uri, cacert, timeout, allow_none = 1, **kwds) def add_auth(self, function): """ @@ -44,12 +44,12 @@ class PLCAPI: if isinstance(arg, list) or isinstance(arg, tuple): # The old implementation did not recursively handle # lists of lists. But neither did the old API itself. - values += self.canonicalize(arg) + values += canonicalize(arg) elif isinstance(arg, dict): # Yes, the comments in the old implementation are # misleading. Keys of dicts are not included in the # hash. - values += self.canonicalize(arg.values()) + values += canonicalize(arg.values()) else: # We use unicode() instead of str(). values.append(unicode(arg)) @@ -64,7 +64,8 @@ class PLCAPI: if self.session is not None: # Use session authentication - auth = {'session': self.session} + auth = {'AuthMethod': "session", + 'session': self.session} else: # Yes, this is the "canonicalization" method used. args = canonicalize(params)