From: Petter Reinholdtsen Date: Thu, 6 Dec 2012 09:39:02 +0000 (+0000) Subject: Generated. X-Git-Url: https://pere.pagekite.me/gitweb/homepage.git/commitdiff_plain/226f3937a7020f60bda963522dc220a5383045c6 Generated. --- diff --git a/blog/archive/2012/12/12.rss b/blog/archive/2012/12/12.rss new file mode 100644 index 0000000000..35712991c9 --- /dev/null +++ b/blog/archive/2012/12/12.rss @@ -0,0 +1,58 @@ + + + + Petter Reinholdtsen - Entries from December 2012 + Entries from December 2012 + http://people.skolelinux.org/pere/blog/ + + + + Scripting the Cerebrum/bofhd user administration system using XML-RPC + http://people.skolelinux.org/pere/blog/Scripting_the_Cerebrum_bofhd_user_administration_system_using_XML_RPC.html + http://people.skolelinux.org/pere/blog/Scripting_the_Cerebrum_bofhd_user_administration_system_using_XML_RPC.html + Thu, 6 Dec 2012 10:30:00 +0100 + <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> + + + + + diff --git a/blog/archive/2012/12/index.html b/blog/archive/2012/12/index.html new file mode 100644 index 0000000000..8a9bcf47f1 --- /dev/null +++ b/blog/archive/2012/12/index.html @@ -0,0 +1,327 @@ + + + + + Petter Reinholdtsen: entries from December 2012 + + + + + + +
+

+ Petter Reinholdtsen + +

+ +
+ + +

Entries from December 2012.

+ +
+ +
+ 6th December 2012 +
+
+

Where I work at the University of +Oslo, we use the +Cerebrum user +administration system to maintain users, groups, DNS, DHCP, etc. +I've known since the system was written that the server is providing +an XML-RPC 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.

+ +

I started by looking at the source of the Java +bofh +client, 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 +simple example in the XML-RPC howto.

+ +

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:

+ +
+#!/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
+
+ +

Armed with this knowledge I can now move forward and script the DNS +and DHCP updates I wanted to do.

+ +
+
+ + + Tags: english, sysadmin. + + +
+
+
+ +

RSS Feed

+ +

+ Created by Chronicle v4.4 +

+ + + diff --git a/blog/tags/sysadmin/index.html b/blog/tags/sysadmin/index.html new file mode 100644 index 0000000000..791d0b531f --- /dev/null +++ b/blog/tags/sysadmin/index.html @@ -0,0 +1,326 @@ + + + + + Petter Reinholdtsen: Entries Tagged sysadmin + + + + + +
+

+ Petter Reinholdtsen + +

+ +
+ + +

Entries tagged "sysadmin".

+ +
+ +
+ 6th December 2012 +
+
+

Where I work at the University of +Oslo, we use the +Cerebrum user +administration system to maintain users, groups, DNS, DHCP, etc. +I've known since the system was written that the server is providing +an XML-RPC 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.

+ +

I started by looking at the source of the Java +bofh +client, 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 +simple example in the XML-RPC howto.

+ +

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:

+ +
+#!/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
+
+ +

Armed with this knowledge I can now move forward and script the DNS +and DHCP updates I wanted to do.

+ +
+
+ + + Tags: english, sysadmin. + + +
+
+
+ +

RSS Feed

+ +

+ Created by Chronicle v4.4 +

+ + + diff --git a/blog/tags/sysadmin/sysadmin.rss b/blog/tags/sysadmin/sysadmin.rss new file mode 100644 index 0000000000..57ef436134 --- /dev/null +++ b/blog/tags/sysadmin/sysadmin.rss @@ -0,0 +1,58 @@ + + + + Petter Reinholdtsen - Entries tagged sysadmin + Entries tagged sysadmin + http://people.skolelinux.org/pere/blog/ + + + + Scripting the Cerebrum/bofhd user administration system using XML-RPC + http://people.skolelinux.org/pere/blog/Scripting_the_Cerebrum_bofhd_user_administration_system_using_XML_RPC.html + http://people.skolelinux.org/pere/blog/Scripting_the_Cerebrum_bofhd_user_administration_system_using_XML_RPC.html + Thu, 6 Dec 2012 10:30:00 +0100 + <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> + + + + +