<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Straight Ornamental</title>
    <link>http://grahamstratton.org/blog/public/</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Ramblings from a rambler</description>
    <item>
      <title>New blog has RSS</title>
      <description>&lt;p&gt;Any subscribers to this blog might like to subscribe to my new blog instead. The feed is at http://grahamstratton.org/straightornamental/feed.rss&lt;/p&gt;</description>
      <pubDate>Sun, 20 Jan 2008 03:03:20 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:4c73aa8b-cc8d-4e6c-a828-b48b70994289</guid>
      <author>Graham Stratton</author>
      <link>http://grahamstratton.org/blog/public/articles/2008/01/20/new-blog-has-rss</link>
    </item>
    <item>
      <title>New Blog</title>
      <description>&lt;p&gt;I haven&amp;#8217;t posted much recently, mainly because I&amp;#8217;ve found using Textile markup a pain. So I&amp;#8217;m moving to a new Python-based blog.&lt;/p&gt;


	&lt;p&gt;It&amp;#8217;s currently living at &lt;a href="http://grahamstratton.org/straightornamental/"&gt;http://grahamstratton.org/straightornamental/&lt;/a&gt; until I get the old posts moved over&lt;/p&gt;</description>
      <pubDate>Tue, 04 Dec 2007 17:18:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:3250be67-41b3-4d9c-b8cb-cacf64a1990e</guid>
      <author>Graham Stratton</author>
      <link>http://grahamstratton.org/blog/public/articles/2007/12/04/new-blog</link>
    </item>
    <item>
      <title>Software for Python presentations</title>
      <description>&lt;p&gt;Whilst trying to prepare my EuroPython presentation, I encountered the severe lack of a presentation program for the task. I certainly don&amp;#8217;t have time to create such a program at the moment, but I thought I&amp;#8217;d write down the requirements anyway. I suspect most of the necessary components are available, so it would just be a matter of integrating them.&lt;/p&gt;


	&lt;p&gt;What I&amp;#8217;d like is a program that understands that certain sections are code snippets, allowing doctest to be run on them and providing syntax highlighting. That&amp;#8217;s probably about it, really. I guess the obvious solution would be an extension to ReST doctests, in order to indicate presentation-specific information such as slide boundaries (is that it?). That would probably be enough to be useful, and would make it very easy to make a document out of a slideshow and vice versa.&lt;/p&gt;


	&lt;p&gt;Any advice on components to create such a system would be gratefully received!&lt;/p&gt;</description>
      <pubDate>Sat, 30 Jun 2007 12:16:04 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:e907c942-c0c5-4527-805c-13adbdfca72e</guid>
      <author>Graham Stratton</author>
      <link>http://grahamstratton.org/blog/public/articles/2007/06/30/software-for-python-presentations</link>
      <category>Python</category>
      <category>Conferences</category>
    </item>
    <item>
      <title>Adventures with buildout</title>
      <description>&lt;p&gt;Recently I wanted to try some modifications to a Pylons project against the latest Pylons trunk without upgrading the system-installed Pylons, so I decided it was about time to try Buildout. Jim Fulton&amp;#8217;s buildout (or zc.buildout, since Jim likes to put things in namespaces), is a package to create development and deployment versions of software.  It&amp;#8217;s not in any way Zope-specific, and whilst it is written in Python primarily for installing Python programs, it&amp;#8217;s not really Python-specific either.&lt;/p&gt;


	&lt;p&gt;It is quite complex.  Maybe very complex.  But I think that this is only because deployment is a complex business.  I can imagine using nearly all the features in the &lt;a href="http:http://cheeseshop.python.org/pypi/zc.buildout/1.0.0b27#detailed-documentation"&gt;buildout docs&lt;/a&gt;, and a few more besides. But I did find a lack of really simple examples for us mortals.&lt;/p&gt;


	&lt;p&gt;The example I&amp;#8217;m going to give here is this: suppose you have a project in a repository. You can check it out, but when you&amp;#8217;ve done so you want a way to install all the dependencies, without affecting what&amp;#8217;s already installed on your system.&lt;/p&gt;


	&lt;p&gt;Buildout makes this easy. You need to add two files to your repository:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;bootstrap.py which installs the latest buildout and setuptools&lt;/li&gt;
	&lt;/ul&gt;


	&lt;ul&gt;
	&lt;li&gt;buildout.cfg which contains the configuration for your install&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;You can get bootstrap.py from the Zope Corp subversion server at http://svn.zope.org/zc.buildout/trunk/bootstrap/&lt;/p&gt;


	&lt;p&gt;Here&amp;#8217;s my buildout.cfg:&lt;/p&gt;


