Commit 077c2773 authored by tbrehm's avatar tbrehm

Added functions to manage OpenVZ virtual machines to the remote API.

Added a example file for adding a VM with the remote API
parent 5d5d88ee
This diff is collapsed.
......@@ -140,13 +140,14 @@ class vm_openvz_plugin {
private function makeOpenVZConfig() {
global $app, $conf;
$vm = $app->tform->getDataRecord($this->id);
$vm = $app->db->queryOneRecord("SELECT * FROM openvz_vm WHERE vm_id = ".$this->id);
$vm_template = $app->db->queryOneRecord("SELECT * FROM openvz_template WHERE template_id = ".$vm['template_id']);
$burst_ram = $vm['ram_burst']*256;
$guar_ram = $vm['ram']*256;
$app->load('tpl');
$tpl = new tpl();
$tpl->newTemplate('templates/openvz.conf.tpl');
$tpl->newTemplate('../vm/templates/openvz.conf.tpl');
$onboot = ($vm['start_boot'] == 'y')?'yes':'no';
$tpl->setVar('onboot',$onboot);
......@@ -205,7 +206,7 @@ class vm_openvz_plugin {
private function createDNS() {
global $app, $conf;
$vm = $app->tform->getDataRecord($this->id);
$vm = $app->db->queryOneRecord("SELECT * FROM openvz_vm WHERE vm_id = ".$this->id);
if($vm['create_dns'] != 'y') return;
......
......@@ -72,6 +72,7 @@ $function_list['dns_rp_get,dns_rp_add,dns_rp_update,dns_rp_delete'] = 'DNS rp fu
$function_list['dns_srv_get,dns_srv_add,dns_srv_update,dns_srv_delete'] = 'DNS srv functions';
$function_list['dns_txt_get,dns_txt_add,dns_txt_update,dns_txt_delete'] = 'DNS txt functions';
$function_list['domains_domain_get,domains_domain_add,domains_domain_delete,domains_get_all_by_user'] = 'Domaintool functions';
$function_list['vm_openvz'] = 'OpenVZ VM functions';
$form["title"] = "Remote user";
$form["description"] = "";
......
......@@ -43,6 +43,7 @@ ORIGIN_SAMPLE="vps.basic"
HOSTNAME="{tmpl_var name='hostname'}"
IP_ADDRESS="{tmpl_var name='ip_address'}"
NAMESERVER="{tmpl_var name='nameserver'}"
MEMINFO="pages:256000"
# alternative meminfo: "pages:256000"
MEMINFO="privvmpages:1"
CAPABILITY="{tmpl_var name='capability'}"
<?php
$username = 'admin';
$password = 'admin';
$soap_location = 'http://localhost:8080/remote/index.php';
$soap_uri = 'http://localhost:8080/remote/';
$client = new SoapClient(null, array('location' => $soap_location,
'uri' => $soap_uri,
'trace' => 1,
'exceptions' => 1));
try {
if($session_id = $client->login($username,$password)) {
echo 'Logged successfull. Session ID:'.$session_id.'<br />';
}
//* Prams are optional for this function. If params are set,
//* then they override the template settings.
$params = array();
//* Set the function parameters.
$client_id = 0;
$ostemplate_id = 1;
$template_id = 1;
$vm_id = $client->openvz_vm_add_from_template($session_id, $client_id, $ostemplate_id, $template_id, $params);
if($client->logout($session_id)) {
echo 'Logged out.<br />';
}
} catch (SoapFault $e) {
echo $client->__getLastResponse();
die('SOAP Error: '.$e->getMessage());
}
?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment