diff options
author | root <root@mdehaan.rdu.redhat.com> | 2007-09-10 18:30:07 -0400 |
---|---|---|
committer | root <root@mdehaan.rdu.redhat.com> | 2007-09-10 18:30:07 -0400 |
commit | 34172fa7ee5c45b8842b191d7f36a340c882891d (patch) | |
tree | 493a252227a7863d74da3ac90b04048f4d0aa56d /cobbler | |
parent | 3b1f2fcc735759d2f35f6e30a7548d8e61744065 (diff) | |
download | third_party-cobbler-34172fa7ee5c45b8842b191d7f36a340c882891d.tar.gz third_party-cobbler-34172fa7ee5c45b8842b191d7f36a340c882891d.tar.xz third_party-cobbler-34172fa7ee5c45b8842b191d7f36a340c882891d.zip |
Added demo_connect.py for working out how to best connect to the https:// interface
remotely.
Diffstat (limited to 'cobbler')
-rw-r--r-- | cobbler/demo_connect.py | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/cobbler/demo_connect.py b/cobbler/demo_connect.py new file mode 100644 index 0000000..8a91012 --- /dev/null +++ b/cobbler/demo_connect.py @@ -0,0 +1,59 @@ +#!/usr/bin/python + +""" +work in progress: demo connection code for Cobbler read-write API +uses SSL+XMLRPC (though just XMLRPC will still work) +adapted from Virt-Factory's old vf_nodecomm source +XMLRPCSSL portions based on http://linux.duke.edu/~icon/misc/xmlrpcssl.py + +Copyright 2007, Red Hat, Inc +Michael DeHaan <mdehaan@redhat.com> +Adrian Likins <alikins@redhat.com> +Scott Seago <sseago@redhat.com> + +This software may be freely redistributed under the terms of the GNU +general public license. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +""" + +import sys +import socket + +from M2Crypto import SSL +from M2Crypto.m2xmlrpclib import SSL_Transport, Server +from SimpleXMLRPCServer import SimpleXMLRPCServer, SimpleXMLRPCRequestHandler + + +# workaround for bz #237902 +class CobblerTransport(SSL_Transport): + def __init__(self, ssl_context=None, use_datetime=0): + self._use_datetime = use_datetime + SSL_Transport.__init__(self,ssl_context=ssl_context) + +def demo_connect(username,password,server): + my_ctx = SSL.Context('sslv23') + # my_ctx.load_client_ca("foo.pem") + # my_ctx.load_cert("bar.pem","baz.pem") + my_ctx.set_session_id_ctx("xmlrpcssl") + my_ctx.set_allow_unknown_ca(True) + my_ctx.set_verify(0,-1) # full anonymous (we hope) + my_uri = "https://%s:443/cobbler_api_rw" % server + print "connecting to: %s" % my_uri + my_rserver = Server(my_uri, CobblerTransport(ssl_context = my_ctx)) + token = my_rserver.login(username,password) + print "got a token: %s" % token + rc = my_rserver.test(token) + print "got test results: %s" % rc + +if __name__ == "__main__": + USERNAME = "mdehaan" + PASSWORD = "llamas2007" + SERVER = "mdehaan.rdu.redhat.com" + demo_connect(USERNAME,PASSWORD,SERVER) + + + + |