&lt;pre&gt;
[buildout]
parts = foxtrot

[foxtrot]
recipe = zc.recipe.egg
interpreter = python2.5
eggs = python-cjson
       nose
       twill
       pastescript
       pylons == 0.9.5
       sqlalchemy
#       pymssql
find-links = http://python.cx.hu/python-cjson/python-cjson-1.0.3x5.tar.gz
             http://www.mirrorservice.org/sites/download.sourceforge.net/pub/sourceforge/p/py/pymssql/
&lt;/pre&gt;

	&lt;p&gt;So my buildout is simple. It only has one part, and the recipe for that is the simple egg recipe zc.recipe.egg. By specifying the interpreter option, I will get a python executable in my bin directory.  When I run it, the environment will contain all the specified packages. I have commented out pymssql because it has too many system dependencies.&lt;/p&gt;


	&lt;p&gt;Packages which are &lt;em&gt;explicitly&lt;/em&gt; specified (not installed as dependencies of other packages) and which define scripts to be installed will have those scripts written to ./bin/ instead of the system directory, and will work in the new environment. So I&amp;#8217;ve explicitly specified nose and pastescript, so that I end up with ./bin/nosetests and ./bin/paster working with this new environment. Cool, eh?&lt;/p&gt;


	&lt;p&gt;The &amp;#8216;find-links&amp;#8217; option is just a list of locations other than the cheeseshop in which to search for packages to install.&lt;/p&gt;


	&lt;p&gt;Once you have your configuration, setting up the environment is simple, if a little slow (mainly due to pypi being rather lethargic at the moment). First, run &lt;pre&gt;python bootstrap.py&lt;/pre&gt;, to install buildout itself. Then run ./bin/buildout, and everything should magically install. If you want to run it again, it will be &lt;em&gt;much&lt;/em&gt; faster with the -N option, which tells buildout not to look for new versions of packages if it already has a version matching the requirements. You can specify version for packages as you would with easy_install.&lt;/p&gt;


	&lt;p&gt;Well, I thought it all worked. But actually buildout doesn&amp;#8217;t seem to use the setuptools that it installs, despite it modifying the path:&lt;/p&gt;


&lt;pre&gt;
$ ./bin/buildout -N
Uninstalling foxtrot.
Installing foxtrot.
Getting distribution for 'Routes&amp;gt;=1.6.3'.
The required version of setuptools (&amp;gt;=0.6c6) is not available, and
can't be installed while this script is running. Please install
 a more recent version first.

(Currently using setuptools 0.6c5 (/usr/local/lib/python2.5/site-packages/setuptools-0.6c5-py2.5.egg))
error: Setup script exited with 2
&lt;/pre&gt;

	&lt;p&gt;Which is really odd, given that bin/buildout begins with:&lt;/p&gt;


&lt;pre&gt;
#!/usr/local/bin/python2.5

import sys
sys.path[0:0] = [
  '/Users/graham/development/pylons/foxtrot/eggs/zc.buildout-1.0.0b27-py2.5.egg',
  '/Users/graham/development/pylons/foxtrot/eggs/setuptools-0.6c6-py2.5.egg',
  ]
&lt;/pre&gt;

	&lt;p&gt;And I had another problem. I wanted to install the development version of pylons into my buildout. So I specified pylons==dev. But buildout gave an error since the version which got installed (0.9.6dev-r2373) wasn&amp;#8217;t the version requested. But then specifying pylons &amp;gt;= 0.9.6dev-r2373 worked.&lt;/p&gt;


	&lt;p&gt;Once you have everything running nicely in your buildout environment, you probably want to then deploy it somewhere. Creating consistent environments between systems in buildout&amp;#8217;s main purpose, so how do we do it?
