summaryrefslogtreecommitdiffstats
path: root/inc
diff options
context:
space:
mode:
authorSimon Rettberg2014-06-05 20:41:32 +0200
committerSimon Rettberg2014-06-05 20:41:32 +0200
commitda5ae919f868d1da90548d7cbafec55a06d2a62b (patch)
tree9af9d1933f03c518875d672cdc1ac87dd13273ad /inc
parentAdd functions to add script includes to the beginning or end of the document ... (diff)
downloadslx-admin-da5ae919f868d1da90548d7cbafec55a06d2a62b.tar.gz
slx-admin-da5ae919f868d1da90548d7cbafec55a06d2a62b.tar.xz
slx-admin-da5ae919f868d1da90548d7cbafec55a06d2a62b.zip
Started "System Status" page
Diffstat (limited to 'inc')
-rw-r--r--inc/property.inc.php13
-rw-r--r--inc/taskmanager.inc.php40
2 files changed, 48 insertions, 5 deletions
diff --git a/inc/property.inc.php b/inc/property.inc.php
index d62bbcb9..00c8018f 100644
--- a/inc/property.inc.php
+++ b/inc/property.inc.php
@@ -133,6 +133,19 @@ class Property
{
return json_decode(self::get('vmstore-config'), true);
}
+ public static function getVmStoreUrl()
+ {
+ $store = self::getVmStoreConfig();
+ if (!isset($store['storetype']))
+ return false;
+ if ($store['storetype'] === 'nfs')
+ return $store['nfsaddr'];
+ if ($store['storetype'] === 'cifs')
+ return $store['cifsaddr'];
+ if ($store['storetype'] === 'internal')
+ return '<local>';
+ return '<unknown>';
+ }
public static function setVmStoreConfig($value)
{
diff --git a/inc/taskmanager.inc.php b/inc/taskmanager.inc.php
index 99e35e94..dfacc5a7 100644
--- a/inc/taskmanager.inc.php
+++ b/inc/taskmanager.inc.php
@@ -18,7 +18,7 @@ class Taskmanager
socket_connect(self::$sock, '127.0.0.1', 9215);
}
- public static function submit($task, $data, $async = false)
+ public static function submit($task, $data = false, $async = false)
{
self::init();
$seq = (string) mt_rand();
@@ -67,21 +67,30 @@ class Taskmanager
return $reply;
}
- public static function waitComplete($taskId)
+ public static function waitComplete($task)
{
+ if (isset($task['id'])) {
+ if ($task['statusCode'] !== TASK_PROCESSING && $task['statusCode'] !== TASK_WAITING) {
+ self::release($task['id']);
+ return $task;
+ }
+ $task = $task['id'];
+ }
+ if (!is_string($task))
+ return false;
$done = false;
for ($i = 0; $i < 10; ++$i) {
- $status = self::status($taskId);
+ $status = self::status($task);
if (!isset($status['statusCode']))
break;
- if ($status['statusCode'] != TASK_PROCESSING && $status['statusCode'] != TASK_WAITING) {
+ if ($status['statusCode'] !== TASK_PROCESSING && $status['statusCode'] !== TASK_WAITING) {
$done = true;
break;
}
usleep(150000);
}
if ($done)
- self::release($taskId);
+ self::release($task);
return $status;
}
@@ -93,6 +102,27 @@ class Taskmanager
return true;
return false;
}
+
+ public static function addErrorMessage($task)
+ {
+ static $failure = false;
+ if ($task === false) {
+ if (!$failure) {
+ Message::addError('taskmanager-error');
+ $failure = true;
+ }
+ return;
+ }
+ if (!isset($task['statusCode'])) {
+ Message::addError('taskmanager-format');
+ return;
+ }
+ if (isset($task['data']['error'])) {
+ Message::addError('task-error', $task['statusCode'] . ' (' . $task['data']['error'] . ')');
+ return;
+ }
+ Message::addError('task-error', $task['statusCode']);
+ }
public static function release($taskId)
{