summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--modules-available/rebootcontrol/inc/rebootcontrol.inc.php45
1 files changed, 8 insertions, 37 deletions
diff --git a/modules-available/rebootcontrol/inc/rebootcontrol.inc.php b/modules-available/rebootcontrol/inc/rebootcontrol.inc.php
index 4c668e53..bb3bcd0c 100644
--- a/modules-available/rebootcontrol/inc/rebootcontrol.inc.php
+++ b/modules-available/rebootcontrol/inc/rebootcontrol.inc.php
@@ -49,39 +49,6 @@ class RebootControl
return $task;
}
- private static function extractLocationIds($from, &$to)
- {
- if (is_numeric($from)) {
- $to[$from] = true;
- return;
- }
- if (!is_array($from))
- return;
- $allnum = true;
- foreach ($from as $k => $v) {
- if (is_numeric($k) && is_numeric($v))
- continue;
- $allnum = false;
- if (is_numeric($k) && is_array($v)) {
- self::extractLocationIds($v, $to);
- } else {
- $k = strtolower($k);
- if ($k === 'locationid' || $k === 'locationids' || $k === 'location' || $k === 'locations' || $k === 'lid' || $k === 'lids') {
- self::extractLocationIds($v, $to);
- } elseif ($k === 'client' || $k === 'clients' || $k === 'machine' || $k === 'machines') {
- if (is_array($v)) {
- self::extractLocationIds($v, $to);
- }
- }
- }
- }
- if ($allnum) {
- foreach ($from as $v) {
- $to[$v] = true;
- }
- }
- }
-
private static function addTask($id, $type, $clients, $taskIds, $other = false)
{
$lids = ArrayUtil::flattenByKey($clients, 'locationid');
@@ -313,7 +280,7 @@ class RebootControl
* Now that I figured out what I want, do something like this:
* 1) Group clients by subnet
* 2) Only after step 1, start to collect possible ways to wake up clients for each subnet that's not empty
- * 3) Habe some priority list for the methods, extend Taskmanager to have "negative dependency"
+ * 3) Have some priority list for the methods, extend Taskmanager to have "negative dependency"
* i.e. submit task B with task A as parent task, but only launch task B if task A failed.
* If task A succeeded, mark task B as FINISHED immediately without actually running it.
* (or introduce new statusCode for this?)
@@ -365,11 +332,11 @@ class RebootControl
break;
}
}
- $ok = false;
- if (!$ok && $subnet === false) {
+ if ($subnet === false) {
$unknown[] = $client;
- $ok = true;
+ continue;
}
+ $ok = false;
if (!$ok && $subnet['isdirect']) {
// Directly reachable
$subnet['direct'][] = $client;
@@ -393,8 +360,12 @@ class RebootControl
} else {
// Found suitable indirect host
$subnet['indirect'][] = $client;
+ $ok = true;
}
}
+ if ($ok && isset($client['machineuuid'])) {
+ // TODO: Remember WOL was attempted
+ }
}
unset($subnet);
// Batch process