Commit 29187a90 authored by Cédric's avatar Cédric

adding networks feature

parent 5ef71d41
...@@ -15,7 +15,8 @@ This application is an Add-ons for ISPConfig used for VPS Management (Proxmox) ...@@ -15,7 +15,8 @@ This application is an Add-ons for ISPConfig used for VPS Management (Proxmox)
- Shutdown - Shutdown
- Reset - Reset
- Hard Stop (unplug the power) - Hard Stop (unplug the power)
- Change network states (enable / disable)
- Display : - Display :
- Power status - Power status
- Uptime - Uptime
...@@ -37,6 +38,8 @@ This application is an Add-ons for ISPConfig used for VPS Management (Proxmox) ...@@ -37,6 +38,8 @@ This application is an Add-ons for ISPConfig used for VPS Management (Proxmox)
<img src="/misc/admin_vue_1.png" width="400px"> <img src="/misc/graph_vue_1.png" width="400px"> <img src="/misc/admin_vue_1.png" width="400px"> <img src="/misc/graph_vue_1.png" width="400px">
<img src="/misc/admin_task_history.png" width="400px">
## How To implement this module ## How To implement this module
- Create Proxmox user for ISPConfig communication with PVEVMUser right - Create Proxmox user for ISPConfig communication with PVEVMUser right
- Assign VMs to this user - Assign VMs to this user
...@@ -46,6 +49,7 @@ This application is an Add-ons for ISPConfig used for VPS Management (Proxmox) ...@@ -46,6 +49,7 @@ This application is an Add-ons for ISPConfig used for VPS Management (Proxmox)
- $conf["pve_password"] = 'password'; - $conf["pve_password"] = 'password';
- $conf["pve_link"] = 'hostname / ip of your cluster head'; - $conf["pve_link"] = 'hostname / ip of your cluster head';
- $conf["pve_realm"] = 'realm'; - $conf["pve_realm"] = 'realm';
- Please do not use your Proxmox root user !
- Create MySQL table for this module -> misc/vm_proxmox.sql - Create MySQL table for this module -> misc/vm_proxmox.sql
- If you are on multi-servers setup you have to do this on each server - If you are on multi-servers setup you have to do this on each server
...@@ -53,7 +57,6 @@ This application is an Add-ons for ISPConfig used for VPS Management (Proxmox) ...@@ -53,7 +57,6 @@ This application is an Add-ons for ISPConfig used for VPS Management (Proxmox)
## ToDo ## ToDo
- Admin function : - Admin function :
- Snapshot (add / remove) - Snapshot (add / remove)
- Networks : Enable / Disable
- Display: - Display:
- Vps console integration (stuck for the moment ... :( ) - Vps console integration (stuck for the moment ... :( )
......
<?php
/*
Copyright (c) 2016, Gody - ORM
All rights reserved.
*/
require_once '../../lib/config.inc.php';
require_once '../../lib/app.inc.php';
include './lib/pve2_api.class.php'; // maybe we can move this class to another location?
/******************************************
* Begin Form configuration
******************************************/
$list_def_file = "list/proxmox_vm.list.php";
/******************************************
* End Form configuration
******************************************/
//* Check permissions for module
$app->auth->check_module_permissions('proxmox');
$prox_id = $app->functions->intval($_REQUEST['id']);
if($_POST && !empty($prox_id))
{
// Verify assignation VM
if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid']))
{
$client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
$vm = $app->db->queryOneRecord("SELECT vm_containers, vm_id FROM proxmox_vm WHERE id = $prox_id AND sys_groupid = $client_group_id");
}
else
{
$vm = $app->db->queryOneRecord("SELECT vm_containers, vm_id FROM proxmox_vm WHERE id = $prox_id");
}
$vm_containers = $vm['vm_containers'];
$vm_id = $app->functions->intval($vm['vm_id']);
if(isset($vm_id) && isset($vm_containers))
{
$pve2 = new PVE2_API($conf["pve_link"], $conf["pve_username"], $conf["pve_realm"], $conf["pve_password"]);
if ($pve2) {
if ($pve2->login()) {
$vm_temp = $pve2->get("/cluster/resources");
$key = array_search($vm_id, array_column( $vm_temp , 'vmid'));
$vm_pvesvr = $vm_temp[$key]['node'];
// Get VM configurations
$vm_config = $pve2->get("/nodes/{$vm_pvesvr}/{$vm_containers}/{$vm_id}/config");
$vm_interface = $vm_config[$_REQUEST['interface']];
$interface_settings = explode(',', $vm_config[$_REQUEST['interface']] );
if( ($key = array_search('link_down=1',$interface_settings)) !== false )
{
unset($interface_settings[$key]);
}
else
{
$interface_settings[] = 'link_down=1';
}
/*
* Post new network vm configuration
* For change VM configurations your Proxmox user need VM.Config.Network right (PVEVMAdmin vs PVEVMUser)
*/
$vm_interface = array($_REQUEST['interface'] => implode(",", $interface_settings));
$vm_config = $pve2->post("/nodes/{$vm_pvesvr}/{$vm_containers}/{$vm_id}/config", $vm_interface );
// TODO : return to vm information with succes or error message
// echo (!empty( $vm_config ) ? 'Ok' : 'NOK' );
} else {
echo "Login to Proxmox Host failed.\n";
exit;
}
} else {
echo "Could not create PVE2_API object.\n";
exit;
}
}
}
$app->uses('listform_actions');
$app->listform_actions->onLoad();
?>
<?php <?php
/*
Copyright (c) 2016, Gody - ORM
All rights reserved.
*/
require_once '../../lib/config.inc.php'; require_once '../../lib/config.inc.php';
require_once '../../lib/app.inc.php'; require_once '../../lib/app.inc.php';
...@@ -14,11 +18,10 @@ $vm_pvesvr = $_REQUEST['vm_pvesvr']; ...@@ -14,11 +18,10 @@ $vm_pvesvr = $_REQUEST['vm_pvesvr'];
if($_POST) if($_POST)
{ {
// Vrification Apartenance VM (user vs admin) // Verify assignation VM
$client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid']))
{ {
$client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
$vm = $app->db->queryOneRecord("SELECT vm_containers, vm_id FROM proxmox_vm WHERE id = $prox_id AND sys_groupid = $client_group_id"); $vm = $app->db->queryOneRecord("SELECT vm_containers, vm_id FROM proxmox_vm WHERE id = $prox_id AND sys_groupid = $client_group_id");
} }
else else
...@@ -29,7 +32,6 @@ if($_POST) ...@@ -29,7 +32,6 @@ if($_POST)
$vm_containers = $vm['vm_containers']; $vm_containers = $vm['vm_containers'];
$vm_id = $app->functions->intval($vm['vm_id']); $vm_id = $app->functions->intval($vm['vm_id']);
if(isset($vm_pvesvr) && isset($vm_id) && isset($vm_containers)) if(isset($vm_pvesvr) && isset($vm_id) && isset($vm_containers))
{ {
$pve2 = new PVE2_API($conf["pve_link"], $conf["pve_username"], $conf["pve_realm"], $conf["pve_password"]); $pve2 = new PVE2_API($conf["pve_link"], $conf["pve_username"], $conf["pve_realm"], $conf["pve_password"]);
...@@ -97,5 +99,4 @@ if($_POST) ...@@ -97,5 +99,4 @@ if($_POST)
} }
} }
?> ?>
...@@ -59,6 +59,7 @@ $form["tabs"]['informations'] = array ( ...@@ -59,6 +59,7 @@ $form["tabs"]['informations'] = array (
'title' => "Informations", // Need to translate with variable 'title' => "Informations", // Need to translate with variable
'width' => 100, 'width' => 100,
'template' => "templates/proxmox_vm_informations.htm", 'template' => "templates/proxmox_vm_informations.htm",
'readonly' => true,
'fields' => array ( 'fields' => array (
//################################# //#################################
// Begin Datatable fields // Begin Datatable fields
...@@ -85,57 +86,7 @@ $form["tabs"]['graphics'] = array ( ...@@ -85,57 +86,7 @@ $form["tabs"]['graphics'] = array (
'title' => "Graphics", // Need to translate with variable 'title' => "Graphics", // Need to translate with variable
'width' => 100, 'width' => 100,
'template' => "templates/proxmox_vm_graphiques.htm", 'template' => "templates/proxmox_vm_graphiques.htm",
'readonly' => false, 'readonly' => true,
/*
'fields' => array (
//#################################
// Begin Datatable fields
//#################################
'id' => array (
'datatype' => 'INTEGER',
'formtype' => 'TEXT',
'default' => '',
'value' => '',
'separator' => '',
'width' => '30',
'maxlength' => '255',
'rows' => '',
'cols' => '',
'searchable' => 2
),
//#################################
// ENDE Datatable fields
//#################################
)*/
); );
$form["tabs"]['networks'] = array (
'title' => "Networks", // Need to translate with variable
'width' => 100,
'template' => "templates/proxmox_vm_networks.htm",
'readonly' => false,
/*
'fields' => array (
//#################################
// Begin Datatable fields
//#################################
'id' => array (
'datatype' => 'INTEGER',
'formtype' => 'TEXT',
'default' => '',
'value' => '',
'separator' => '',
'width' => '30',
'maxlength' => '255',
'rows' => '',
'cols' => '',
'searchable' => 2
),
//#################################
// ENDE Datatable fields
//#################################
)*/
);
?> ?>
...@@ -41,9 +41,14 @@ $wb["vm_confirm_kill"] = 'Stopper la machine virtuelle ?'; ...@@ -41,9 +41,14 @@ $wb["vm_confirm_kill"] = 'Stopper la machine virtuelle ?';
$wb["vm_confirm_shutdown"] = 'Arreter la machine virtuelle ?'; $wb["vm_confirm_shutdown"] = 'Arreter la machine virtuelle ?';
$wb["vm_select_timeframe_txt"] = 'Merci de choisir une période' ; $wb["vm_select_timeframe_txt"] = 'Merci de choisir une période' ;
$wb["vm_interface_txt"] = 'Interface'; $wb["vm_interface_txt"] = 'Interface';
$wb["vm_bridge_txt"] = 'Mode'; $wb["vm_bridge_txt"] = 'Bridge Name';
$wb["vm_rate_txt"] = 'Limitation (Mb/s)'; $wb["vm_rate_txt"] = 'Max rate (Mb/s)';
$wb["vm_tag_txt"] = 'Vlan'; $wb["vm_tag_txt"] = 'Vlan';
$wb["vm_link_txt"] = 'Désactivé'; $wb["vm_disconnect_txt"] = 'Désactivé';
$wb["vm_mac_txt"] = 'Adresse mac';
$wb["vm_mode_txt"] = 'Mode';
$wb["vm_model_txt"] = 'Model';
$wb["vm_firewall_txt"] = 'Firewall';
$wb["vm_queues_txt"] = 'Multiqueues';
?> ?>
<?php <?php
$wb["id_txt"] = 'id';
$wb["_csrf_id_txt"] = '_csrf_id'; $wb["_csrf_id_txt"] = '_csrf_id';
$wb["_csrf_key_txt"] = '_csrf_key'; $wb["_csrf_key_txt"] = '_csrf_key';
$wb["proxy_directives_txt"] = 'proxy_directives'; $wb["proxy_directives_txt"] = 'proxy_directives';
...@@ -39,10 +39,15 @@ $wb["vm_max_year"] = 'Year (max)'; ...@@ -39,10 +39,15 @@ $wb["vm_max_year"] = 'Year (max)';
$wb["vm_confirm_reset"] = 'Reset the virtual machine ?'; $wb["vm_confirm_reset"] = 'Reset the virtual machine ?';
$wb["vm_confirm_kill"] = 'Kill the virtual machine ?'; $wb["vm_confirm_kill"] = 'Kill the virtual machine ?';
$wb["vm_confirm_shutdown"] = 'Shutdown the virtual machine ?'; $wb["vm_confirm_shutdown"] = 'Shutdown the virtual machine ?';
$wb["vm_select_timeframe_txt"] = 'Choose a timeframe please' ; $wb["vm_select_timeframe_txt"] = 'Choose a timeframe please';
$wb["vm_interface_txt"] = 'Interface'; $wb["vm_interface_txt"] = 'Interface';
$wb["vm_bridge_txt"] = 'Mode'; $wb["vm_bridge_txt"] = 'Bride name';
$wb["vm_rate_txt"] = 'Rate (Mb/s)'; $wb["vm_rate_txt"] = 'Max rate (Mb/s)';
$wb["vm_tag_txt"] = 'Vlan'; $wb["vm_tag_txt"] = 'Vlan';
$wb["vm_link_txt"] = 'Disable'; $wb["vm_disconnect_txt"] = 'Disabled';
$wb["vm_mac_txt"] = 'Mac Address';
$wb["vm_mode_txt"] = 'Mode';
$wb["vm_model_txt"] = 'Model';
$wb["vm_firewall_txt"] = 'Firewall';
$wb["vm_queues_txt"] = 'Multiqueues';
?> ?>
...@@ -41,9 +41,13 @@ $wb["vm_confirm_kill"] = 'Stopper la machine virtuelle ?'; ...@@ -41,9 +41,13 @@ $wb["vm_confirm_kill"] = 'Stopper la machine virtuelle ?';
$wb["vm_confirm_shutdown"] = 'Arreter la machine virtuelle ?'; $wb["vm_confirm_shutdown"] = 'Arreter la machine virtuelle ?';
$wb["vm_select_timeframe_txt"] = 'Merci de choisir une période' ; $wb["vm_select_timeframe_txt"] = 'Merci de choisir une période' ;
$wb["vm_interface_txt"] = 'Interface'; $wb["vm_interface_txt"] = 'Interface';
$wb["vm_bridge_txt"] = 'Mode'; $wb["vm_bridge_txt"] = 'Bridge name';
$wb["vm_rate_txt"] = 'Limitation (Mb/s)'; $wb["vm_rate_txt"] = 'Max rate (Mb/s)';
$wb["vm_tag_txt"] = 'Vlan'; $wb["vm_tag_txt"] = 'Vlan';
$wb["vm_link_txt"] = 'Désactivé'; $wb["vm_disconnect_txt"] = 'Désactivé';
$wb["vm_mac_txt"] = 'Adresse mac';
$wb["vm_mode_txt"] = 'Mode';
$wb["vm_model_txt"] = 'Model';
$wb["vm_firewall_txt"] = 'Firewall';
$wb["vm_queues_txt"] = 'Multiqueues';
?> ?>
misc/admin_vue_1.png

28.8 KB | W: | H:

misc/admin_vue_1.png

42.2 KB | W: | H:

misc/admin_vue_1.png
misc/admin_vue_1.png
misc/admin_vue_1.png
misc/admin_vue_1.png
  • 2-up
  • Swipe
  • Onion skin
misc/graph_vue_1.png

79.2 KB | W: | H:

misc/graph_vue_1.png

123 KB | W: | H:

misc/graph_vue_1.png
misc/graph_vue_1.png
misc/graph_vue_1.png
misc/graph_vue_1.png
  • 2-up
  • Swipe
  • Onion skin
<?php <?php
/* /*
Copyright (c) 2010, Till Brehm, projektfarm Gmbh Copyright (c) 2016, Gody - ORM
All rights reserved. All rights reserved.
*/ */
...@@ -28,9 +28,11 @@ $vm_pvesvr = $_REQUEST['vm_pvesvr']; ...@@ -28,9 +28,11 @@ $vm_pvesvr = $_REQUEST['vm_pvesvr'];
if(isset($prox_id) && !empty($prox_id)) if(isset($prox_id) && !empty($prox_id))
{ {
$client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]); // Verify assignation VM
if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) { if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid']))
{
$client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
$vm = $app->db->queryOneRecord("SELECT vm_containers, vm_id FROM proxmox_vm WHERE id = $prox_id AND sys_groupid = $client_group_id"); $vm = $app->db->queryOneRecord("SELECT vm_containers, vm_id FROM proxmox_vm WHERE id = $prox_id AND sys_groupid = $client_group_id");
} }
else else
......
<?php <?php
/* /*
Copyright (c) 2010 Till Brehm, projektfarm Gmbh and Oliver Vogel www.muv.com Copyright (c) 2016, Gody - ORM
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of ISPConfig nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
/****************************************** /******************************************
......
<?php <?php
/*
Copyright (c) 2016, Gody - ORM
All rights reserved.
*/
/****************************************** /******************************************
* Begin Form configuration * Begin Form configuration
...@@ -100,4 +104,4 @@ class page_action extends tform_actions { ...@@ -100,4 +104,4 @@ class page_action extends tform_actions {
$page = new page_action; $page = new page_action;
$page->onLoad(); $page->onLoad();
?> ?>
\ No newline at end of file
<?php <?php
/*
Copyright (c) 2016, Gody - ORM
All rights reserved.
*/
/****************************************** /******************************************
* Begin Form configuration * Begin Form configuration
...@@ -19,20 +22,15 @@ include './lib/pve2_api.class.php'; ...@@ -19,20 +22,15 @@ include './lib/pve2_api.class.php';
//* Check permissions for module //* Check permissions for module
$app->auth->check_module_permissions('proxmox'); $app->auth->check_module_permissions('proxmox');
// Loading classes // Loading classes
$app->uses('tpl,tform,tform_actions'); $app->uses('tpl,tform,tform_actions');
$app->load('tform'); $app->load('tform');
print_r($_REQUEST);
class page_action extends tform_actions { class page_action extends tform_actions {
function onShowEnd() { function onShowEnd() {
global $app, $conf; global $app, $conf;
//$vm_info['vm_id'] = $app->functions->intval($this->dataRecord['vm_id']);
$pve2 = new PVE2_API($conf["pve_link"], $conf["pve_username"], $conf["pve_realm"], $conf["pve_password"]); $pve2 = new PVE2_API($conf["pve_link"], $conf["pve_username"], $conf["pve_realm"], $conf["pve_password"]);
if ($pve2) { if ($pve2) {
...@@ -41,7 +39,6 @@ class page_action extends tform_actions { ...@@ -41,7 +39,6 @@ class page_action extends tform_actions {
$vm_id = $app->functions->intval($this->dataRecord['vm_id']); $vm_id = $app->functions->intval($this->dataRecord['vm_id']);
$vm_containers = $this->dataRecord['vm_containers'] ; $vm_containers = $this->dataRecord['vm_containers'] ;
$vm_temp = $pve2->get("/cluster/resources"); $vm_temp = $pve2->get("/cluster/resources");
$key = array_search($vm_id, array_column( $vm_temp , 'vmid')); $key = array_search($vm_id, array_column( $vm_temp , 'vmid'));
$vm_pvesvr = $vm_temp[$key]['node']; $vm_pvesvr = $vm_temp[$key]['node'];
...@@ -49,48 +46,16 @@ class page_action extends tform_actions { ...@@ -49,48 +46,16 @@ class page_action extends tform_actions {
$app->tpl->setVar("vm_id", $vm_id); $app->tpl->setVar("vm_id", $vm_id);
$app->tpl->setVar("vm_pvesvr", $vm_pvesvr); $app->tpl->setVar("vm_pvesvr", $vm_pvesvr);
switch($_REQUEST['next_tab']) switch($_REQUEST['next_tab'])
{ {
case 'graphics': case 'graphics':
//DO SOMETHING HERE //DO SOMETHING HERE
break; break;
case 'networks':
$vm_config = $pve2->get("/nodes/{$vm_pvesvr}/{$vm_containers}/{$vm_id}/config");
$keys = array_keys($vm_config);
$net_temp = preg_grep('/^net[0-9]+/',$keys);
echo '<pre>';
$arr_net = array();
foreach($net_temp as $net)
{
$settings_temp = explode(',', $vm_config[$net]);
$arr_net[$net]['interface'] = $net;
foreach($settings_temp as $settings )
{
list($k, $v) = explode('=', $settings);
$arr_net[$net]['checked'] = ($k == 'link_down' && $v == 1 ? 'checked' : '');
$arr_net[$net][$k] = $v;
}
}
$app->tpl->setloop('networks', $arr_net);
print_r($arr_net);
echo '</pre>';
break;
case 'informations': case 'informations':
default: default:
$vm_status = $pve2->get("/nodes/{$vm_pvesvr}/{$vm_containers}/{$vm_id}/status/current"); $vm_status = $pve2->get("/nodes/{$vm_pvesvr}/{$vm_containers}/{$vm_id}/status/current");
if ($vm_status != false) if ($vm_status != false)
{ {
$app->tpl->setVar("vm_name", $vm_status['name']); $app->tpl->setVar("vm_name", $vm_status['name']);
...@@ -109,12 +74,37 @@ class page_action extends tform_actions { ...@@ -109,12 +74,37 @@ class page_action extends tform_actions {
{ {
$app->error($app->tform->wordbook["vm_err_assignation"]); $app->error($app->tform->wordbook["vm_err_assignation"]);
} }
break;
$vm_config = $pve2->get("/nodes/{$vm_pvesvr}/{$vm_containers}/{$vm_id}/config");
$keys = array_keys($vm_config);
$net_temp = preg_grep('/^net[0-9]+/',$keys);
$arr_net = array();
foreach($net_temp as $net)
{
$settings_temp = explode(',', $vm_config[$net]);
$arr_net[$net]['interface'] = $net;
foreach($settings_temp as $settings )
{
list($k, $v) = explode('=', $settings);
if (preg_match('/(e1000|vmxnet3|virtio|rtl8139)/i', $k ) )
{
$arr_net[$net]['mac'] = $v;
}
$arr_net[$net]['link_state'] = ($k == 'link_down' && $v == 1 ? 'Yes' : 'No');
$arr_net[$net][$k] = $v;
}
}
$app->tpl->setloop('networks', $arr_net);
break;
} }
} else { } else {
//print("Login to Proxmox Host failed.\n"); //print("Login to Proxmox Host failed.\n");
$app->error($app->tform->wordbook["vm_err_login"]); $app->error($app->tform->wordbook["vm_err_login"]);
...@@ -128,34 +118,8 @@ class page_action extends tform_actions { ...@@ -128,34 +118,8 @@ class page_action extends tform_actions {
parent::onShowEnd(); parent::onShowEnd();
} }
/*
function onSubmit() {
global $app, $conf;
parent::onSubmit();
}
function onAfterInsert() {
global $app, $conf;
}
function onBeforeUpdate() {
global $app, $conf;
}
function onAfterUpdate() {
global $app, $conf;
}
*/
} }
$page = new page_action; $page = new page_action;
$page->onLoad(); $page->onLoad();
......
<?php <?php
/*
Copyright (c) 2016, Gody - ORM
All rights reserved.
*/
require_once '../../lib/config.inc.php'; require_once '../../lib/config.inc.php';
require_once '../../lib/app.inc.php'; require_once '../../lib/app.inc.php';
......
<?php <?php
/*
Copyright (c) 2016, Gody - ORM
All rights reserved.
*/
require_once '../../lib/config.inc.php'; require_once '../../lib/config.inc.php';
require_once '../../lib/app.inc.php'; require_once '../../lib/app.inc.php';
...@@ -12,32 +16,25 @@ $app->auth->check_module_permissions('proxmox'); ...@@ -12,32 +16,25 @@ $app->auth->check_module_permissions('proxmox');
// Loading classes // Loading classes
$app->uses('tpl'); $app->uses('tpl');
$template = 'templates/proxmox_vm_logs.htm';
// Loading the template
$app->uses('tpl');
$app->tpl->newTemplate("form.tpl.htm");
$app->tpl->setInclude('content_tpl', $template);
$pve2 = new PVE2_API($conf["pve_link"], $conf["pve_username"], $conf["pve_realm"], $conf["pve_password"]); $pve2 = new PVE2_API($conf["pve_link"], $conf["pve_username"], $conf["pve_realm"], $conf["pve_password"]);
if ($pve2) { if ($pve2) {
if ($pve2->login()) { if ($pve2->login()) {
$template = 'templates/proxmox_vm_logs.htm'; $app->tpl->setVar("task_title_txt", $app->lng("task_title_txt") );
$app->tpl->setVar("start_time_txt", $app->lng("start_time_txt") );
// Loading the template $app->tpl->setVar("end_time_txt", $app->lng("end_time_txt") );
$app->uses('tpl'); $app->tpl->setVar("username_txt", $app->lng("username_txt") );
$app->tpl->newTemplate("form.tpl.htm"); $app->tpl->setVar("description_txt", $app->lng("description_txt") );
$app->tpl->setInclude('content_tpl', $template); $app->tpl->setVar("status_txt", $app->lng("status_txt") );
$title = $app->lng("task_title_txt");
$start_time = $app->lng("start_time_txt");
$end_time = $app->lng("end_time_txt");
$username = $app->lng("username_txt");
$description = $app->lng("description_txt");
$status = $app->lng("status_txt");
$app->tpl->setVar("task_title_txt", $title);
$app->tpl->setVar("start_time_txt", $start_time);
$app->tpl->setVar("end_time_txt", $end_time);
$app->tpl->setVar("username_txt", $username);
$app->tpl->setVar("description_txt", $description);
$app->tpl->setVar("status_txt", $status);
$tasks_history = $pve2->get("/cluster/tasks"); $tasks_history = $pve2->get("/cluster/tasks");
...@@ -54,11 +51,9 @@ if ($pve2) { ...@@ -54,11 +51,9 @@ if ($pve2) {
} }
$app->tpl->setloop('task_logs', $tasks_logs); $app->tpl->setloop('task_logs', $tasks_logs);
$app->tpl_defaults();
$app->tpl->pparse();