2015-09-29 20:35:05 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Icinga\Module\Director\Tables;
|
|
|
|
|
|
|
|
use Icinga\Module\Director\Web\Table\QuickTable;
|
|
|
|
|
|
|
|
class DeploymentLogTable extends QuickTable
|
|
|
|
{
|
2015-10-16 18:07:08 +02:00
|
|
|
protected $activeStageName;
|
|
|
|
|
|
|
|
public function setActiveStageName($name)
|
|
|
|
{
|
|
|
|
$this->activeStageName = $name;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2015-12-16 13:04:01 +01:00
|
|
|
protected function listTableClasses()
|
|
|
|
{
|
|
|
|
return array_merge(array('deployment-log'), parent::listTableClasses());
|
|
|
|
}
|
|
|
|
|
2015-10-16 18:07:08 +02:00
|
|
|
protected function getRowClasses($row)
|
|
|
|
{
|
2015-12-16 13:04:01 +01:00
|
|
|
if ($row->startup_succeeded === 'y') {
|
|
|
|
$classes = array('succeeded');
|
|
|
|
} elseif ($row->startup_succeeded === 'n') {
|
|
|
|
$classes = array('failed');
|
2015-12-16 16:19:58 +01:00
|
|
|
} elseif ($row->stage_collected === null) {
|
|
|
|
$classes = array('pending');
|
2015-12-16 13:04:01 +01:00
|
|
|
} elseif ($row->dump_succeeded === 'y') {
|
|
|
|
$classes = array('sent');
|
|
|
|
} else {
|
|
|
|
// TODO: does this ever be stored?
|
|
|
|
$classes = array('notsent');
|
|
|
|
}
|
|
|
|
|
2015-10-16 18:07:08 +02:00
|
|
|
if ($this->activeStageName !== null
|
2016-02-26 12:42:21 +01:00
|
|
|
&& $row->stage_name === $this->activeStageName
|
|
|
|
) {
|
2015-12-16 13:04:01 +01:00
|
|
|
$classes[] = 'running';
|
2015-10-16 18:07:08 +02:00
|
|
|
}
|
|
|
|
|
2015-12-16 13:04:01 +01:00
|
|
|
return $classes;
|
2015-10-16 18:07:08 +02:00
|
|
|
}
|
|
|
|
|
2015-09-29 20:35:05 +02:00
|
|
|
public function getColumns()
|
|
|
|
{
|
2016-05-10 21:32:14 +02:00
|
|
|
$db = $this->connection();
|
|
|
|
|
2015-09-29 20:35:05 +02:00
|
|
|
$columns = array(
|
|
|
|
'id' => 'l.id',
|
|
|
|
'peer_identity' => 'l.peer_identity',
|
2016-05-10 21:32:14 +02:00
|
|
|
'identifier' => "l.peer_identity || ' (' || SUBSTRING(",
|
2015-09-29 20:35:05 +02:00
|
|
|
'start_time' => 'l.start_time',
|
|
|
|
'stage_collected' => 'l.stage_collected',
|
|
|
|
'dump_succeeded' => 'l.dump_succeeded',
|
2015-10-16 18:07:08 +02:00
|
|
|
'stage_name' => 'l.stage_name',
|
2015-09-29 20:35:05 +02:00
|
|
|
'startup_succeeded' => 'l.startup_succeeded',
|
2016-05-10 21:32:14 +02:00
|
|
|
'checksum' => $db->dbHexFunc('c.checksum'),
|
2015-09-29 20:35:05 +02:00
|
|
|
'duration' => "l.duration_dump || 'ms'",
|
|
|
|
);
|
|
|
|
|
2016-03-02 13:42:37 +01:00
|
|
|
if ($this->connection->isPgsql()) {
|
2016-05-10 21:32:14 +02:00
|
|
|
$columns['identifier'] .= $columns['checksum'] . ' FROM 1 FOR 7)';
|
|
|
|
} else {
|
|
|
|
$columns['identifier'] .= $columns['checksum'] . ', 1, 7)';
|
2015-09-29 20:35:05 +02:00
|
|
|
}
|
|
|
|
|
2016-05-10 21:32:14 +02:00
|
|
|
$columns['identifier'] .= " || ')'";
|
|
|
|
|
2015-09-29 20:35:05 +02:00
|
|
|
return $columns;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getActionUrl($row)
|
|
|
|
{
|
2015-12-16 16:19:58 +01:00
|
|
|
return $this->url('director/deployment', array('id' => $row->id));
|
2015-09-29 20:35:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getTitles()
|
|
|
|
{
|
|
|
|
$view = $this->view();
|
|
|
|
return array(
|
2016-05-10 21:32:14 +02:00
|
|
|
'identifier' => $view->translate('Icinga Node'),
|
|
|
|
'start_time' => $view->translate('Time'),
|
2015-09-29 20:35:05 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getBaseQuery()
|
|
|
|
{
|
|
|
|
$db = $this->connection()->getConnection();
|
|
|
|
|
|
|
|
$query = $db->select()->from(
|
|
|
|
array('l' => 'director_deployment_log'),
|
|
|
|
array()
|
|
|
|
)->joinLeft(
|
|
|
|
array('c' => 'director_generated_config'),
|
2015-10-16 18:11:05 +02:00
|
|
|
'c.checksum = l.config_checksum',
|
2015-09-29 20:35:05 +02:00
|
|
|
array()
|
|
|
|
)->order('l.start_time DESC');
|
|
|
|
|
|
|
|
return $query;
|
|
|
|
}
|
|
|
|
}
|