diff options
author | Simon Rettberg | 2015-02-24 16:30:07 +0100 |
---|---|---|
committer | Simon Rettberg | 2015-02-24 16:30:07 +0100 |
commit | bb6432a6158b97cd5b92ab316d9d8b52bca2044d (patch) | |
tree | e64f4d92458d2fb501eb0af13c6dc37adc731747 | |
parent | MiniLinux download with version selection (diff) | |
download | slx-admin-bb6432a6158b97cd5b92ab316d9d8b52bca2044d.tar.gz slx-admin-bb6432a6158b97cd5b92ab316d9d8b52bca2044d.tar.xz slx-admin-bb6432a6158b97cd5b92ab316d9d8b52bca2044d.zip |
Various fixes
-rw-r--r-- | apis/cb.inc.php | 5 | ||||
-rw-r--r-- | config.php.example | 4 | ||||
-rw-r--r-- | inc/configmodule/adauth.inc.php | 1 | ||||
-rw-r--r-- | inc/configtgz.inc.php | 1 | ||||
-rw-r--r-- | inc/event.inc.php | 1 | ||||
-rw-r--r-- | inc/property.inc.php | 10 | ||||
-rw-r--r-- | inc/taskmanagercallback.inc.php | 4 | ||||
-rw-r--r-- | inc/trigger.inc.php | 12 | ||||
-rw-r--r-- | index.php | 4 | ||||
-rw-r--r-- | modules/sysconfig/addconfig.inc.php | 2 | ||||
-rw-r--r-- | templates/tm-callback-trigger.html | 16 |
11 files changed, 34 insertions, 26 deletions
diff --git a/apis/cb.inc.php b/apis/cb.inc.php index da5d8756..a94ac463 100644 --- a/apis/cb.inc.php +++ b/apis/cb.inc.php @@ -1,3 +1,6 @@ <?php -Trigger::checkCallbacks(); +if ( Trigger::checkCallbacks() ) + echo "True"; +else + echo "False"; diff --git a/config.php.example b/config.php.example index f6e418d2..929e7e2e 100644 --- a/config.php.example +++ b/config.php.example @@ -15,7 +15,7 @@ define('CONFIG_SQL_FORCE_UTF8', true); define('CONFIG_TGZ_LIST_DIR', '/opt/openslx/configs'); -define('CONFIG_REMOTE_ML', 'http://mltk.boot.openslx.org/update/new'); +define('CONFIG_REMOTE_ML', 'https://bwlp-masterserver.ruf.uni-freiburg.de/minilinux/sat_01'); define('CONFIG_TFTP_DIR', '/srv/openslx/tftp'); define('CONFIG_HTTP_DIR', '/srv/openslx/www/boot'); @@ -24,4 +24,4 @@ define('CONFIG_IPXE_DIR', '/opt/openslx/ipxe'); define('CONFIG_VMSTORE_DIR', '/srv/openslx/nfs'); -define('CONFIG_PROXY_CONF', '/opt/openslx/proxy/config');
\ No newline at end of file +define('CONFIG_PROXY_CONF', '/opt/openslx/proxy/config'); diff --git a/inc/configmodule/adauth.inc.php b/inc/configmodule/adauth.inc.php index 828469c3..f2e20e4a 100644 --- a/inc/configmodule/adauth.inc.php +++ b/inc/configmodule/adauth.inc.php @@ -18,6 +18,7 @@ class ConfigModule_AdAuth extends ConfigModule protected function generateInternal($tgz, $parent) { + Trigger::ldadp($this->id(), $parent); $config = $this->moduleData; $config['parentTask'] = $parent; $config['failOnParentFail'] = false; diff --git a/inc/configtgz.inc.php b/inc/configtgz.inc.php index 231960bb..8ddd4523 100644 --- a/inc/configtgz.inc.php +++ b/inc/configtgz.inc.php @@ -285,6 +285,7 @@ class ConfigTgz { if ($this->configId === 0) Util::traceError('ConfigTgz::markUpdated called with invalid config id!'); + Event::activeConfigChanged(); if ($this->areAllModulesUpToDate()) return $this->mark('OK'); return $this->mark('OUTDATED'); diff --git a/inc/event.inc.php b/inc/event.inc.php index 6b303493..5dca20ef 100644 --- a/inc/event.inc.php +++ b/inc/event.inc.php @@ -84,6 +84,7 @@ class Event */ public static function activeConfigChanged() { + error_log('Active config changed'); $task = Trigger::ldadp(); TaskmanagerCallback::addCallback($task, 'ldadpStartup'); } diff --git a/inc/property.inc.php b/inc/property.inc.php index d5a91872..0cb57f81 100644 --- a/inc/property.inc.php +++ b/inc/property.inc.php @@ -183,15 +183,5 @@ class Property { return self::get('password-type', 'password'); } - - public static function setNeedsCallback($value) - { - return self::set('need-callback', $value, 5); - } - - public static function getNeedsCallback() - { - return self::get('need-callback', 0); - } } diff --git a/inc/taskmanagercallback.inc.php b/inc/taskmanagercallback.inc.php index 546fbbc9..ba589469 100644 --- a/inc/taskmanagercallback.inc.php +++ b/inc/taskmanagercallback.inc.php @@ -38,7 +38,6 @@ class TaskmanagerCallback } else { Database::exec("INSERT INTO callback (taskid, dateline, cbfunction) VALUES (:task, UNIX_TIMESTAMP(), :callback)", $data); } - Property::setNeedsCallback(1); } /** @@ -73,8 +72,9 @@ class TaskmanagerCallback return; if (Taskmanager::isFailed($status) || Taskmanager::isFinished($status)) { $del = Database::exec("DELETE FROM callback WHERE taskid = :task AND cbfunction = :cb LIMIT 1", array('task' => $callback['taskid'], 'cb' => $callback['cbfunction'])); - if ($del === 0) // No entry deleted, so someone else must have deleted it - race condition, do nothing + if ($del === 0) { // No entry deleted, so someone else must have deleted it - race condition, do nothing return; + } } if (Taskmanager::isFinished($status)) { $func = array('TaskmanagerCallback', preg_replace('/\W/', '', $callback['cbfunction'])); diff --git a/inc/trigger.inc.php b/inc/trigger.inc.php index 0410b2be..0b1f00c5 100644 --- a/inc/trigger.inc.php +++ b/inc/trigger.inc.php @@ -78,10 +78,11 @@ class Trigger /** * Launch all ldadp instances that need to be running. * + * @param int $exclude if not NULL, id of config module NOT to start * @param string $parent if not NULL, this will be the parent task of the launch-task * @return boolean|string false on error, id of task otherwise */ - public static function ldadp($parent = NULL) + public static function ldadp($exclude = NULL, $parent = NULL) { // TODO: Fetch list from ConfigModule_AdAuth (call loadDb first) $res = Database::simpleQuery("SELECT moduleid, configtgz.filepath FROM configtgz_module" @@ -92,7 +93,9 @@ class Trigger $id = array(); while ($row = $res->fetch(PDO::FETCH_ASSOC)) { if (readlink('/srv/openslx/www/boot/default/config.tgz') === $row['filepath']) { - $id[] = (int) $row['moduleid']; + if (!is_null($exclude) && (int)$row['moduleid'] === (int)$exclude) + continue; + $id[] = (int)$row['moduleid']; break; } } @@ -133,6 +136,8 @@ class Trigger /** * Check and process all callbacks. + * + * @return boolean Whether there are still callbacks pending */ public static function checkCallbacks() { @@ -150,8 +155,7 @@ class Trigger else $tasksLeft = true; } - if (!$tasksLeft) - Property::setNeedsCallback(0); + return $tasksLeft; } private static function triggerDaemons($action, $parent, &$taskids) @@ -145,9 +145,7 @@ if (defined('CONFIG_FOOTER')) { Render::addTemplate('footer', array('text' => CONFIG_FOOTER)); } -if (Property::getNeedsCallback()) { - Render::addTemplate('tm-callback-trigger'); -} +Render::addTemplate('tm-callback-trigger'); // Send page to client. Render::output(); diff --git a/modules/sysconfig/addconfig.inc.php b/modules/sysconfig/addconfig.inc.php index 8acf5c32..023ec000 100644 --- a/modules/sysconfig/addconfig.inc.php +++ b/modules/sysconfig/addconfig.inc.php @@ -153,7 +153,7 @@ class AddConfig_Start extends AddConfig_Base 'step' => 'AddConfig_Finish', 'groups' => array_values($mods), 'title' => $title, - 'edit' => $this->edit->id() + 'edit' => ($this->edit !== false ? $this->edit->id() : false) )); } diff --git a/templates/tm-callback-trigger.html b/templates/tm-callback-trigger.html index 26b362ca..274a2246 100644 --- a/templates/tm-callback-trigger.html +++ b/templates/tm-callback-trigger.html @@ -1,5 +1,15 @@ <script type="text/javascript"> - setTimeout(function () { - $.post('api.php?do=cb', { token: TOKEN }); - }, 500); + var slxCbCooldown = 0; + function slxCheckCallbacks() { + $.post('api.php?do=cb', { token: TOKEN }, function(data) { + if ( data.indexOf('True') >= 0 ) { + slxCbCooldown = 0; + } else { + slxCbCooldown++; + } + if (slxCbCooldown < 4) + setTimeout(slxCheckCallbacks, (slxCbCooldown + 1) * 1500); + }, 'text'); + } + setTimeout(slxCheckCallbacks, 500); </script>
\ No newline at end of file |