It&amp;#8217;s described in detail in the buildout docs in the section &lt;a href="http://cheeseshop.python.org/pypi/zc.buildout/1.0.0b27#id124"&gt;controlling eggs used&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;The configuration file buildout.cfg can contain sections specifying the versions of packages required. To find out what versions are being used, buildout can be run in verbose mode, using the -v option. Strangely, it seems that you then need to manually write these versions into the config file.&lt;/p&gt;


	&lt;p&gt;Hopefully this simple example will be enough to show the potential of buildout. The complete docs are very thorough and describe all the possible options.&lt;/p&gt;</description>
      <pubDate>Wed, 27 Jun 2007 22:22:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:81dbf791-77d1-4c90-a820-33c4113672ad</guid>
      <author>Graham Stratton</author>
      <link>http://grahamstratton.org/blog/public/articles/2007/06/27/adventures-with-buildout</link>
      <category>Python</category>
      <category>Software development</category>
      <category>Pylons</category>
    </item>
    <item>
      <title>Shared sign-on across web applications</title>
      <description>&lt;p&gt;I&amp;#8217;ve spent the day on what I can only assume is a really common problem with a distinct lack of a solution.&lt;/p&gt;


	&lt;p&gt;We have a number of web applications, some Zope-based and also a Pylons app served using the Paste server.  We are using Apache as a proxy in front of all of them.&lt;/p&gt;


	&lt;p&gt;We&amp;#8217;d like users to be able to sign in to any of those applications and then access any of the others.  To implement their security the applications will need to know what groups the user is a member of.&lt;/p&gt;


	&lt;p&gt;To complicate matters slightly, users need to be authenticated by &lt;span class="caps"&gt;NLTM&lt;/span&gt; if possible, failing that looked up in an &lt;span class="caps"&gt;LDAP&lt;/span&gt; directory, and if that fails verified against a relational database.  For &lt;span class="caps"&gt;NTML&lt;/span&gt; users we&amp;#8217;ll need to get the groups out at some point, presumably from &lt;span class="caps"&gt;LDAP&lt;/span&gt;.&lt;/p&gt;


	&lt;p&gt;Each of the applications will have its own way of keeping track of whether the user is logged in, probably by means of a cookie.&lt;/p&gt;


	&lt;p&gt;I think there are a few potential ways of sharing the sign-on information, given the restrictions of &lt;span class="caps"&gt;HTTP&lt;/span&gt;:&lt;/p&gt;


	&lt;p&gt;1) Something similar to OpenID, maybe actually using the OpenID protocol. Write a server which the web applications redirect to if authorization fails for some request. There are OpenID interfaces for plone and AuthKit.  But there is a question as to whether the OpenID spec would allow returning of the list of groups a user belongs to.&lt;/p&gt;


	&lt;p&gt;2) Have the proxying Apache authenticate users and put this information in the environment.  This would work if we only wanted to protect whole directories.  An Apache module to help with this is mod_auth_tkt, which does rather more.  Unfortunately it still doesn&amp;#8217;t allow you to redirect users when authorization is required.  What is needed is some way of catching a 401, as is done by AuthKit, and providing a sign-on there.&lt;/p&gt;


	&lt;p&gt;What I think mod_auth_tkt does is to hash the username with a secret code and store it in a cookie. The secret code is share between all the applications.  If the browser sends a request claiming to be fred and hashing &amp;#8216;fred&amp;#8217; with the secret code produces the code passed by the browser, the app1 can conclude that app2 successfully authenticated fred and gave him the code.  This is really quite neat and I wouldn&amp;#8217;t have thought of it.&lt;/p&gt;


	&lt;p&gt;3) Use paste.proxy as an extra proxy layer.  This makes it easy to add middleware which will intercept status 401 messages and replace them with a login form.  Since the proxy would not have a session, it would have to use set cookies in the same way as mod_auth_tkt to communicate user verification.&lt;/p&gt;


	&lt;p&gt;The problem is further complicated by external and internal Apache instances. The internal one proxies services mainly used internally, and only accepts requests which come either from machines internally of from the external Apache instance.  The external one proxies the organisational website, and also allows external access to the internal services.&lt;/p&gt;</description>
      <pubDate>Fri, 25 May 2007 16:35:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:5f3ad536-3ff7-453e-9a57-412cd6acc8b8</guid>
      <author>Graham Stratton</author>
      <link>http://grahamstratton.org/blog/public/articles/2007/05/25/shared-sign-on-across-web-applications</link>
    </item>
    <item>
      <title>Functional testing in Pylons, Twill and wsgi_intercept</title>
      <description>&lt;p&gt;When trying to do some functional testing in Pylons, I initially tried Paste&amp;#8217;s solution, which worked a bit, but I got stuck on trying to select multiple options in a select box. So I decided to move over to Twill, which I am already familiar with anyway.&lt;/p&gt;


	&lt;p&gt;In order to use Twill for in-process testing, Titus Brown, the developer of Twill, has provided a cunning module called wsgi_intercept. Yes, there is a clue in the name. wsgi_intercept replaces httplib.HTTPConnection, redirecting specified requests to the wsgi application. Titus has an article on &lt;a href="http://www.advogato.org/article/874.html"&gt;testing with Twill and wsgi_intercept&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;Using the module with Pylons is quite easy.  I created a new project called squirrel, with a controller called nuts. In squirrel/tests/&lt;i&gt;init&lt;/i&gt;.py, I added:&lt;/p&gt;


