From f10d0e51bb137b62ed50c7aa49437e7833ef8dcc Mon Sep 17 00:00:00 2001 From: nativemad Date: Tue, 23 Oct 2018 17:39:54 +0200 Subject: [PATCH] prio for startup and new overview to sort vms --- nlvmi | 20 ++++++++----- web/arrowdown.png | Bin 0 -> 8203 bytes web/arrowup.png | Bin 0 -> 8180 bytes web/index.php | 72 +++++++++++++++++++++++++++++++++++++--------- web/nlvmi.js | 16 +++++++++++ 5 files changed, 88 insertions(+), 20 deletions(-) create mode 100644 web/arrowdown.png create mode 100644 web/arrowup.png diff --git a/nlvmi b/nlvmi index a5a1348..7417c9b 100755 --- a/nlvmi +++ b/nlvmi @@ -81,7 +81,8 @@ function createdb { brdev3 VARCHAR(50), vncport INTEGER, websocket INTEGER, - vncpassword VARCHAR(50) + vncpassword VARCHAR(50), + prio INTEGER );" sqlite3 $SQLITEFILE "CREATE TABLE users ( id INTEGER PRIMARY KEY AUTOINCREMENT, @@ -147,8 +148,9 @@ function vmstart { sqlite3 $SQLITEFILE "SELECT * FROM vms LEFT JOIN servers on vms.server = servers.hostname WHERE vms.id=$1" | while read line; do IFS='|' read -r -a array <<< "$line" #prepare tmpfile - TMPF=/home/nlvmi/start${array[1]}.tmp - rm $TMPF &>/dev/null + TMPF=/home/nlvmi/start${array[32]}-${array[1]}.tmp + rm /home/nlvmi/start*-${array[1]}.tmp &>/dev/null + touch $TMPF && chmod 660 $TMPF #add user if necessary echo "if ! \`id -u ${array[2]} &>/dev/null\`; then useradd ${array[2]} -d /run/nlvmi -g nlvmi -M -s /bin/false -G kvm; fi" >>$TMPF #chown mon and pid files @@ -183,14 +185,18 @@ function vmstart { echo "${COMMAND[@]}" >>$TMPF #Set VNC Password echo "echo \"change vnc password ${array[31]}\" | socat - unix-connect:$RUNDIRECTORY/${array[1]}.mon >/dev/null" >>$TMPF - if [ ! -z "${array[34]}" ]; then + if [ ! -z "${array[35]}" ]; then echo "chmod g+w $RUNDIRECTORY/${array[1]}.mon" >>$TMPF echo "chmod g+r $RUNDIRECTORY/${array[1]}.pid" >>$TMPF openssl dgst -sha512 -sign "/etc/nlvmi/nlvmi_priv.key" -out /home/nlvmi/${array[1]}.tmp.sha512 $TMPF - su nlvmi -c "scp $TMPF* ${array[34]}:/home/nlvmi/" - su nlvmi -c "ssh ${array[34]} \"/usr/bin/nlvmi remote $TMPF run\"" + TMPFR="/home/nlvmi/rstart{array[32]}-${array[1]}.tmp" + mv $TMPF $TMPFR + su nlvmi -c "ssh ${array[35]} \"rm /home/nlvmi/start*-${array[1]}.tmp\"" + mv $TMPFR $TMPF + su nlvmi -c "scp $TMPF* ${array[35]}:/home/nlvmi/" + su nlvmi -c "ssh ${array[35]} \"/usr/bin/nlvmi remote $TMPF run\"" if [ ${array[12]} == "0" ]; then - su nlvmi -c "ssh ${array[34]} \"rm $TMPF $TMPF.sha512\"" + su nlvmi -c "ssh ${array[35]} \"rm $TMPF $TMPF.sha512\"" fi rm $TMPF $TMPF.sha512 else diff --git a/web/arrowdown.png b/web/arrowdown.png new file mode 100644 index 0000000000000000000000000000000000000000..d9292abb8482f2d3f08f7487526c0a520dbdd059 GIT binary patch literal 8203 zcma)hd0bOR*Z;YJ$SUzwR1jHweW*|ruqq(3h`6*`c9MW>QN)!^!y1IdrBWXiY(-Gk zDhimeL{U(-#H!GW1Q8?HuoeZp7#1-s0g~SY+voGV{p-i)L+;F(Gv|EIGIM9nJ@4+i zYoYoIbpTlS-M8C40SKsxO{gwFj|F}kgV95ozU@12RrGgK^}vs)uNL{OFCCG?75~`F z{CkHHQ8#LbPn1{0!Km1MCqf`LHrD(|_%V9$zQ_>sh!cmhhV51W82$+Y;kA8 z{oC;Y-P5t;SS1(hbsHz1YAnC1)1cE3;`8*tC8HBORdwaZ|Jr$ezh#Tfl>??~*LByJ z1>gI|*Mr`=YH^v<>$vYOZoBYuUF@^|{ZISxaq9^Xm&Drq=-Zncd$vfr_l8Hic1Lp#Jk6Z1? zD=(&F65f|1ot?>M%*YDE%UZ)@D|1Bc;x1ug^H}$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php b/web/index.php index 937b7b0..4b79e23 100644 --- a/web/index.php +++ b/web/index.php @@ -141,7 +141,7 @@ if (isset($_SESSION['username'])){ } else { $vmname = clean($_POST['deletename']); $vmid = clean($_POST['deleteid']); - $sql="SELECT id FROM vms WHERE vmname='$vmname' AND id='$vmid'"; + $sql="SELECT id,prio FROM vms WHERE vmname='$vmname' AND id='$vmid'"; $res = $db_handle->query($sql); while ($row = $res->fetchArray(SQLITE3_ASSOC)){ $sqld="DELETE FROM vms WHERE id='$vmid'"; @@ -150,7 +150,9 @@ if (isset($_SESSION['username'])){ } } } - } elseif ((isset($_POST['deleteid']))&&(isset($_POST['deletename']))&&($_POST['delwhat']=="user")){ + } elseif +//delete user + ((isset($_POST['deleteid']))&&(isset($_POST['deletename']))&&($_POST['delwhat']=="user")){ if($_SESSION['isadmin']!=1){ echo "you are not allowed to delete users!"; } else { @@ -165,7 +167,9 @@ if (isset($_SESSION['username'])){ } } } - } elseif ((isset($_POST['deleteid']))&&(isset($_POST['deletename']))&&($_POST['delwhat']=="server")){ + } elseif +//delete server + ((isset($_POST['deleteid']))&&(isset($_POST['deletename']))&&($_POST['delwhat']=="server")){ if($_SESSION['isadmin']!=1){ echo "you are not allowed to delete vms!"; } else { @@ -274,6 +278,11 @@ if (isset($_SESSION['username'])){ //insert or update vm in db if(isset($_REQUEST['mode'])){ if($_REQUEST['mode']=="newvm"){ + $psql = "SELECT MAX(prio) AS prio FROM vms"; + $pres = $db_handle->query($psql); + $prioa = $pres->fetchArray(SQLITE3_ASSOC); + $prio = $prioa['prio'] + 1; + $mode="newvm"; $sqls="INSERT INTO vms "; $sqlc="("; @@ -304,10 +313,10 @@ if (isset($_SESSION['username'])){ $sqlv .= "'$rvalue',"; } } - $sqlc = rtrim($sqlc, ','); - $sqlc.=")"; - $sqlv = rtrim($sqlv, ','); - $sqlv.=")"; +// $sqlc = rtrim($sqlc, ','); + $sqlc.=" 'prio')"; +// $sqlv = rtrim($sqlv, ','); + $sqlv.=" '$prio')"; $sql = "$sqls$sqlc$sqlv"; //echo $sql; $res = $db_handle->exec($sql); @@ -354,6 +363,37 @@ if (isset($_SESSION['username'])){ exit; } } + if (isset($_REQUEST['neworder'])){ + if (isset($_REQUEST['vid'])){ + $vid = clean($_REQUEST['vid']); + $sql="SELECT prio FROM vms WHERE id='$vid'"; + $oldprio = $db_handle->query($sql)->fetchArray(SQLITE3_ASSOC)['prio']; + //print_r($res); + //echo "buu"; + if ($_REQUEST['neworder']=="up"){ + $newprio = $oldprio - 1; + $sqlu="SELECT id FROM vms WHERE prio='$newprio'"; + $oldid = $db_handle->query($sqlu)->fetchArray(SQLITE3_ASSOC)['id']; + $sqlm="UPDATE vms SET prio='$newprio' WHERE id='$vid'"; + $sqln="UPDATE vms SET prio='$oldprio' WHERE id='$oldid'"; + if(($db_handle->exec($sqlm))&&($db_handle->exec($sqln))){ + echo "success"; + exit; + } + }elseif ($_REQUEST['neworder']=="down"){ + $newprio = $oldprio + 1; + $sqlu="SELECT id FROM vms WHERE prio='$newprio'"; + $oldid = $db_handle->query($sqlu)->fetchArray(SQLITE3_ASSOC)['id']; + $sqlm="UPDATE vms SET prio='$newprio' WHERE id='$vid'"; + $sqln="UPDATE vms SET prio='$oldprio' WHERE id='$oldid'"; + if(($db_handle->exec($sqlm))&&($db_handle->exec($sqln))){ + echo "success"; + exit; + } + } + + } + } if (isset($_POST['serverbuttoni'])){ serverdepropdown($_POST['serverbuttoni'], "no drive1", 'drive1'); formatbuttons('format1', ''); @@ -598,10 +638,11 @@ if (isset($_SESSION['username'])){ } //getting vms from DB - $sql="SELECT * FROM vms $sqllimit"; + $sql="SELECT * FROM vms $sqllimit ORDER BY prio"; $res = $db_handle->query($sql); - echo "
"; + while ($row = $res->fetchArray(SQLITE3_ASSOC)){ + echo "
"; if (checkvm($row['vmname'])){ $button = "start"; $buttonc = "btn-success"; @@ -610,8 +651,12 @@ if (isset($_SESSION['username'])){ $buttonc = "btn-warning"; } $vncport = sprintf("%02d", $row['vncport']); - echo "

$row[vmname]

$row[server]
$row[cpus] CPUs, $row[memory] MB RAM
$row[drive1]
"; - echo "VNC port: 59$vncport
edit "; + echo "
"; + //style=\"margin:5px;padding:5px;border:solid 1px;max-width:295px;\"> + echo "
"; + echo "
"; + echo "
$row[vmname]
$row[server]
$row[cpus] CPUs, $row[memory] MB RAM
$row[drive1]
"; + echo "
VNC port: 59$vncport
edit "; echo "$button "; echo " "; if ($row['websocket']!=""){ @@ -620,13 +665,14 @@ if (isset($_SESSION['username'])){ echo "VNC"; } } - echo "
"; + echo "

"; } } - echo "
"; + echo ""; } elseif (!isset($_SESSION['username'])){ echo "

Welcome to nlvmi!

You need to log in


"; echo "
Username: Password:
"; exit; } + ?> diff --git a/web/nlvmi.js b/web/nlvmi.js index b64a497..466d48e 100644 --- a/web/nlvmi.js +++ b/web/nlvmi.js @@ -73,3 +73,19 @@ function submitbutton(formid){ }, }); } + +function arrow(dir, id){ + data = "&neworder="+ dir +"&vid="+ id; + $.ajax({ + type: 'POST', + url: "?rand="+ makeid(), + data: data, + success: function(response) { + if (response != "success"){ + window.alert('Failure!\n' + response); + } else { + window.location.href = ""; + } + }, + }); +}