Category: Code

Hudson and VMBuilder

Unhappy with the current state of VMBuilder, I recently decided to take a look at Hudson, hoping it can help improve quality going forward. Hudson is a “continuous integration” tool. This means that it’s a tool you use to apply quality control continuously rather than only either when you’re feeling bored or when a release is imminent.

I’ve set up Hudson with a number of jobs:

  • One monitors the the VMBuilder trunk bzr branch. Whenever something changes there, it downloads it, runs pylint on it, runs the unit tests (pylint and unit tests setup with help from a blog post by Joe Heck), and rolls a tarball. Finally it triggers the next job..
  • ..which builds an Ubuntu source package out of it, and triggers the next job..
  • ..which signs and uploads it to the VMBuilder PPA that I recently blogged about..
  • Last, but certainly not least, I’ve set up the very first completely automated, end to end VMBuilder test. It grabs the freshest tarball from Hudson, copies it to a reasonably beefy server, builds a VM, boots it up and upon succesful boot, it reports back that it all worked, and Hudson is happy. It doesn’t exercise all the various plugins of VMBuilder (not even close), but it’s a start!

VMBuilder in Lucid == lots of fail

Let it be no secret that I’m unhappy with the state of VMBuilder in Lucid (and in general for that matter). Way too many regressions crept in and I didn’t have time to fix them all. I still expect to do an SRU for all of this, but every time I try to attack the bureaucracy involved in this, I fail. I need to find a few consecutive hours to throw at this very soon.

Anyways, in an effort to make testing easier, I’ve set up a PPA for VMBuilder.

I’ve set up a cloud server that monitors the VMBuilder trunk bzr branch. If there’s been a new commit, it rolls a tarball, builds a source package out of it, and uploads it to that ppa. That way, adventurous users can grab packages from there and test things out before they go into an SRU. To do this, you simply run this command:

sudo add-apt-repository ppa:vmbuilder/daily

I’m also working on a setup that will automatically test these packages. The idea is to fire up another cloud server, make it install a fresh VMBuilder from that ppa, perform a bunch of tests and report back. To do this, I’m injecting an upstart job into the instance that

  1. adds the ppa,
  2. installs vmbuilder,
  3. builds a VM, which (using the firstboot option) will call back into the host when it has booted succesfully,
  4. sets up a listener waiting for this callback,
  5. waits for set amount of time for this callback.

If I get a response in a timely manner, I assume all is well. If not, it’ll notify me somehow.

The idea is to make it run a whole bunch of builds to attempt to exercise as much of the code base as possible.

I’ll try to make a habit of blogging about the progress on this as I know a lot of people are aggravated by the current state of affairs and this way, they can see that something is happening.

Switching to Wordpress

For years now, my blog has been powered by my own blogging engine. I wrote my own because I wanted to not have to run PHP on my web server, and it was a handy way to get familiar with Django. However, I now work for a company that, among many other things, offers web hosting, so it seems like a good idea to be dogfooding that, and having one less spare time project to work on is always a win. On top of that, Wordpress seems like a pretty awesome system with an extensive ecosystem of plugins, a stack of client applications, etc. This post, for instance was written almost entirely on my phone in the wicked cool Wordpress application for Android.

Django upload_to trickery

I’ve recently discovered Django and have used it for all my web development projects ever since. If you’re doing web development in Python do yourself a favour and check it out.

I’ve just spent too many hours figuring out a way to make Django store an uploaded image in a directory depending on another field of the model, but I finally made it work and I figured I’d share it with the world. It may not be pretty, but it makes sense to me.

Well, it all boils down to overriding the save() method. Like so:

class Illustration(models.Model):
    item = models.ForeignKeyField(Item)
    image = models.ImageField(upload_to='images/incoming')

    def save(self):
        for f in self._meta.fields:
            if f.attname == 'image':
                f.upload_to = 'images/items/%d/' % self.item.id

        super(Illustration, self).save()

If anyone should care, I need it for a new website for my girlfriend. The current one can be seen here for a few days until I make the transition to this new Django-powered one.

Linux2Go is Digg proof thanks to caching by WP Super Cache