summaryrefslogtreecommitdiffstats
path: root/apis
diff options
context:
space:
mode:
authorSimon Rettberg2014-10-06 19:30:06 +0200
committerSimon Rettberg2014-10-06 19:30:06 +0200
commit94cb6009866f4ebc16d92087c0440adb98f18299 (patch)
treefb7deffa2965f92c4561b5111c17a6a5bed270c4 /apis
parentuse eventlog when creating users; show info on main page if no user was creat... (diff)
downloadslx-admin-94cb6009866f4ebc16d92087c0440adb98f18299.tar.gz
slx-admin-94cb6009866f4ebc16d92087c0440adb98f18299.tar.xz
slx-admin-94cb6009866f4ebc16d92087c0440adb98f18299.zip
Use eventlog in init and update API, populate database with default values on init
Diffstat (limited to 'apis')
-rw-r--r--apis/init.inc.php61
-rw-r--r--apis/update.inc.php12
2 files changed, 66 insertions, 7 deletions
diff --git a/apis/init.inc.php b/apis/init.inc.php
index 3e948330..a1344fc4 100644
--- a/apis/init.inc.php
+++ b/apis/init.inc.php
@@ -3,7 +3,60 @@
if (!isLocalExecution())
exit(0);
-Trigger::ldadp();
-Trigger::mount();
-Trigger::autoUpdateServerIp();
-Trigger::ipxe();
+EventLog::info('System boot...');
+$everythingFine = true;
+
+DefaultData::populate();
+
+// Tasks: fire away
+$mountId = Trigger::mount();
+$ldadpId = Trigger::ldadp();
+$autoIp = Trigger::autoUpdateServerIp();
+$ipxeId = Trigger::ipxe();
+
+// Check status of all tasks
+// Mount vm store
+if ($mountId === false) {
+ EventLog::info('No VM store type defined.');
+ $everythingFine = false;
+} else {
+ $res = Taskmanager::waitComplete($mountId, 5000);
+ if (Taskmanager::isFailed($res)) {
+ EventLog::failure('Mounting VM store failed: ' . $res['data']['messages']);
+ $everythingFine = false;
+ }
+}
+// LDAP AD Proxy
+if ($ldadpId === false) {
+ EventLog::failure('Cannot start LDAP-AD-Proxy: Taskmanager unreachable!');
+ $everythingFine = false;
+} else {
+ $res = Taskmanager::waitComplete($ldadpId, 5000);
+ if (Taskmanager::isFailed($res)) {
+ EventLog::failure('Starting LDAP-AD-Proxy failed: ' . $res['data']['messages']);
+ $everythingFine = false;
+ }
+}
+// Primary IP address
+if (!$autoIp) {
+ EventLog::failure("The server's IP address could not be determined automatically, and there is no active address configured.");
+ $everythingFine = false;
+}
+// iPXE generation
+if ($ipxeId === false) {
+ EventLog::failure('Cannot generate PXE menu: Taskmanager unreachable!');
+ $everythingFine = false;
+} else {
+ $res = Taskmanager::waitComplete($ipxeId, 5000);
+ if (Taskmanager::isFailed($res)) {
+ EventLog::failure('Update PXE Menu failed: ' . $res['data']['error']);
+ $everythingFine = false;
+ }
+}
+
+// Just so we know booting is done (and we don't expect any more errors from booting up)
+if ($everythingFine) {
+ EventLog::info('Bootup finished without errors.');
+} else {
+ EventLog::info('There were errors during bootup. Maybe the server is not fully configured yet.');
+}
diff --git a/apis/update.inc.php b/apis/update.inc.php
index 3c8984b6..4fb4b3fb 100644
--- a/apis/update.inc.php
+++ b/apis/update.inc.php
@@ -2,6 +2,12 @@
$targetVersion = Database::getExpectedSchemaVersion();
+function fatal($message)
+{
+ EventLog::failure($message);
+ die("$message\n");
+}
+
// #######################
$res = Database::queryFirst("SELECT value FROM property WHERE name = 'webif-version' LIMIT 1", array(), true);
@@ -16,16 +22,16 @@ while ($currentVersion < $targetVersion) {
$function = 'update_' . $currentVersion;
if (!function_exists($function))
- die("Don't know how to update from version $currentVersion to $targetVersion :-(");
+ fatal("Don't know how to update from version $currentVersion to $targetVersion :-(");
if (!$function())
- die("Update from $currentVersion to $targetVersion failed! :-(");
+ fatal("Update from $currentVersion to $targetVersion failed! :-(");
$currentVersion++;
$ret = Database::exec("INSERT INTO property (name, value) VALUES ('webif-version', :version) ON DUPLICATE KEY UPDATE value = VALUES(value)", array('version' => $currentVersion), false);
if ($ret === false)
- die('Writing version information back to DB failed. Next update will probably break.');
+ fatal('Writing version information back to DB failed. Next update will probably break.');
if ($currentVersion < $targetVersion) {
echo("Updated to $currentVersion...\n");