&lt;pre&gt;
import twill

class TwillTestController(TestCase):

    wsgi_app = loadapp('config:test.ini', relative_to=conf_dir)

    def setUp(self):
        def build_app():
            return self.wsgi_app

        twill.add_wsgi_intercept('localhost', 8080, build_app)

    def tearDown(self):
        twill.remove_wsgi_intercept('localhost', 8080)
&lt;/pre&gt;

	&lt;p&gt;Then I changed squirrel/tests/functional/test_nuts.py to&lt;/p&gt;


&lt;pre&gt;from squirrel.tests import TwillTestController
from twill.commands import *

class TestNutsController(TwillTestController):
    def test_index(self):
        go('http://localhost:8080/')
        find('World')
        notfind('Universe')&lt;/pre&gt;

	&lt;p&gt;And running nosetests works quite nicely for me. &lt;em&gt;Unless&lt;/em&gt;, that is, http_proxy is set, which it is on my work machine. I haven&amp;#8217;t yet traced this problem to see whether it can be fixed or not, though I suspect there won&amp;#8217;t be a simple solution.&lt;/p&gt;</description>
      <pubDate>Sun, 13 May 2007 20:08:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:8fea0a52-bfd8-4bee-9019-6a5d30cdb9dd</guid>
      <author>Graham Stratton</author>
      <link>http://grahamstratton.org/blog/public/articles/2007/05/13/functional-testing-in-pylons-twill-and-wsgi_intercept</link>
      <category>Pylons</category>
    </item>
    <item>
      <title>Setting up Python 2.5 on OS X</title>
      <description>&lt;p&gt;Sadly, this isn&amp;#8217;t quite as simple as it might be.  First, set up /usr/local/src/ to contain the source of the packages to be installed:&lt;/p&gt;


&lt;pre&gt;mkdir /usr/local/src
sudo mkdir /usr/local/src
sudo chgrp admin  /usr/local/src
sudo chmod -R 775 /usr/local/src
cd /usr/local/src&lt;/pre&gt;

	&lt;p&gt;Custom packages are generally installed to /usr/local/, hence /usr/local/src is a sensible place to put the source.&lt;/p&gt;


	&lt;p&gt;Now install readline:&lt;/p&gt;


&lt;pre&gt;url -O ftp://ftp.cwru.edu/pub/bash/readline-5.2.tar.gz
tar -xzvf readline-5.2.tar.gz
cd readline-5.2
./configure --prefix=/usr/local
make
sudo make install
cd ..&lt;/pre&gt;

	&lt;p&gt;One of the exciting new batteries included with Python 2.5 is bindings for Sqlite.  So, we&amp;#8217;d better install that, too:&lt;/p&gt;


