OvzCP#1: Introduction

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.

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 *
import openvz
for i in openvz.listVM():
if not VM.select(VM.q.veid == i.veid).count():
owner = “manatsawin@gmail.com”
if i.veid == 105:
owner = None
VM(veid=i.veid, owner=owner)
vm = VM.select()
whs=VarnishBackend(name=”whs”, port=80, vm=vm[1])
glo=VarnishBackend(name=”global”, port=80, vm=vm[0])
VarnishCond(hostname=”whs.whsgroup.ath.cx”, varnishBackend=whs)
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!

#nlcX Final round

Hello readers, I didin’t update this blog for very long time so I cleaned up the backend by removing unused modules, remove features and remove the comment system so I can write little more evil story >)

@jingjingmaple requested me to write blog about #nlcX which is the 10th Thai national Linux competition. Now enjoy.

I was very excited for the last round of #nlcX since I didn’t see my competitor in the second round.

Hello readers, I didin’t update this blog for very long time so I cleaned up the backend by removing unused modules, remove features and remove the comment system so I can write little more evil story >)

@jingjingmaple requested me to write blog about #nlcX which is the 10th Thai national Linux competition. Now enjoy.

I was very excited for the last round of #nlcX since I didn’t see my competitor in the second round. I expect that there must be a tough competitor so the night before the first day, I spent 1 hours with the WebAdminTools.

Here’s the rule of the game:

* **Jigsaw:** 8×8 tile. The first person that hit the button in each round can open up a tile. Once the point for that question reduced to 1 the referee allow 2-5 tiles to be open. If you got only the category clue and guess it correctly, you got 10 points *(this only happened in the client competition for the picture of Linus Torvalds with Windows 7 and young @MrChoke)* but if you open a tile and answered correctly you got 5 points. 2 tiles open for 4 points and so on until 5 tiles or more open then you will get 1 point. If you answer it incorrectly or didn’t answer, you got -1 point.
* **Property:** 5 properties. The first person that hit the button in each round can open a property. The scoring method is like jigsaw question. Once 5 properties are opened but the one who open the last property cannot answer correctly, everyone receive -1 points. *(Happened once)*
* **Hands-on:** Do as the question say in computer in front of you then hit the button. The first one who can do it correctly got 2 points. Note that in the server competition since I answered most of questions the referee decided to give the second person 1 points. In client competition there’s multiplier which someone from the referee or the crowd will pick a ping-pong ball with number written on it such as 5. The score of that question would be multiplied by 5 to get 10 points for that question.

At the first day, the game is boring. Jigsaw picture leeching everyone’s points (incl. me) and property question have only one block that narrow you, the rest is like “Open source software” “GPL license”

But there still a hands-on quiz which I got many of point from these questions. At the end of first day, I got 21 points. Other competitor have less than 10 points and many have minus point.

On the second day, hands-on quiz is lot more harder and LinuxSIS is now involved. I do many task by “hacks” such as editing /etc/hosts (LinuxSIS use bind, which doesn’t read /etc/hosts unlike dnsmasq which I prefer)

One of the property question on the second day have this attribute “product of NSC” which I can’t think of any except mine project. It ends out as NSC is misspelling and in fact it’s ISC. When all 5 attributes are uncovered, the person at number 5 answered bind and got the point, even the question is wrong.

Another annoying question is a jigsaw picture which I can’t remember which one. Someone opened up a 3rd tile (2 point left) and I know what it is. A girl (and the only girl) managed to hit the button before me and opened up another tile (1 point left) which made the guy that opened the 3rd tile know what it is and he got the point.

At the last day, I find out that advanced competition question isn’t hard at all and I can answered most question (while some LinuxSIS questions are related to LinuxSIS which I don’t have knowledge in) and I got the 1st price in this competition and 15k baht.

I planned that my 15k this time will go to Palm for a Palm Pre Plus GSM (not released yet) and probably a Touchstone dock but I feel I can’t wait anymore and might grab a GSM Pre.

**Bonus**: [Codejom!](http://codejom.thailandoi.org)

In the second day, I’m lucky that #nlcX server round is in the morning so I can watch #codejom. Codejom is much like Google Code Jam: You got a question from the server and a test case. You do anything to solve that test case and return the result to server. (Note that I wrote “do anything” because the server only needs correct answer so you can use any programming language or even OpenOffice.org Calc)

Codejom competition is quite fun. The competitors are “floating” in water, displayed on large projectors. When they done a question, their username will float up by one rank and when new question is released every one of them will be submerged by one rank. At the almost the end of the game many teams stuck at the bottom of screen (submerged by have 10 undone questions in stack)