ConfigHealthItemRenderer: use Migrations

fixes #11263
This commit is contained in:
Thomas Gelf 2016-03-05 17:23:40 +01:00
parent ca71bf5420
commit 3134630f86
1 changed files with 21 additions and 0 deletions

View File

@ -6,6 +6,7 @@ use Exception;
use Icinga\Application\Config; use Icinga\Application\Config;
use Icinga\Module\Director\ConfigHealthChecker; use Icinga\Module\Director\ConfigHealthChecker;
use Icinga\Module\Director\Db; use Icinga\Module\Director\Db;
use Icinga\Module\Director\Db\Migrations;
use Icinga\Module\Director\KickstartHelper; use Icinga\Module\Director\KickstartHelper;
use Icinga\Web\Navigation\Renderer\BadgeNavigationItemRenderer; use Icinga\Web\Navigation\Renderer\BadgeNavigationItemRenderer;
@ -57,6 +58,26 @@ class ConfigHealthItemRenderer extends BadgeNavigationItemRenderer
return; return;
} }
$migrations = new Migrations($db);
if (!$migrations->hasSchema()) {
$this->count = 1;
$this->directorState = self::STATE_CRITICAL;
$this->message = $this->translate(
'Director database schema has not been created yet'
);
return;
}
if ($migrations->hasPendingMigrations()) {
$this->count = $migrations->countPendingMigrations();
$this->directorState = self::STATE_PENDING;
$this->message = sprintf(
$this->translate('There are %d pending database migrations'),
$this->count
);
return;
}
$kickstart = new KickstartHelper($db); $kickstart = new KickstartHelper($db);
if ($kickstart->isRequired()) { if ($kickstart->isRequired()) {
$this->directorState = self::STATE_PENDING; $this->directorState = self::STATE_PENDING;