Blog by Piotr Banaszkiewicz

Python extension and './configure'

Recently I have been working on python-rrdtool Python binding to rrdtool utility.

On PyPI there has already existed py-rrdtool package, but it did not work at all.

It turned out, that rrdtool sources had a nice looking rrdtoolmodule.c, all I needed was to compile it.

Long story short: rrdtoolmodule.c includes a non-existent header, which is created during ./configure run. So I had to figure out how to call ./configure from inside setup.py script.

(You may take a look at actual setup.py instead of reading this blog post.)

from distutils.core import setup, Command
from distutils.command.build_ext import build_ext
...
setup(
    ...
    cmdclass={"build_configure": BuildConfigure, "build_ext": BuildExtension},
    ...
)

In order to run ./configure at specific moment before your module is being built, you have to use distutils command extensions: build_configure and build_ext.

class BuildConfigure(Command):
    def run(self):
        # run `./configure` here, I did it using subprocess module
        ...

BuildConfigure class has to call the configure executable. But this class is not enough, distutils requires special building extension.

class BuildExtension(build_ext):
    def run(self):
        for cmd_name in self.get_sub_commands():
            self.run_command(cmd_name)

        build_ext.run(self)

    sub_commands = [("build_configure", None)] + build_ext.sub_commands

I override run method to explicitly run our commands. In sub_commands list of 2-element tuples, first element stays for command extension, and second for usage circumstances (None == always, function == depending on it’s boolean output).

Note: if you happen to see “permission error” somewhere, make sure that you set chmods for configure executable:

os.chmod(executable, 0777)

Thing about Vagrant, VirtualBox and lack of hardware virtualization

If you don’t have a very modern computer with CPU supporting hardware virtualization, like me, and you want to use Vagrant, you’ll likely have lots of issues.

TL;DR: you’d better buy a new PC. Hardware virtualization is a must-have nowadays.

In case you don’t want to buy it, here’s some issues I had with Vagrant and how I fixed them.

VM can’t be started (even through VirtualBox GUI) due to “VT-x is not available”.

Solution: In this GUI select VM → Settings → System → Acceleration, then uncheck everything.


Acceleration tab is not active.

Solution: Go to the directory containing your VirtualBox VMs, then to your VM’s directory, then edit *.vbox XML file. Within <CPU> tag children (like <HardwareVirtEx> or <PAE>), replace every enabled="true" with enabled="false".


I can do that all with Vagrantfile and do not need to change my *.vbox config!

Solution: Even though you can turn hardware virtualization off via Vagrantfile (config.vm.customize ["modifyvm", :id, "--hwvirtex", "off"]), it might not work. At least it didn’t in my case. If it does the same for you, go and change your *.vbox XML file.


Still not working. What can be wrong?

Solution: Check if number of CPUs for your Vagrant virtual machine is greater than 1. If so, go and change the count of CPUs in your *.vbox file to one. (Yes, you could do it from Vagrantfile, but it may not work. It did not in my case.)

GSOC 2012

Google Summer of Code 2012 has begun and I’m one of participants. I have to admit, I was thrilled when I found out.

My project is to bring metrics (like CPU, RAM, disk, net usage), alerts and graphs to the cool Ganeti Web Manager by Oregon State University Open Source Lab.

For metrics collection I decided to use collectd daemon. It’ll be backed up by my soon-to-be-born collectd-ganeti plugin.

Collectd will be installed on the host (Ganeti node), and this plugin will gather usage information from KVM (and later Xen). This way there’s no need to install collectd on every virtual machine Ganeti creates.

Next to collectd, I’m going to create a some kind of network daemon, which will monitor and send metrics data to GWM. For now I created something very pre-alpha – no—one should use it.

Following weeks are going to be very important to me. Not only will I get my final exams results, but also there will take place university admission. And Google seems to want job—interview with me.