- <div class="entry">
- <div class="title"><a href="http://people.skolelinux.org/pere/blog/Scripting_the_Cerebrum_bofhd_user_administration_system_using_XML_RPC.html">Scripting the Cerebrum/bofhd user administration system using XML-RPC</a></div>
- <div class="date"> 6th December 2012</div>
- <div class="body"><p>Where I work at the <a href="http://www.uio.no/">University of
-Oslo</a>, we use the
-<a href="http://sourceforge.net/projects/cerebrum/">Cerebrum user
-administration system</a> to maintain users, groups, DNS, DHCP, etc.
-I've known since the system was written that the server is providing
-an <a href="http://en.wikipedia.org/wiki/XML-RPC">XML-RPC</a> API, but
-I have never spent time to try to figure out how to use it, as we
-always use the bofh command line client at work. Until today. I want
-to script the updating of DNS and DHCP to make it easier to set up
-virtual machines. Here are a few notes on how to use it with
-Python.</p>
-
-<p>I started by looking at the source of the Java
-<a href="http://cerebrum.svn.sourceforge.net/viewvc/cerebrum/trunk/cerebrum/clients/jbofh/">bofh
-client</a>, to figure out how it connected to the API server. I also
-googled for python examples on how to use XML-RPC, and found
-<a href="http://tldp.org/HOWTO/XML-RPC-HOWTO/xmlrpc-howto-python.html">a
-simple example in</a> the XML-RPC howto.</p>
-
-<p>This simple example code show how to connect, get the list of
-commands (as a JSON dump), and how to get the information about the
-user currently logged in:</p>
-
-<blockquote><pre>
-#!/usr/bin/env python
-import getpass
-import xmlrpclib
-server_url = 'https://cerebrum-uio.uio.no:8000';
-username = getpass.getuser()
-password = getpass.getpass()
-server = xmlrpclib.Server(server_url);
-#print server.get_commands(sessionid)
-sessionid = server.login(username, password)
-print server.run_command(sessionid, "user_info", username)
-result = server.logout(sessionid)
-print result
-</pre></blockquote>
-
-<p>Armed with this knowledge I can now move forward and script the DNS
-and DHCP updates I wanted to do.</p>
-</div>
- <div class="tags">
-
-
- Tags: <a href="http://people.skolelinux.org/pere/blog/tags/english">english</a>, <a href="http://people.skolelinux.org/pere/blog/tags/sysadmin">sysadmin</a>.
-
-
- </div>
- </div>
- <div class="padding"></div>
-