proxmox_vm_logs.php 1.51 KB
Newer Older
Cédric's avatar
Cédric committed
1
<?php
Cédric's avatar
Cédric committed
2 3 4 5
/*
Copyright (c) 2016, Gody - ORM
All rights reserved.
*/
Cédric's avatar
Cédric committed
6 7 8 9 10 11 12 13 14 15 16 17 18

require_once '../../lib/config.inc.php';
require_once '../../lib/app.inc.php';

include './lib/pve2_api.class.php';


//* Check permissions for module
$app->auth->check_module_permissions('proxmox');

// Loading classes
$app->uses('tpl');

Cédric's avatar
Cédric committed
19 20 21 22 23 24 25
$template = 'templates/proxmox_vm_logs.htm';

// Loading the template
$app->uses('tpl');
$app->tpl->newTemplate("form.tpl.htm");
$app->tpl->setInclude('content_tpl', $template);
		
Cédric's avatar
Cédric committed
26 27 28 29 30

$pve2 = new PVE2_API($conf["pve_link"], $conf["pve_username"], $conf["pve_realm"], $conf["pve_password"]);
		
if ($pve2) {
	if ($pve2->login()) {
Cédric's avatar
Cédric committed
31 32 33 34 35 36 37
	
		$app->tpl->setVar("task_title_txt", $app->lng("task_title_txt") );
		$app->tpl->setVar("start_time_txt", $app->lng("start_time_txt") );
		$app->tpl->setVar("end_time_txt", $app->lng("end_time_txt") );
		$app->tpl->setVar("username_txt", $app->lng("username_txt") );
		$app->tpl->setVar("description_txt", $app->lng("description_txt") );
		$app->tpl->setVar("status_txt", $app->lng("status_txt") );
Cédric's avatar
Cédric committed
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56

		$tasks_history = $pve2->get("/cluster/tasks");

		$tasks_logs = array();
		foreach($tasks_history as $key => $task){
			$tasks_logs[] = array(
				'starttime' => date('d-m-Y H-i-s', $task['starttime']),
				'endtime' => date('d-m-Y H-i-s', $task['endtime']),
				'vmid' => $task['id'],
				'username' => $task['user'],
				'description' => $app->lng($task['type']),
				'status'  => $task['status'],
			);
		}
		
		$app->tpl->setloop('task_logs', $tasks_logs);
	}
}

Cédric's avatar
Cédric committed
57 58
$app->tpl_defaults();
$app->tpl->pparse();
Cédric's avatar
Cédric committed
59
?>