deployment: show more information, cleanup
This commit is contained in:
parent
922a6d25c0
commit
47e31f023b
|
@ -37,7 +37,7 @@ class ConfigController extends ActionController
|
||||||
if ($deploymentId = $this->params->get('deployment_id')) {
|
if ($deploymentId = $this->params->get('deployment_id')) {
|
||||||
$tabs->add('deployment', array(
|
$tabs->add('deployment', array(
|
||||||
'label' => $this->translate('Deployment'),
|
'label' => $this->translate('Deployment'),
|
||||||
'url' => 'director/deployment/show',
|
'url' => 'director/deployment',
|
||||||
'urlParams' => array(
|
'urlParams' => array(
|
||||||
'id' => $deploymentId
|
'id' => $deploymentId
|
||||||
)
|
)
|
||||||
|
|
|
@ -4,17 +4,22 @@ namespace Icinga\Module\Director\Controllers;
|
||||||
|
|
||||||
use Icinga\Module\Director\Web\Controller\ActionController;
|
use Icinga\Module\Director\Web\Controller\ActionController;
|
||||||
use Icinga\Module\Director\Objects\DirectorDeploymentLog;
|
use Icinga\Module\Director\Objects\DirectorDeploymentLog;
|
||||||
|
use Icinga\Module\Director\IcingaConfig\IcingaConfig;
|
||||||
use Icinga\Module\Director\Util;
|
use Icinga\Module\Director\Util;
|
||||||
|
|
||||||
class DeploymentController extends ActionController
|
class DeploymentController extends ActionController
|
||||||
{
|
{
|
||||||
public function showAction()
|
public function indexAction()
|
||||||
{
|
{
|
||||||
|
$this->view->title = $this->translate('Deployment details');
|
||||||
|
|
||||||
$deploymentId = $this->params->get('id');
|
$deploymentId = $this->params->get('id');
|
||||||
$this->view->deployment = $deployment = DirectorDeploymentLog::load(
|
$this->view->deployment = $deployment = DirectorDeploymentLog::load(
|
||||||
$deploymentId,
|
$deploymentId,
|
||||||
$this->db()
|
$this->db()
|
||||||
);
|
);
|
||||||
|
$this->view->config_checksum = Util::binary2hex($deployment->config_checksum);
|
||||||
|
$this->view->config = IcingaConfig::load($deployment->config_checksum, $this->db());
|
||||||
|
|
||||||
$tabs = $this->getTabs()->add('deployment', array(
|
$tabs = $this->getTabs()->add('deployment', array(
|
||||||
'label' => $this->translate('Deployment'),
|
'label' => $this->translate('Deployment'),
|
||||||
|
@ -24,9 +29,9 @@ class DeploymentController extends ActionController
|
||||||
if ($deployment->config_checksum !== null) {
|
if ($deployment->config_checksum !== null) {
|
||||||
$tabs->add('config', array(
|
$tabs->add('config', array(
|
||||||
'label' => $this->translate('Config'),
|
'label' => $this->translate('Config'),
|
||||||
'url' => 'director/config/show',
|
'url' => 'director/config/files',
|
||||||
'urlParams' => array(
|
'urlParams' => array(
|
||||||
'checksum' => Util::binary2hex($deployment->config_checksum),
|
'checksum' => $this->view->config_checksum,
|
||||||
'deployment_id' => $deploymentId
|
'deployment_id' => $deploymentId
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
|
|
|
@ -25,6 +25,8 @@ class DeploymentLogTable extends QuickTable
|
||||||
$classes = array('succeeded');
|
$classes = array('succeeded');
|
||||||
} elseif ($row->startup_succeeded === 'n') {
|
} elseif ($row->startup_succeeded === 'n') {
|
||||||
$classes = array('failed');
|
$classes = array('failed');
|
||||||
|
} elseif ($row->stage_collected === null) {
|
||||||
|
$classes = array('pending');
|
||||||
} elseif ($row->dump_succeeded === 'y') {
|
} elseif ($row->dump_succeeded === 'y') {
|
||||||
$classes = array('sent');
|
$classes = array('sent');
|
||||||
} else {
|
} else {
|
||||||
|
@ -64,7 +66,7 @@ class DeploymentLogTable extends QuickTable
|
||||||
|
|
||||||
protected function getActionUrl($row)
|
protected function getActionUrl($row)
|
||||||
{
|
{
|
||||||
return $this->url('director/deployment/show', array('id' => $row->id));
|
return $this->url('director/deployment', array('id' => $row->id));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTitles()
|
public function getTitles()
|
||||||
|
|
|
@ -0,0 +1,79 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Icinga\Util\Format;
|
||||||
|
|
||||||
|
?><div class="controls">
|
||||||
|
<?= $this->tabs ?>
|
||||||
|
<h1><?= $this->escape($this->title) ?></h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="content">
|
||||||
|
<table class="name-value-table">
|
||||||
|
<tr>
|
||||||
|
<th><?= $this->translate('Deployment time') ?></th>
|
||||||
|
<td><?= $deployment->start_time ?></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th><?= $this->translate('Sent to') ?></th>
|
||||||
|
<td><?= $deployment->peer_identity ?></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th><?= $this->translate('Configuration') ?></th>
|
||||||
|
<td><?= $this->qlink(
|
||||||
|
sprintf(
|
||||||
|
$this->translate('%d files'),
|
||||||
|
$this->config->getFileCount()
|
||||||
|
),
|
||||||
|
'director/config/files',
|
||||||
|
array(
|
||||||
|
'checksum' => $config_checksum,
|
||||||
|
'deployment_id' => $deployment->id
|
||||||
|
)
|
||||||
|
) ?>, <?= sprintf(
|
||||||
|
$this->translate('%d objects, %d templates'),
|
||||||
|
$config->getObjectCount(),
|
||||||
|
$config->getTemplateCount()
|
||||||
|
)?>, <?= Format::bytes($config->getSize()) ?></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th><?= $this->translate('Duration') ?></th>
|
||||||
|
<td><?= sprintf(
|
||||||
|
$this->translate('Rendered in %0.2fs, deployed in %0.2fs'),
|
||||||
|
$config->getDuration() / 1000,
|
||||||
|
$deployment->duration_dump / 1000
|
||||||
|
) ?></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th><?= $this->translate('Stage name') ?></th>
|
||||||
|
<td><?= $deployment->stage_name ?></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th><?= $this->translate('Startup') ?></th>
|
||||||
|
<td><?php
|
||||||
|
|
||||||
|
if ($deployment->startup_succeeded === null) {
|
||||||
|
if ($deployment->stage_collected === null) {
|
||||||
|
echo $this->translate('Unknown, still waiting for config check outcome') . ' ' . $this->icon('spinner');
|
||||||
|
} else {
|
||||||
|
echo $this->translate('Unknown, failed to collect related information') . ' ' . $this->icon('help');
|
||||||
|
}
|
||||||
|
} elseif ($deployment->startup_succeeded === 'y') {
|
||||||
|
echo '<div style="color: green">';
|
||||||
|
echo $this->translate('Succeeded') . ' ' . $this->icon('ok');
|
||||||
|
echo '</div>';
|
||||||
|
} else {
|
||||||
|
echo '<div style="color: red">';
|
||||||
|
echo $this->translate('Failed') . ' ' . $this->icon('cancel');
|
||||||
|
echo '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
?></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<?php if ($deployment->startup_succeeded !== null): ?>
|
||||||
|
<h2>Startup log</h2>
|
||||||
|
<pre>
|
||||||
|
<?= $this->escape($deployment->startup_log) ?>
|
||||||
|
</pre>
|
||||||
|
<?php endif ?>
|
||||||
|
</div>
|
|
@ -1,15 +0,0 @@
|
||||||
<div class="controls">
|
|
||||||
<?= $this->tabs ?>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="content">
|
|
||||||
<h1><?= $this->escape($this->title) ?></h1>
|
|
||||||
<?php if ($this->deployment->startup_succeeded === 'y'): ?>
|
|
||||||
<div style="color: green; font-weight: bold">Startup succeeded</div>
|
|
||||||
<?php else: ?>
|
|
||||||
<div style="color: red; font-weight: bold">Startup failed</div>
|
|
||||||
<?php endif ?>
|
|
||||||
<pre>
|
|
||||||
<?= $this->escape($this->deployment->startup_log) ?>
|
|
||||||
</pre>
|
|
||||||
</div>
|
|
|
@ -38,6 +38,43 @@ class IcingaConfig
|
||||||
$this->db = $connection->getDbAdapter();
|
$this->db = $connection->getDbAdapter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getSize()
|
||||||
|
{
|
||||||
|
$size = 0;
|
||||||
|
foreach ($this->getFiles() as $file) {
|
||||||
|
$size += $file->getSize();
|
||||||
|
}
|
||||||
|
return $size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDuration()
|
||||||
|
{
|
||||||
|
return $this->duration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFileCount()
|
||||||
|
{
|
||||||
|
return count($this->files);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getObjectCount()
|
||||||
|
{
|
||||||
|
$cnt = 0;
|
||||||
|
foreach ($this->getFiles() as $file) {
|
||||||
|
$cnt += $file->getObjectCount();
|
||||||
|
}
|
||||||
|
return $cnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTemplateCount()
|
||||||
|
{
|
||||||
|
$cnt = 0;
|
||||||
|
foreach ($this->getFiles() as $file) {
|
||||||
|
$cnt += $file->getTemplateCount();
|
||||||
|
}
|
||||||
|
return $cnt;
|
||||||
|
}
|
||||||
|
|
||||||
public function getChecksum()
|
public function getChecksum()
|
||||||
{
|
{
|
||||||
return $this->checksum;
|
return $this->checksum;
|
||||||
|
@ -265,7 +302,7 @@ throw $e;
|
||||||
{
|
{
|
||||||
$query = $this->db->select()->from(
|
$query = $this->db->select()->from(
|
||||||
self::$table,
|
self::$table,
|
||||||
array('checksum', 'last_activity_checksum')
|
array('checksum', 'last_activity_checksum', 'duration')
|
||||||
)->where('checksum = ?', $this->dbBin($checksum));
|
)->where('checksum = ?', $this->dbBin($checksum));
|
||||||
$result = $this->db->fetchRow($query);
|
$result = $this->db->fetchRow($query);
|
||||||
|
|
||||||
|
@ -274,6 +311,7 @@ throw $e;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->checksum = $result->checksum;
|
$this->checksum = $result->checksum;
|
||||||
|
$this->duration = $result->duration;
|
||||||
$this->lastActivityChecksum = $result->last_activity_checksum;
|
$this->lastActivityChecksum = $result->last_activity_checksum;
|
||||||
|
|
||||||
if (is_resource($this->checksum)) {
|
if (is_resource($this->checksum)) {
|
||||||
|
|
|
@ -48,6 +48,11 @@ class IcingaConfigFile
|
||||||
return $this->cntTemplate;
|
return $this->cntTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getSize()
|
||||||
|
{
|
||||||
|
return strlen($this->content);
|
||||||
|
}
|
||||||
|
|
||||||
public function setObjectCount($cnt)
|
public function setObjectCount($cnt)
|
||||||
{
|
{
|
||||||
$this->cntObject = $cnt;
|
$this->cntObject = $cnt;
|
||||||
|
|
|
@ -427,6 +427,13 @@ table.deployment-log {
|
||||||
content: '\e803';
|
content: '\e803';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tr.pending td:first-child::before {
|
||||||
|
color: @gray;
|
||||||
|
// icon-spinner
|
||||||
|
content: '\e874';
|
||||||
|
.animate(spin 2s infinite linear);
|
||||||
|
}
|
||||||
|
|
||||||
tr.failed td:first-child::before {
|
tr.failed td:first-child::before {
|
||||||
// icon-ok
|
// icon-ok
|
||||||
color: @color-critical;
|
color: @color-critical;
|
||||||
|
|
Loading…
Reference in New Issue