Back then at #nlcX final round, which was held at the same place as the NSC competition. (National software competition) I plan to enter the next NSC competition so I take a look around for some project idea.
First, I got my own highly innovative idea from my Twitter timeline, I saw a tweet and got a really cool idea about game that runs on Palm webOS. This is very hard to create as I have to learn many new technology and how I can create that game in short time. But when NSC result announced I, standing next to the stage sweared that next year I will do a control panel for @whsgroup. (The winner in student software category is web hosting control from iberrystudio, congrats!)
Why I announce it so loud without fearing other will copy it? Because I have a year of OpenVZ experience and setup on hand. From what I saw OpenVZ is not easy to learn and it’s slightly complicated I don’t think anyone else can make a paravirtualization control panel in time for the contest.
Now on to the story, I have been coding OvzCP for a week now and the basic feature is almost complete except of creating and destroying the virtual machine. The blurry screenshot can be see at the front page of whsgroup.ath.cx (that’s the creation page)
One of the feature of OvzCP is automated Varnish control. Back then, whsgroup.ath.cx’s varnish (reverse proxy) use my hand-written configuration. I use complicated regular expression (like ^(t|os|whs).whsgroup.ath.cx$ because I’m lazy to write many elseifs. Now, OvzCP have come to automated my configuration.
Porting my old configuration is painless. I don’t use many varnish feature such as caching (as this is both development and production environment) so I just write a importer like this:
from models import *
for i in openvz.listVM():
if not VM.select(VM.q.veid == i.veid).count():
owner = “email@example.com”
if i.veid == 105:
owner = None
vm = VM.select()
whs=VarnishBackend(name=”whs”, port=80, vm=vm)
glo=VarnishBackend(name=”global”, port=80, vm=vm)
VarnishCond(hostname=”whsgroup.ath.cx”, subdomain=False, varnishBackend=glo)
(Varnish have backend definition, and vcl_recv condition. OvzCP frontend doesn’t display backend configuration but merge both backend and condition in one easy to configure display while never make duplicate or orphan backend)
Then just run that file. Now my old configuration got imported in. Then I will order OvzCP to regenerate varnish configuration by running varnish.py. It will restart varnish automatically.
I think OvzCP’s API is quite easy to learn but the code isn’t. Currently it’s about 650 lines of Python code and some shell script (for port forwarding) sloccount estimated that I have done 1.5 person-month already. (Note that I don’t use don’t repeat yourself philosophy and copy-pasting whenever I feel suitable)
OvzCP probably be open-sourced during the NSC competition. I hope to finish writing it by the next month. Of course, since I use every project I created I will see many issue while using my software and I will always improve it.
**PS.** I think I really need a new theme for my blog!