blob: f7ee6ac1847935e8f2ddef174d59f375656aab19 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
<?php
require_once 'inc/taskmanager.inc.php';
require_once 'inc/property.inc.php';
if (!is_array($_POST['ids'])) {
die('{"error" : "No Task ids given in POST data."}');
}
$return = array();
foreach ($_POST['ids'] as $id) {
$status = Taskmanager::status($id);
if ($status === false) {
$return[] = array('id' => $id, 'error' => 'No connection to TaskManager');
continue;
}
$return[] = $status;
// HACK HACK - should be pluggable
if (isset($status['statusCode']) && $status['statusCode'] === TASK_FINISHED // iPXE Update
&& $id === Property::getIPxeTaskId() && Property::getServerIp() !== Property::getIPxeIp()) {
Property::setIPxeIp(Property::getServerIp());
}
// -- END HACKS --
if (!isset($status['statusCode']) || ($status['statusCode'] !== TASK_WAITING && $status['statusCode'] !== TASK_PROCESSING)) {
Taskmanager::release($id);
}
}
echo json_encode(array('tasks' => $return));
|