Disallow multiple conf_files instances and have conf_files use curl with certificates.
[nodemanager.git] / safexmlrpc.py
1 """Leverage curl to make XMLRPC requests that check the server's credentials."""
2
3 import curlwrapper
4 import xmlrpclib
5
6
7 CURL = '/usr/bin/curl'
8
9 class CertificateCheckingSafeTransport(xmlrpclib.Transport):
10     def request(self, host, handler, request_body, verbose=0):
11         self.verbose = verbose
12         try:
13             contents = curlwrapper.retrieve('https://%s%s' % (host, handler), request_body)
14             return xmlrpclib.loads(contents)[0]
15         except curlwrapper.CurlException, e: raise xmlrpclib.ProtocolError(host + handler, -1, str(e), '')
16
17 class ServerProxy(xmlrpclib.ServerProxy):
18     def __init__(self, handler, *args, **kw_args): xmlrpclib.ServerProxy.__init__(self, handler, CertificateCheckingSafeTransport())