mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-31 01:34:12 +02:00
DeploymentStatus: new helper
* this also adds director/config/deployment-status refs #2187
This commit is contained in:
parent
e2d753bad7
commit
3f8f7bd1eb
@ -6,6 +6,7 @@ use Icinga\Data\Filter\Filter;
|
|||||||
use Icinga\Exception\IcingaException;
|
use Icinga\Exception\IcingaException;
|
||||||
use Icinga\Exception\NotFoundError;
|
use Icinga\Exception\NotFoundError;
|
||||||
use Icinga\Module\Director\ConfigDiff;
|
use Icinga\Module\Director\ConfigDiff;
|
||||||
|
use Icinga\Module\Director\Deployment\DeploymentStatus;
|
||||||
use Icinga\Module\Director\Forms\DeployConfigForm;
|
use Icinga\Module\Director\Forms\DeployConfigForm;
|
||||||
use Icinga\Module\Director\Forms\SettingsForm;
|
use Icinga\Module\Director\Forms\SettingsForm;
|
||||||
use Icinga\Module\Director\IcingaConfig\IcingaConfig;
|
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\ConfigFileDiffTable;
|
||||||
use Icinga\Module\Director\Web\Table\DeploymentLogTable;
|
use Icinga\Module\Director\Web\Table\DeploymentLogTable;
|
||||||
use Icinga\Module\Director\Web\Table\GeneratedConfigFileTable;
|
use Icinga\Module\Director\Web\Table\GeneratedConfigFileTable;
|
||||||
use Icinga\Module\Director\Util;
|
|
||||||
use Icinga\Module\Director\Web\Controller\ActionController;
|
use Icinga\Module\Director\Web\Controller\ActionController;
|
||||||
use Icinga\Module\Director\Web\Tabs\InfraTabs;
|
use Icinga\Module\Director\Web\Tabs\InfraTabs;
|
||||||
use Icinga\Module\Director\Web\Widget\ActivityLogInfo;
|
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
|
* @throws \Icinga\Security\SecurityException
|
||||||
*/
|
*/
|
||||||
|
30
library/Director/Deployment/DeploymentStatus.php
Normal file
30
library/Director/Deployment/DeploymentStatus.php
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Icinga\Module\Director\Deployment;
|
||||||
|
|
||||||
|
use Icinga\Module\Director\Core\CoreApi;
|
||||||
|
use Icinga\Module\Director\Db;
|
||||||
|
|
||||||
|
class DeploymentStatus
|
||||||
|
{
|
||||||
|
protected $db;
|
||||||
|
|
||||||
|
protected $api;
|
||||||
|
|
||||||
|
public function __construct(Db $db, CoreApi $api)
|
||||||
|
{
|
||||||
|
$this->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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user