From 2e143bb614be3b551779a6ccd9ad17fb276d13ce Mon Sep 17 00:00:00 2001 From: Tlams Date: Sat, 28 Apr 2018 13:28:50 +0100 Subject: [PATCH] PVE action by web interface --- code/web/www/pages/requires/pveaction.php | 67 +++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100755 code/web/www/pages/requires/pveaction.php diff --git a/code/web/www/pages/requires/pveaction.php b/code/web/www/pages/requires/pveaction.php new file mode 100755 index 0000000..a84389a --- /dev/null +++ b/code/web/www/pages/requires/pveaction.php @@ -0,0 +1,67 @@ +GET_status('current', $id), true)['value']['data']; +$status_before = (object) $status_before; + + +if (mappingstatus($status_before->status) != $action) +{ + if(in_array($action, ["shutdown","stop","reset"]) && $status_before->status == "stopped") + { + echo "Action not available! VM ".$status_before->name." is currently :".$status_before->status.""; + } + else if ($action == "current") + { + echo "The VM ".$status_before->name." is currently ".$status_before->status.""; + } + else + { + $status_after = $status_before; + + $q->GET_status($action, $id); + + for ($i = 1; ($status_after->status == $status_before->status) && $i <= 9; $i++) { + sleep(3); // 30s max (10*3) + $status_after = json_decode($q->GET_status('current', $id), true)['value']['data']; + $status_after = (object) $status_after; + } + + if($status_after->status == $status_before->status) + { + echo "Command time out"; + } + else + { + echo "The VM ".$status_after->name." is now :".$status_after->status.""; + } + } +} +else +{ + echo "Your VM ".$status_before->name." is already:".$status_before->status.""; +} \ No newline at end of file