diff --git a/application/controllers/ConfigController.php b/application/controllers/ConfigController.php index d0459f48..b193bc80 100644 --- a/application/controllers/ConfigController.php +++ b/application/controllers/ConfigController.php @@ -6,6 +6,7 @@ use Icinga\Data\Filter\Filter; use Icinga\Exception\IcingaException; use Icinga\Exception\NotFoundError; use Icinga\Module\Director\ConfigDiff; +use Icinga\Module\Director\Deployment\DeploymentStatus; use Icinga\Module\Director\Forms\DeployConfigForm; use Icinga\Module\Director\Forms\SettingsForm; use Icinga\Module\Director\IcingaConfig\IcingaConfig; @@ -15,7 +16,6 @@ use Icinga\Module\Director\Web\Table\ActivityLogTable; use Icinga\Module\Director\Web\Table\ConfigFileDiffTable; use Icinga\Module\Director\Web\Table\DeploymentLogTable; use Icinga\Module\Director\Web\Table\GeneratedConfigFileTable; -use Icinga\Module\Director\Util; use Icinga\Module\Director\Web\Controller\ActionController; use Icinga\Module\Director\Web\Tabs\InfraTabs; use Icinga\Module\Director\Web\Widget\ActivityLogInfo; @@ -126,6 +126,23 @@ class ConfigController extends ActionController } } + public function deploymentStatusAction() + { + if ($this->sendNotFoundUnlessRestApi()) { + return; + } + $api = $this->api(); + $status = new DeploymentStatus($this->db(), $api); + $stageName = $api->getActiveStageName(); + $checksum = $status->getConfigChecksumForStageName($stageName); + $this->sendJson($this->getResponse(), (object) [ + 'active_configuration' => (object) [ + 'active_stage_name' => $stageName, + 'active_checksum' => $checksum + ], + ]); + } + /** * @throws \Icinga\Security\SecurityException */ diff --git a/library/Director/Deployment/DeploymentStatus.php b/library/Director/Deployment/DeploymentStatus.php new file mode 100644 index 00000000..ec7be55d --- /dev/null +++ b/library/Director/Deployment/DeploymentStatus.php @@ -0,0 +1,30 @@ +db = $db; + $this->api = $api; + } + + public function getConfigChecksumForStageName($stageName) + { + $db = $this->db->getDbAdapter(); + $query = $db->select()->from( + array('l' => 'director_deployment_log'), + array('checksum' => $this->db->dbHexFunc('l.config_checksum')) + )->where('l.stage_name = ?', $stageName); + + return $db->fetchOne($query); + } +}