diff --git a/library/Director/Core/CoreApi.php b/library/Director/Core/CoreApi.php index fe855b0d..98bfeb3f 100644 --- a/library/Director/Core/CoreApi.php +++ b/library/Director/Core/CoreApi.php @@ -4,6 +4,7 @@ namespace Icinga\Module\Director\Core; use Exception; use Icinga\Exception\IcingaException; +use Icinga\Module\Director\Db; use Icinga\Module\Director\IcingaConfig\IcingaConfig; use Icinga\Module\Director\Objects\IcingaObject; use Icinga\Module\Director\Objects\IcingaCommand; @@ -21,7 +22,7 @@ class CoreApi } // Todo: type - public function setDb($db) + public function setDb(Db $db) { $this->db = $db; return $this; @@ -277,6 +278,22 @@ constants return current($this->listModuleStages('director', true)); } + public function getActiveChecksum(Db $conn) + { + $db = $conn->getConnection(); + $stage = $this->getActiveStageName(); + if (! $stage) { + return null; + } + + $query = $db->select()->from( + array('l' => 'director_deployment_log'), + array('checksum' => $conn->dbHexFunc('l.config_checksum')) + )->where('l.stage_name = ?', $stage); + + return $db->fetchOne($query); + } + protected function getDirectorObjects($type, $single, $plural, $map) { $attrs = array_merge(