Knowledgebase

OpenVZ API?

Posted by DHD-Chris, 06-14-2009, 12:24 PM
I was looking into controlling a few of the features of OpenVZ through a web based interface, I know PHP currently but that's about it. Would anybody be able to give me a few pointers? Thanks in advance

Posted by @Matt, 06-14-2009, 12:57 PM
I could be wrong but I don't think OpenVZ has an actual api. You would basically need to code a script that would connect with your server. You would than need to define some variables and just execute the normal openvz commands. Example: Lets say we wanted to stop a container. Just simply define a variable for container will call it "Container" Than write the command to run vzctl stop container. This is just a very rough example and i'm sure their is many other ways to do something similar to this.

Posted by DHD-Chris, 06-14-2009, 01:10 PM
My thoughts too actually, it is mainly things like how I would parse these kind of things for example, vzlist would show the list of VPS's and their VEID's but then how would I go about converting these kind of things to be echoed as HTML and such. I am taking a guess I would need to use something like perl too, any kind of hints would be great!

Posted by bhavicp, 06-16-2009, 02:34 AM
No you wouldn't need perl, Something like Then a simple echo of $vms would display it all, Then you would have to filter it and just get the things you want. Although i don't think there is a vzctl list. (or actually any sort of such command in vzctl)

Posted by RavC, 06-16-2009, 02:45 AM
How about PHP bindings for libvirt? http://phplibvirt.cybersales.cz/ Supposedly alpha, I have not used it (I don't have much experience with PHP anyhow). But libvirt itself is quite robust

Posted by HivelocityDD, 06-16-2009, 08:59 AM
If you are able to run these commands from shell you can try exec() function of php to execute the command.

Posted by DHD-Chris, 06-28-2009, 12:39 PM
How do the pro's do this kind of things, I know they run some kind of service but like what language do they use, how do they link them togther?

Posted by luki, 06-28-2009, 03:47 PM
You can use any programming language you like to execute vz management commands, however, the concern is security. Typically your web server will not run with root privileges required to manage VPSs. You can work around that with sudo or a privileged daemon/unprivileged client, but be sure you really understand what you are doing or you will be rooted.

Posted by DHD-Chris, 06-29-2009, 04:58 AM
I was wondering how do most of these big panels like HyperVM communicate, I know that they use some PHP coding but how do they get PHP to run particular parts of the programs and do things like interacting with services.

Posted by mwatkins, 06-29-2009, 01:02 PM
A two-part solution... a smaller "core" that has to run with escalated privileges is accessible to the front end (and likely some scripts) via some sort of remote procedure call mechanism which could be anything from XMLRPC or Soap (ugh) to json requests to corba (ugh) and so on. The client doesn't run with escalated privs. Secure communication between client and core is obviously a must.

Posted by DHD-Chris, 06-30-2009, 05:37 PM
Thanks mrwatkins that kinda pushed me a little further. Does anyone know how I would call a script to run using these kind of methods. Which method would you say companies like HyperVM and Plesk use?



Was this answer helpful?

Add to Favourites Add to Favourites

Print this Article Print this Article

Also Read
Lowest Hosting Down??? (Views: 663)


Language:

Client Login

Email

Password

Remember Me

Search