Power cycle VM to take effect.";
} elseif($_GET['s'] == '14') {
$success = "VM disk resized, please login to resize inside the OS.
May need to power cycle VM to take effect.";
} elseif($_GET['s'] == '15') {
$success = "VM disk added successfully.";
} elseif($_GET['s'] == '16') {
$success = "VM disk deleted successfully.";
} elseif($_GET['s'] == '17') {
$success = "VM backup started successfully.";
} elseif($_GET['s'] == '18') {
$success = "VM backup deleted successfully.";
} elseif($_GET['s'] == '19') {
$success = "VM restore started successfully, this might take a while.";
} elseif($_GET['s'] == '20') {
$success = "VM NIC added successfully.";
} elseif($_GET['s'] == '21') {
$success = "VM NIC deleted successfully.";
} elseif($_GET['s'] == '22') {
$success = "VM IP added successfully.";
} elseif($_GET['s'] == '23') {
$success = "VM IP removed successfully.";
}
}
$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 {
header("Location: vms.php?s=3");
}
}
#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'])) {
$encpw = encrypt($_POST["vncpw"]);
$vm_data = [':name' => $_POST["name"],':hostname' => $_POST["hostname"],':notes' => isset($_POST["notes"])? $_POST["notes"]: ' ',':vncpw' => $encpw,':vncport' => $_POST["vncport"],':websockify' => $_POST["websockify"],':mac_address' => $_POST["mac_address"],':cluster' => $_POST["cluster"],':status' => isset($_POST["status"])? 1: 0,':protected' => isset($_POST["protected"])? 1: 0];
$result = editVM($loggedin_id,$vm_id,$vm_data);
if($result === true) {
header("Location: vm.php?id=". (int)$vm_id. "&s=1");
} else {
$error = $result;
}
}
if(isset($_POST['set_CPU'])) {
$cpu_cores = $_POST["cpu_cores"];
$result = setCPU($loggedin_id,$vm_id,$vm['name'],$cpu_cores,$node['node_id']);
if($result === true) {
header("Location: vm.php?id=". (int)$vm_id. "&s=1");
} else {
$error = $result;
}
}
if(isset($_POST['set_RAM'])) {
$memory = $_POST["memory"];
$result = setRAM($loggedin_id,$vm_id,$vm['name'],$memory,$vm['node_id']);
if($result === true) {
header("Location: vm.php?id=". (int)$vm_id. "&s=1");
} else {
$error = $result;
}
}
if(isset($_POST['resize_disk'])) {
$disk_id= $_POST["disk_id"];
$disk_name = $_POST["disk_name"];
$disk_size = $_POST["disk_size"];
$result = resizeDisk($loggedin_id,$vm_id,$vm['name'],$disk_id,$disk_name,$disk_size,$vm['node_id']);
if($result === true) {
header("Location: vm.php?id=". (int)$vm_id. "&s=14");
} else {
$error = $result;
}
}
if(isset($_POST['add_disk'])) {
$disk_size = $_POST["disk_size"];
$result = addDisk($loggedin_id,$vm_id,$vm['name'],$disk_size,$vm['node_id']);
if($result === true) {
header("Location: vm.php?id=". (int)$vm_id. "&s=15");
} else {
$error = $result;
}
}
if(isset($_POST['delete_disk'])) {
$disk_id= $_POST["disk_id"];
$disk_name = $_POST["disk_name"];
$result = deleteDisk($loggedin_id,$vm_id,$vm['name'],$disk_id,$disk_name,$vm['node_id']);
if($result === true) {
header("Location: vm.php?id=". (int)$vm_id. "&s=16");
} else {
$error = $result;
}
}
if(isset($_POST['add_nic'])) {
$network = $_POST["network"];
$result = addNIC($loggedin_id,$vm_id,$vm['name'],$network,$vm['mac_address'],$vm['node_id']);
if($result === true) {
header("Location: vm.php?id=". (int)$vm_id. "&s=20");
} else {
$error = $result;
}
}
if(isset($_POST['delete_nic'])) {
$nic_id= $_POST["nic_id"];
$mac_address = $_POST["mac_address"];
$result = deleteNIC($loggedin_id,$vm['node_id'],$vm['name'],$nic_id,$mac_address);
if($result === true) {
header("Location: vm.php?id=". (int)$vm_id. "&s=21");
} else {
$error = $result;
}
}
if(isset($_POST['attach_ip4'])) {
$ip_id = $_POST["ip_id"];
$result = attachIP($loggedin_id,$vm_id,$ip_id,$vm['node_id'],"4");
if($result === true) {
header("Location: vm.php?id=". (int)$vm_id. "&s=22");
} else {
$error = $result;
}
}
if(isset($_POST['detach_ip4'])) {
$ip_id = $_POST["ip_id"];
$result = detachIP($loggedin_id,$ip_id,"4");
if($result === true) {
header("Location: vm.php?id=". (int)$vm_id. "&s=23");
} else {
$error = $result;
}
}
if(isset($_POST['attach_ip6'])) {
$ip_id = $_POST["ip_id"];
$result = attachIP($loggedin_id,$vm_id,$ip_id,$vm['node_id'],"6");
if($result === true) {
header("Location: vm.php?id=". (int)$vm_id. "&s=22");
} else {
$error = $result;
}
}
if(isset($_POST['detach_ip6'])) {
$ip_id = $_POST["ip_id"];
$result = detachIP($loggedin_id,$ip_id,"6");
if($result === true) {
header("Location: vm.php?id=". (int)$vm_id. "&s=23");
} else {
$error = "VM IP remove failed: ".$result;
}
}
if(isset($_POST['set_iow'])) {
$speed = $_POST['iow'];
$result = setIOW($loggedin_id,$vm_id,$vm['name'],$speed,$vm['node_id']);
if($result === true) {
header("Location: vm.php?id=". (int)$vm_id. "&s=1");
} else {
$error = $result;
}
}
if(isset($_POST['set_iow'])) {
$speed = $_POST['iow'];
$result = setIOW($loggedin_id,$vm_id,$vm['name'],$speed,$vm['node_id']);
if($result === true) {
header("Location: vm.php?id=". (int)$vm_id. "&s=1");
} else {
$error = $result;
}
}
if(isset($_POST['set_nic'])) {
$speed = $_POST['nic'];
$result = setNIC($loggedin_id,$vm_id,$vm['name'],$vm['network'],$speed,$vm['node_id']);
if($result === true) {
header("Location: vm.php?id=". (int)$vm_id. "&s=1");
} else {
$error = $result;
}
}
if(isset($_POST['startvm'])) {
$result = startVM($loggedin_id,$vm_id,$vm['name'],$vm['node_id']);
if($result === true) {
header("Location: vm.php?id=". (int)$vm_id. "&s=2");
} else {
$error = $result;
}
}
if(isset($_POST['restartvm'])) {
$result = restartVM($loggedin_id,$vm_id,$vm['name'],$vm['node_id']);
if($result === true) {
header("Location: vm.php?id=". (int)$vm_id. "&s=3");
} else {
$error = $result;
}
}
if(isset($_POST['shutdownvm'])) {
$result = shutdownVM($loggedin_id,$vm_id,$vm['name'],$vm['node_id']);
if($result === true) {
header("Location: vm.php?id=". (int)$vm_id. "&s=4");
} else {
$error = $result;
}
}
if(isset($_POST['stopvm'])) {
$result = stopVM($loggedin_id,$vm_id,$vm['name'],$vm['node_id']);
if($result === true) {
header("Location: vm.php?id=". (int)$vm_id. "&s=5");
} else {
$error = $result;
}
}
if(isset($_POST['disableVNC'])) {
$result = disableVNC($loggedin_id,$vm_id,$vm['name'],$vm['websockify'],$vm['vncport'],$vm['node_id']);
if($result === true) {
header("Location: vm.php?id=". (int)$vm_id. "&s=6");
} else {
$error = $result;
}
}
if(isset($_POST['enableVNC'])) {
$result = enableVNC($loggedin_id,$vm_id,$vm['name'],$vm['websockify'],$vm['vncport'],$vm['node_id']);
if($result === true) {
header("Location: vm.php?id=". (int)$vm_id. "&s=7");
} else {
$error = $result;
}
}
if(isset($_POST['consolePW'])) {
$result = consolePW($loggedin_id,$vm_id,$vm['name'],$vm['vncport'],$vm['node_id']);
if($result === true) {
header("Location: vm.php?id=". (int)$vm_id. "&s=8");
} else {
$error = $result;
}
}
if(isset($_POST['mountISO'])) {
$ostemplate = $_POST['ostemplate'];
$result = mountISO($loggedin_id,$vm_id,$vm['name'],$ostemplate,$vm['node_id']);
if($result === true) {
header("Location: vm.php?id=". (int)$vm_id. "&s=9");
} else {
$error = $result;
}
}
if(isset($_POST['unmountISO'])) {
$result = unmountISO($loggedin_id,$vm_id,$vm['name'],$vm['node_id']);
if($result === true) {
header("Location: vm.php?id=". (int)$vm_id. "&s=10");
} else {
$error = $result;
}
}
#if(isset($_POST['diskDriver'])) {
# $bus = $_POST['bus'];
# $result = diskDriver($loggedin_id,$vm_id,$vm['name'],$bus,$vm['node_id']);
# if($result === true) {
# header("Location: vm.php?id=". (int)$vm_id. "&s=11");
# } else {
# $error = $result;
# }
#}
#if(isset($_POST['netDriver'])) {
# $bus = $_POST['bus'];
# $result = netDriver($loggedin_id,$vm_id,$vm['name'],$bus,$vm['node_id']);
# if($result === true) {
# header("Location: vm.php?id=". (int)$vm_id. "&s=12");
# } else {
# $error = $result;
# }
#}
if(isset($_POST['bootOrder'])) {
$boot = $_POST['boot'];
$result = bootOrder($loggedin_id,$vm_id,$vm['name'],$boot,$vm['node_id']);
if($result === true) {
header("Location: vm.php?id=". (int)$vm_id. "&s=13");
} else {
$error = $result;
}
}
if(isset($_POST['backupvm'])) {
$result = backupVM($loggedin_id,$vm_id,$vm['name'],$vm['node_id']);
if($result === true) {
header("Location: vm.php?id=". (int)$vm_id. "&s=17");
} else {
$error = $result;
}
}
if(isset($_POST['deleteBackup'])) {
$backup_id = $_POST['backup_id'];
$backup_name = $_POST['backup_name'];
$result = deleteBackup($loggedin_id,$vm_id,$backup_name,$backup_id,$vm['node_id']);
if($result === true) {
header("Location: vm.php?id=". (int)$vm_id. "&s=18");
} else {
$error = $result;
}
}
if(isset($_POST['restoreVM'])) {
$backup_name = $_POST['backup_name'];
$result = restoreVM($loggedin_id,$backup_name,$vm['name'],$vm['vncport'],$vm_id,$vm['node_id']);
if($result === true) {
header("Location: vm.php?id=". (int)$vm_id. "&s=19");
} else {
$error = $result;
}
}
if(isset($_POST['destroyVM'])) {
if(isset($_POST['confirm'])) {
$confirm = $_POST['confirm'];
$result = destroyVM($loggedin_id,$vm_id,$vm['name'],$vm['websockify'],$vm['vncport'],$vm['node_id'],$confirm);
if($result === true) {
header("Location: vms.php?s=2");
} else {
$error = $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();
$disks = getDisks($vm_id);
$backups = getBackups($vm_id);
$nics = getNICs($vm_id);
$networks = getNetworks($vm['node_id']);
$ip4s = getAvailableIPs($vm['cluster'],'4');
$vmip4s = getVMIPs($vm_id,'4');
?>
VM Details
Disk Management
Attached Disks
';
$diskname = '';
$diskid = '';
echo "";
endforeach;?>
Network Management
Attached NICs
';
$macaddr = '';
$nic_id = '';
echo "";
endforeach;?>
IP Management
Attached IPs
';
$ip_id = '';
echo "";
endforeach;?>
Backup/Restore
Backups
IN PROGRESS";
} else {
$size = $size."MB";
}
$backup_id = $backup['backup_id'];
$created_at = $backup['created_at'];
$csrf = '';
$backupname = '';
$backup_id = '';
echo "
";
endforeach;?>
CPU Cores: |
|
Memory(GB): |
|
IO Write Limit: |
|
NIC Speed: |
|
Mount ISO: |
|
Unmount ISO: |
|
Boot Order: |
|