diff options
author | Devan Goodwin <dgoodwin@dangerouslyinc.com> | 2007-10-02 21:42:47 -0300 |
---|---|---|
committer | James Bowes <jbowes@redhat.com> | 2007-10-02 21:33:49 -0400 |
commit | 1ce955ec36f775d8fde2cb9d7943178e8b9d60da (patch) | |
tree | 4c69d218fde87091d4e5d1f3138a435b9164dbf4 /func/overlord/sslclient.py | |
parent | 3c13a4f30f247f4aa75c02c65e6bb6e575e30d01 (diff) | |
download | func-1ce955ec36f775d8fde2cb9d7943178e8b9d60da.tar.gz func-1ce955ec36f775d8fde2cb9d7943178e8b9d60da.tar.xz func-1ce955ec36f775d8fde2cb9d7943178e8b9d60da.zip |
Moved code under the func namespace.
Previously we had overlord, minion, modules, and func all at the root of
the source tree. After install these would all be shuffled below func.
Relocated them in the source tree to reflect this.
Diffstat (limited to 'func/overlord/sslclient.py')
-rw-r--r-- | func/overlord/sslclient.py | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/func/overlord/sslclient.py b/func/overlord/sslclient.py new file mode 100644 index 0000000..ccb2c9c --- /dev/null +++ b/func/overlord/sslclient.py @@ -0,0 +1,52 @@ +#!/usr/bin/python + +import sys +import xmlrpclib +import urllib + +from func import SSLCommon + + +class SSL_Transport(xmlrpclib.Transport): + + user_agent = "pyOpenSSL_XMLRPC/%s - %s" % ('0.1', xmlrpclib.Transport.user_agent) + + def __init__(self, ssl_context, timeout=None, use_datetime=0): + if sys.version_info[:3] >= (2, 5, 0): + xmlrpclib.Transport.__init__(self, use_datetime) + self.ssl_ctx=ssl_context + self._timeout = timeout + + def make_connection(self, host): + # Handle username and password. + try: + host, extra_headers, x509 = self.get_host_info(host) + except AttributeError: + # Yay for Python 2.2 + pass + _host, _port = urllib.splitport(host) + return SSLCommon.HTTPS(_host, int(_port), ssl_context=self.ssl_ctx, timeout=self._timeout) + + +class SSLXMLRPCServerProxy(xmlrpclib.ServerProxy): + def __init__(self, uri, pkey_file, cert_file, ca_cert_file, timeout=None): + self.ctx = SSLCommon.CreateSSLContext(pkey_file, cert_file, ca_cert_file) + xmlrpclib.ServerProxy.__init__(self, uri, SSL_Transport(ssl_context=self.ctx, timeout=timeout)) + + +class FuncServer(SSLXMLRPCServerProxy): + def __init__(self, uri, pem=None, crt=None, ca=None): + self.pem = pem + self.crt = crt + self.ca = ca + + SSLXMLRPCServerProxy.__init__(self, uri, + self.pem, + self.crt, + self.ca) + + +if __name__ == "__main__": + s = SSLXMLRPCServerProxy('https://localhost:51234/', '/etc/pki/func/slave.pem', '/etc/pki/func/slave.cert', '/etc/pki/func/ca/funcmaster.crt') + f = s.ping(1, 2) + print f |