Power cycle VM to take effect.";
}
}
$vm_id = $_GET['id'];
$vm = getVMDetails($vm_id);
$node = getNodeDetails($vm['node_id']);
} elseif (isset($_POST['id'])) {
$vm_id = $_POST['id'];
$vm = getVMDetails($vm_id);
$node = getNodeDetails($vm['node_id']);
} else {
error_log("Error VM ID missing.");
header("Location: vms.php");
}
}
#print_r($node);
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
$csrfToken = getCSRFToken();
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$token = $_POST["csrf_token"];
if (validateCSRFToken($token)) {
if (isset($_POST['update_vm'])) {
$name = $_POST["name"];
$hostname = $_POST["hostname"];
$ipaddr = $_POST["ip_address"];
$cpu_cores = $_POST["cpu_cores"];
$memory = $_POST["memory"];
$disk1 = $_POST["disk1"];
$disk_space1 = $_POST["disk_space1"];
$ipv4 = $_POST["ipv4"];
$ipv6 = $_POST["ipv6"];
$mac_address = $_POST["mac_address"];
if(isset($_POST["notes"])) {
$notes = $_POST["notes"];
} else {
$notes = ' ';
}
$vncpw = $_POST["vncpw"];
$vncport = $_POST["vncport"];
$websockify = $_POST["websockify"];
$netdriver = $_POST["netdriver"];
$network = $_POST["network"];
$diskdriver = $_POST["diskdriver"];
$bootorder = $_POST["bootorder"];
$loc = $_POST["loc"];
if($_POST["status"]) {
$status = '1';
} else {
$status = '0';
}
if($_POST["protected"]) {
$protected = '1';
} else {
$protected = '0';
}
$result = editVM($vm_id, $name, $hostname, $ipaddr, $cpu_cores, $memory, $disk1, $disk_space1, $ipv4, $ipv6, $mac_address, $notes, $vncpw, $vncport, $websockify, $netdriver, $network, $diskdriver, $bootorder, $loc, $node['ipaddr'], $node['sshport'], $node['sshuser'], $node['sshkey'], $status, $protected);
if($result === true) {
header("Location: vm.php?id=$vm_id&s=1");
} else {
$error = "VM update failed: ".$result;
}
}
if (isset($_POST['set_iow'])) {
$speed = $_POST['iow'];
$result = setIOW($vm_id,$vm['name'],$speed,$node['ipaddr'],$node['sshport'],$node['sshuser'],$node['sshkey']);
if($result === true) {
header("Location: vm.php?id=$vm_id&s=1");
} else {
$error = "VM update failed: ".$result;
}
}
if (isset($_POST['set_nic'])) {
$speed = $_POST['nic'];
$result = setNIC($vm_id,$vm['name'],$vm['network'],$speed,$node['ipaddr'],$node['sshport'],$node['sshuser'],$node['sshkey']);
if($result === true) {
header("Location: vm.php?id=$vm_id&s=1");
} else {
$error = "VM update failed: ".$result;
}
}
if (isset($_POST['startvm'])) {
$result = startVM($vm_id,$vm['name'],$node['ipaddr'],$node['sshport'],$node['sshuser'],$node['sshkey']);
if($result === true) {
header("Location: vm.php?id=$vm_id&s=2");
} else {
$error = "VM start failed: ".$result;
}
}
if (isset($_POST['restartvm'])) {
$result = restartVM($vm_id,$vm['name'],$node['ipaddr'],$node['sshport'],$node['sshuser'],$node['sshkey']);
if($result === true) {
header("Location: vm.php?id=$vm_id&s=3");
} else {
$error = "VM restart failed: ".$result;
}
}
if (isset($_POST['shutdownvm'])) {
$result = shutdownVM($vm_id,$vm['name'],$node['ipaddr'],$node['sshport'],$node['sshuser'],$node['sshkey']);
if($result === true) {
header("Location: vm.php?id=$vm_id&s=4");
} else {
$error = "VM shutdown failed: ".$result;
}
}
if (isset($_POST['stopvm'])) {
$result = stopVM($vm_id,$vm['name'],$node['ipaddr'],$node['sshport'],$node['sshuser'],$node['sshkey']);
if($result === true) {
header("Location: vm.php?id=$vm_id&s=5");
} else {
$error = "VM stop failed: ".$result;
}
}
if (isset($_POST['disableVNC'])) {
$result = disableVNC($vm_id,$vm['name'],$vm['websockify'],$vm['vncport'],$node['ipaddr'],$node['sshport'],$node['sshuser'],$node['sshkey']);
if($result === true) {
header("Location: vm.php?id=$vm_id&s=6");
} else {
$error = "VM disable VNC failed: ".$result;
}
}
if (isset($_POST['enableVNC'])) {
$result = enableVNC($vm_id,$vm['name'],$vm['websockify'],$vm['vncport'],$node['ipaddr'],$node['sshport'],$node['sshuser'],$node['sshkey']);
if($result === true) {
header("Location: vm.php?id=$vm_id&s=7");
} else {
$error = "VM enable VNC failed: ".$result;
}
}
if (isset($_POST['consolePW'])) {
$result = consolePW($vm_id,$vm['name'],$vm['vncport'],$node['ipaddr'],$node['sshport'],$node['sshuser'],$node['sshkey']);
if($result === true) {
header("Location: vm.php?id=$vm_id&s=8");
} else {
$error = "VM console password reset failed: ".$result;
}
}
if (isset($_POST['mountISO'])) {
$ostemplate = $_POST['ostemplate'];
$result = mountISO($vm_id,$vm['name'],$ostemplate,$node['ipaddr'],$node['sshport'],$node['sshuser'],$node['sshkey']);
if($result === true) {
header("Location: vm.php?id=$vm_id&s=9");
} else {
$error = "VM ISO mount failed: ".$result;
}
}
if (isset($_POST['unmountISO'])) {
$result = unmountISO($vm_id,$vm['name'],$node['ipaddr'],$node['sshport'],$node['sshuser'],$node['sshkey']);
if($result === true) {
header("Location: vm.php?id=$vm_id&s=10");
} else {
$error = "VM ISO unmount failed: ".$result;
}
}
#if (isset($_POST['diskDriver'])) {
# $bus = $_POST['bus'];
# $result = diskDriver($vm_id,$vm['name'],$bus,$node['ipaddr'],$node['sshport'],$node['sshuser'],$node['sshkey']);
# if($result === true) {
# header("Location: vm.php?id=$vm_id&s=11");
# } else {
# $error = "VM update disk driver failed: ".$result;
# }
#}
#if (isset($_POST['netDriver'])) {
# $bus = $_POST['bus'];
# $result = netDriver($vm_id,$vm['name'],$bus,$node['ipaddr'],$node['sshport'],$node['sshuser'],$node['sshkey']);
# if($result === true) {
# header("Location: vm.php?id=$vm_id&s=12");
# } else {
# $error = "VM update network driver failed: ".$result;
# }
#}
if (isset($_POST['bootOrder'])) {
$boot = $_POST['boot'];
$result = bootOrder($vm_id,$vm['name'],$boot,$node['ipaddr'],$node['sshport'],$node['sshuser'],$node['sshkey']);
if($result === true) {
header("Location: vm.php?id=$vm_id&s=13");
} else {
$error = "VM update boot order failed: ".$result;
}
}
if (isset($_POST['destroyVM'])) {
if (isset($_POST['confirm'])) {
$confirm = $_POST['confirm'];
$result = destroyVM($vm_id,$vm['name'],$vm['websockify'],$vm['vncport'],$node['ipaddr'],$node['sshport'],$node['sshuser'],$node['sshkey'],$confirm);
if($result === true) {
header("Location: vms.php?s=2");
} else {
$error = "VM delete failed: ".$result;
}
} else {
$error = "VM delete failed: Please make sure you checked the confirmation box.";
}
}
} else {
$error = "Invalid CSRF token.";
}
}
if ($vm) {
$clusters = getClusters('all');
if ($vm['status'] == "1") {
$state = " checked";
} else {
$state = "";
}
if ($vm['protected'] == "1") {
$protect = " checked";
} else {
$protect = "";
}
$isoList = getISOs();
?>
VM Details
IO Write Limit: |
|
NIC Speed: |
|
Mount ISO: |
|
Unmount ISO: |
|
Boot Order: |
|