Stop and destroy working correctly. Unix accounts created on configure method.
[nodemanager.git] / safexmlrpc.py
1 """Leverage curl to make XMLRPC requests that check the server's credentials."""
2
3 import xmlrpclib
4
5 import curlwrapper
6
7
8 class CertificateCheckingSafeTransport (xmlrpclib.Transport):
9
10     def __init__(self, cacert, timeout):
11         self.cacert = cacert
12         self.timeout = timeout
13
14     def request(self, host, handler, request_body, verbose=0):
15         self.verbose = verbose
16         url='https://%s%s' % (host, handler)
17         # this might raise an xmlrpclib.Protocolerror exception
18         contents = curlwrapper.retrieve(url,
19                                         cacert = self.cacert,
20                                         postdata = request_body,
21                                         timeout = self.timeout)
22         return xmlrpclib.loads(contents)[0]
23
24 class ServerProxy(xmlrpclib.ServerProxy):
25
26     def __init__(self, uri, cacert, timeout = 300, **kwds):
27         xmlrpclib.ServerProxy.__init__(self, uri,
28                                        CertificateCheckingSafeTransport(cacert, timeout),
29                                        **kwds)