summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2018-04-24 15:54:00 +0200
committerSimon Rettberg2018-04-24 15:54:00 +0200
commitb48e755affc865547ab148340f586ae9a297c8f5 (patch)
treef15da9b1ced06785594467fe84fd63db34900461
parent[translation] Satelliten-Server -> Satellitenserver (diff)
downloadslx-admin-b48e755affc865547ab148340f586ae9a297c8f5.tar.gz
slx-admin-b48e755affc865547ab148340f586ae9a297c8f5.tar.xz
slx-admin-b48e755affc865547ab148340f586ae9a297c8f5.zip
[rebootcontrol] Try clients first that are known to be online
This prevents long delays if a large amount of clients is selected where the majority is offline.
-rw-r--r--modules-available/rebootcontrol/inc/rebootqueries.inc.php4
-rw-r--r--modules-available/rebootcontrol/page.inc.php8
2 files changed, 9 insertions, 3 deletions
diff --git a/modules-available/rebootcontrol/inc/rebootqueries.inc.php b/modules-available/rebootcontrol/inc/rebootqueries.inc.php
index 3dc3183f..525a9e58 100644
--- a/modules-available/rebootcontrol/inc/rebootqueries.inc.php
+++ b/modules-available/rebootcontrol/inc/rebootqueries.inc.php
@@ -44,13 +44,13 @@ class RebootQueries
/**
* Get machines by list of UUIDs
* @param string[] $list list of system UUIDs
- * @return array list of machines with machineuuid, clientip and locationid
+ * @return array list of machines with machineuuid, clientip, state and locationid
*/
public static function getMachinesByUuid($list)
{
if (empty($list))
return array();
- $res = Database::simpleQuery("SELECT machineuuid, clientip, locationid FROM machine
+ $res = Database::simpleQuery("SELECT machineuuid, clientip, state, locationid FROM machine
WHERE machineuuid IN (:list)", compact('list'));
return $res->fetchAll(PDO::FETCH_ASSOC);
}
diff --git a/modules-available/rebootcontrol/page.inc.php b/modules-available/rebootcontrol/page.inc.php
index 041ae74f..675c94f8 100644
--- a/modules-available/rebootcontrol/page.inc.php
+++ b/modules-available/rebootcontrol/page.inc.php
@@ -49,7 +49,13 @@ class Page_RebootControl extends Page
Message::addError('no-clients-selected');
Util::redirect();
}
-
+ usort($actualClients, function($a, $b) {
+ $a = ($a['state'] === 'IDLE' || $a['state'] === 'OCCUPIED');
+ $b = ($b['state'] === 'IDLE' || $b['state'] === 'OCCUPIED');
+ if ($a === $b)
+ return 0;
+ return $a ? -1 : 1;
+ });
$task = RebootControl::execute($actualClients, $this->action === 'shutdown', $minutes, $locationId);
Util::redirect("?do=rebootcontrol&taskid=".$task["id"]);
}