&lt;pre&gt;curl -O http://www.sqlite.org/sqlite-3.3.17.tar.gz
./configure --prefix=/usr/local --with-readline-dir=/usr/local
tar xzvf sqlite-3.3.17.tar.gz 
cd sqlite-3.3.17
./configure --prefix=/usr/local --with-readline-dir=/usr/local
make
sudo make install
cd ..&lt;/pre&gt;

	&lt;p&gt;And finally we can actually build Python:&lt;/p&gt;


&lt;pre&gt;wget http://www.python.org/ftp/python/2.5.1/Python-2.5.1.tar.bz2
tar xjvf Python-2.5.1.tar.bz2
cd Python-2.5.1/
./configure --prefix=/usr/local --with-readline-dir=/usr/local --with-sqlite3=/usr/local
make
sudo make install
cd ..&lt;/pre&gt;

	&lt;p&gt;Finally, enable tab completion in the interactive interpreter.  Set ~/.pythonstartup to contain&lt;/p&gt;


&lt;pre&gt;import readline, rlcompleter
readline.parse_and_bind("tab: complete")&lt;/pre&gt;

	&lt;p&gt;and set the environment variable &lt;span class="caps"&gt;PYTHONSTARTUP&lt;/span&gt; to point to this file,for example by adding&lt;/p&gt;


&lt;pre&gt;export PYTHONSTARTUP=~/.pythonstartup&lt;/pre&gt;

	&lt;p&gt;to ~/.bashrc&lt;/p&gt;


	&lt;p&gt;Phew. Now I can actually do something useful! Maybe my next post will be able to contain some more significant substance!&lt;/p&gt;


