OvzCP#3: OpenVZ API

One of my design goal for OvzCP is to write a OpenVZ abstraction API but not a complete abstraction, just only what OvzCP use.

When I think about getting a number (such as memory available) from OpenVZ, an idea poped in my mind about using getter/setter so I modelled the API that way.

This is how you would get and set current disk space in OvzCP’s API.

import openvz

vm=openvz.VM(101)
print vm.diskinfo # return [total, used, free]

vm.diskinfo = 1024 * 1000 # Set available VM space to 1GB

(Note: currently getter/setter aren’t cached but seems that OvzCP’s f

One of my design goal for OvzCP is to write a OpenVZ abstraction API but not a complete abstraction, just only what OvzCP use.

When I think about getting a number (such as memory available) from OpenVZ, an idea poped in my mind about using getter/setter so I modelled the API that way.

This is how you would get and set current disk space in OvzCP’s API.

import openvz

vm=openvz.VM(101)
print vm.diskinfo # return [total, used, free]

vm.diskinfo = 1024 * 1000 # Set available VM space to 1GB

(Note: currently getter/setter aren’t cached but seems that OvzCP’s first page is served about 60 req/s according to Apache benchmark)