A quick trick I came across today.  I had code working in the interactive interpreter, but I wanted to copy into an editor.  So I copied the block into TextMate, and needed to strip out the &amp;gt;&amp;gt;&amp;gt;s, the &amp;#8230;s and the output.  Text -&amp;gt; Filter Through Command, setting the command to be 
&lt;pre&gt;egrep "&amp;gt;&amp;gt;&amp;gt;|..." | cut -c5-&lt;/pre&gt; and all sorted. Another instance of a nice blend of &lt;span class="caps"&gt;GUI&lt;/span&gt; and command line in &lt;span class="caps"&gt;OS X&lt;/span&gt;.</description>
      <pubDate>Sun, 13 May 2007 13:47:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:a5dfaee2-c58b-4494-aee9-0946ac31c70f</guid>
      <author>Graham Stratton</author>
      <link>http://grahamstratton.org/blog/public/articles/2007/05/13/setting-up-python-2-5-on-os-x</link>
      <category>Python</category>
      <category>Mac</category>
    </item>
    <item>
      <title>Virtualisation</title>
      <description>&lt;p&gt;Virtualisation is the current big thing, and it&amp;#8217;s easy to see why.  But in many ways it opens up such a flood of possibilities that it&amp;#8217;s hard to understand where to start.  Virtualisation also has interesting implications for hardware and software vendors.&lt;/p&gt;


	&lt;h4&gt;Products&lt;/h4&gt;


	&lt;p&gt;By far the largest player in the virtualisation market is VMware.  Microsoft are clearly not comfortable with this situation, and since their Virtual Server product cannot compete and they will not have anything new until at least 2008, they have &lt;a href="http://www.theregister.co.uk/2006/07/20/ms_xen_love/"&gt;announced&lt;/a&gt; support for VMWare&amp;#8217;s main rival, XenSource, a company built around the Open Source Xen virtualisation platform.&lt;/p&gt;


	&lt;p&gt;The ways that Xen and VMWare work are quite fundamentally different.  VMWare&amp;#8217;s solution requires slightly more overhead, but means that pretty much any x86 OS will run in a VMWare virtual machine, and these virtual machines can be hosted on a variety of other OSes.  Having got a bit of experience with VMWare&amp;#8217;s VMWare Server, (which has become free for download since the increase in competition from the likes of Xen), I have to say that it is very professional and reliable.  Install was straightforward and painless, and downloaded virtual machines just worked as you would hope.&lt;/p&gt;


	&lt;p&gt;Wikipedia has a useful overview of &lt;a href="http://en.wikipedia.org/wiki/Virtualization_Technology"&gt;virtualisation&lt;/a&gt;. As a rough summary, the difficulty in implementing virtualisation is with a small set of instructions which need to be handled differently on a virtual operating system to how they would be on an OS running natively.  VMWare works by replacing these calls with system calls before they are run.  This is responsible for the overhead when using VMWare.&lt;/p&gt;


	&lt;p&gt;Xen requires guest OSes to be modified in advance in order to be able to run, taking out offending instructions replacing them with calls to Xen itself.  This means that to run under Xen, operating systems have to be available for modification (for example open source ones), and have to actually have been modified (often only the most recent version).  This clearly limits Xen&amp;#8217;s potential.&lt;/p&gt;


	&lt;p&gt;However, Intel and &lt;span class="caps"&gt;AMD&lt;/span&gt; have recently added dedicated virtualisation extensions to their chips, in the form of VT-x and &lt;span class="caps"&gt;AMD&lt;/span&gt;-V extensions.  These are similar extensions, and Xen manages to add a single abstration layer above both of them called &lt;span class="caps"&gt;HVM&lt;/span&gt;.  These extensions enable an unmodified OS to be started as a virtual machine, after which the OS will call the hypervisor (the code which runs the virtual machine, eg Xen) whenever a &amp;#8216;problem instruction&amp;#8217; is encountered.  This enables many more operating systems, notably including Windows, to be run, and already compatible OSes to be run without modification.&lt;/p&gt;


	&lt;p&gt;VT-x technology is available in most Intel chips from the Core Duo onwards.  The exception is a few budget and low-power chips.  However, some hardware vendors disable the functionality, particularly in laptops.&lt;/p&gt;


	&lt;h4&gt;Apple and Vistualisation&lt;/h4&gt;


	&lt;p&gt;Apple are doing very well at the moment, and part of that is because since they moved to Intel processors it has been possible to run Windows on Macs.  The means that the &amp;#8216;I like Macs but won&amp;#8217;t buy one in case I need to run some PC software&amp;#8217; crowd were all suddenly potential customers.  But some people need to use Windows applications pretty much continuously, and for them the pain of having to reboot to a different OS for that is still too much.  Along comes virtualisation, and suddenly they can run Windows and &lt;span class="caps"&gt;OSX&lt;/span&gt; simultaneously.  Great.  So now they&amp;#8217;re potential customers.&lt;/p&gt;


	&lt;p&gt;But &lt;span class="caps"&gt;OS X&lt;/span&gt; on Intel is (somehow) restricted to only be able to run on Apple hardware.  And currently this means that you can&amp;#8217;t have an &lt;span class="caps"&gt;OS X&lt;/span&gt; virtual machine, even running on a Mac.  So whilst I can have a few Linux virtual machines lying around for testing different things, I currently can&amp;#8217;t have a second &lt;span class="caps"&gt;OS X&lt;/span&gt; install.  Maybe this is a critical thing, maybe not.  It does seem to limit Apple&amp;#8217;s potential in the server market, though.  Parallels does support Intel&amp;#8217;s VT-x virtualisation extenstion, which enables guest OSes to run with no modification directly on the hardware, but it seems that this still isn&amp;#8217;t enough.&lt;/p&gt;


	&lt;p&gt;I was just browsing the Parallels website, and encountered their new Coherence technology, allowing you to run Windows &amp;#8216;in the background&amp;#8217; with Windows application windows floating around your desktop alongside you Mac apps.  Very cool, if an obvious step on a route to confusion!&lt;/p&gt;


	&lt;h4&gt;Applications of Virtualisation&lt;/h4&gt;


	&lt;p&gt;So, what uses does virtualisation have?  There are a few obvious savings where a number of different OSes need to be run simultaneously, for example for testing.  And it can be useful in order to try out a different OS.  But more interesting is to ask what problems currently exist, and consider whether virtualisation is a good solution.&lt;/p&gt;


	&lt;p&gt;As a web application developer, I spend a surprising amount of my time doing sys admin stuff, and I&amp;#8217;m still far from having a good setup.  I&amp;#8217;d like a more solid backup strategy, and some sort of continual testing.&lt;/p&gt;


	&lt;p&gt;I offer my clients a hosting service, but at the moment if my server fails it will take a few hours of work on my part to get the sites hosted there back up and running (relying on some notes which I will have to pull out of Google&amp;#8217;s cache!).  If I had all of the sites backed up to a virtual machine, I could just copy the virtual machine onto another server and be ready to go.&lt;/p&gt;


	&lt;p&gt;Of course, the obvious next step here is to replace my server with a virtual server which is continually backed up.  This doesn&amp;#8217;t seem to be as popular an option as I was expected.  None of the virtualisation vendors seem to be pushing the ability to do this.  Possibly part of the reason is that even if you have a continual backup of the disk image, you are far from having a continual backup, as writes may be buffered.  If you snapshot a disk image of a running system and run it, the OS will assume that it crashed.  To take a snapshot of a running virtual machine, you have to snapshot the memory as well, which is entirely possible, but means you might have to back up more data (and certainly have more changes in incremental backups) than you might expect.&lt;/p&gt;


	&lt;p&gt;One feature which the Xen guys like to promote is the ability to transfer a virtual machine seamlessly from one host to another.  This is a very nice and useful feature.  The downtime is estimated at about 0.1 seconds, so provided that your network gear switches over quickly enough everything should go unnoticed.  However, this requires a large amount of bandwidth, and therefore having a server continuously in a state where it could instantaneously fail-over is not practical, though maybe mirroring every ten seconds would not be unreasonable within a private network.&lt;/p&gt;


	&lt;h4&gt;Overdoing it?&lt;/h4&gt;


	&lt;p&gt;After first encountering virtualisation, I soon wanted to run everything in a separate machine. Then I began to ask why. Surely most operating systems are perfectly capable of running many separate services, and having a separate install of an operating system and lots of standard packages for one small task seems rather wasteful, particularly of memory (which isn&amp;#8217;t quite free yet, unlike disk space).&lt;/p&gt;


	&lt;p&gt;So, is there a limit?  It does make sense to run each service on a separate machine (say mailserver, webserver, firewall (virtual firewall??)), but what about individual web applications?  Certainly some of my deployed apps require different libraries to others, and it might be handy to be able to upgrade them individually.  But there&amp;#8217;s workingenv to create a completely separate python environment, so only system libraries are an issue.&lt;/p&gt;


	&lt;h4&gt;A few random thoughts&lt;/h4&gt;


	&lt;p&gt;I haven&amp;#8217;t yet seen anyone saying that they can dynamically move memory between systems.  I wonder whether that&amp;#8217;s possible?&lt;/p&gt;


	&lt;h4&gt;End.&lt;/h4&gt;


	&lt;p&gt;This post is getting a bit long, so I think I&amp;#8217;ll return to &amp;#8216;what virtualisation can do for me&amp;#8217; another time.&lt;/p&gt;</description>
      <pubDate>Mon, 09 Apr 2007 15:49:28 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:bcd58a10-f9e1-41c5-9dbb-c5924a277e5e</guid>
      <author>Graham Stratton</author>
      <link>http://grahamstratton.org/blog/public/articles/2007/04/09/virtualisation</link>
    </item>
    <item>
      <title>Backup tools</title>
      <description>&lt;p&gt;I was investigating backing up track when I came across some useful tools. First is backupninja, which allows you to take a backup of lots of different applications such as databases whilst they&amp;#8217;re running.&lt;/p&gt;


	&lt;p&gt;More interesting to me was rdiff-backup, at http://www.nongnu.org/rdiff-backup/
rdiff-backup basically performs an rsync mirroring (it uses librsync), but actually performs an incremental backup allowing you to restore older versions of files, and has some other nice features as well.&lt;/p&gt;</description>
      <pubDate>Thu, 15 Feb 2007 18:37:28 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:3fd283ad-2d89-4534-9362-b927c83ea949</guid>
      <author>Graham Stratton</author>
      <link>http://grahamstratton.org/blog/public/articles/2007/02/15/backup-tools</link>
    </item>
    <item>
      <title>Trac setup</title>
      <description>&lt;p&gt;Just in case I haven&amp;#8217;t already expressed my opinion on this: trac is wonderful. It&amp;#8217;s a simple integration of subversion with an issue tracker and a wiki.  It&amp;#8217;s probably not that difficult to set up by default, but for some reason I chose to use Postgres instead of SQLite, so there&amp;#8217;s a little bit to it.  I covered installing everything elsewhere, so here I&amp;#8217;m just going to describe setting up the database and configuring it all.&lt;/p&gt;


	&lt;p&gt;First we need to create a subversion repository.  This needs to be writable by the user which Apache is running as, probably www-data or similar.&lt;/p&gt;


&lt;pre&gt;sudo svnadmin create /var/svn/hippocms
sudo chown -R www-data /var/svn/hippocms/&lt;/pre&gt;

	&lt;p&gt;Now we need to configure Apache:&lt;/p&gt;


&lt;pre&gt;
  &amp;lt;Location /svn&amp;gt;
    DAV svn
    SVNParentPath /var/svn
    AuthType Basic
    AuthName "Subversion" 
    AuthUserFile /etc/svn-auth
    Require valid-user
  &amp;lt;/Location&amp;gt;
&lt;/pre&gt;

	&lt;p&gt;The SVNParentPath variable makes all the subdirectories of this directory which should be repositories available, but denies access to the directory itself.&lt;/p&gt;


	&lt;p&gt;We&amp;#8217;re only protecting the repository with BasicAuth here; you&amp;#8217;ll need to use https to make this secure.  We need to create the htpasswd file:&lt;/p&gt;


	&lt;p&gt;sudo htpasswd -c /etc/svn-auth graham&lt;/p&gt;


	&lt;p&gt;So now, you should be able to access the repository through the web at http://your.server/svn/hippocms/&lt;/p&gt;


And you should be able to check out its emptyness with 
&lt;pre&gt;svn co http://cambridgewebdevelopment.co.uk/svn/hippocms/&lt;/pre&gt;

	&lt;p&gt;Next we set up the Apache to host trac:&lt;/p&gt;


&lt;pre&gt;
  Alias /trac "/usr/share/trac/htdocs" 

  ScriptAlias /hippocms /usr/share/trac/cgi-bin/trac.cgi
  &amp;lt;Location "/hippocms"&amp;gt;
    SetEnv TRAC_ENV "/var/trac/hippocms" 
    AuthType Basic
    AuthName "hippocms" 
    AuthUserFile /var/trac/hippocms/.htpasswd
    Require valid-user
  &amp;lt;/Location&amp;gt;
&lt;/pre&gt;

And we need to add a user for Apache to authenticate:
&lt;pre&gt;sudo htpasswd -c /var/trac/hippocms/.htpasswd graham&lt;/pre&gt;

	&lt;p&gt;Finally we need to create a database and create a trac user:&lt;/p&gt;


&lt;pre&gt;
sudo su - postgres -c createdb hippocms
sudo su - postgres -c psql hippocms
# create user trac with password 'secret';
&lt;/pre&gt;

	&lt;p&gt;Now we&amp;#8217;re ready to initialise our trac environment:&lt;/p&gt;


&lt;pre&gt;sudo trac-admin /var/trac/hippocms initenv&lt;/pre&gt;

	&lt;p&gt;And everything should Just Work.&lt;/p&gt;</description>
      <pubDate>Thu, 15 Feb 2007 17:39:06 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:226aae1f-0b40-4b90-b632-6799d01a4ea9</guid>
      <author>Graham Stratton</author>
      <link>http://grahamstratton.org/blog/public/articles/2007/02/15/trac-setup</link>
      <category>Software development</category>
    </item>
  </channel>
</rss>
