icingaweb2-module-businessp.../library/Businessprocess/HostNode.php

68 lines
1.5 KiB
PHP
Raw Normal View History

<?php
2014-11-30 09:56:58 -05:00
namespace Icinga\Module\Businessprocess;
2015-03-16 08:11:39 -04:00
use Icinga\Web\Url;
class HostNode extends Node
{
protected $hostname;
protected $className = 'host';
public function __construct(BusinessProcess $bp, $object)
{
$this->name = $object->hostname . ';Hoststatus';
$this->hostname = $object->hostname;
$this->bp = $bp;
if (isset($object->state)) {
$this->setState($object->state);
} else {
$this->setState(0)->setMissing();
}
}
2014-11-30 05:30:59 -05:00
public function renderLink($view)
{
2015-03-16 08:11:39 -04:00
if ($this->isMissing()) {
return '<span class="missing">' . $view->escape($this->hostname) . '</span>';
}
$params = array(
'host' => $this->getHostname(),
);
if ($this->bp->hasBackendName()) {
$params['backend'] = $this->bp->getBackendName();
}
return $view->qlink($this->hostname, 'monitoring/host/show', $params);
}
protected function getActionIcons($view)
{
$icons = array();
if (! $this->bp->isLocked()) {
$url = Url::fromPath( 'businessprocess/node/simulate', array(
2015-03-16 04:08:00 -04:00
'config' => $this->bp->getName(),
2015-03-16 08:11:39 -04:00
'node' => $this->name
2014-11-30 05:30:59 -05:00
));
2015-03-16 08:11:39 -04:00
$icons[] = $this->actionIcon(
$view,
'magic',
$url,
'Simulation'
);
2014-11-30 05:30:59 -05:00
}
2015-03-16 08:11:39 -04:00
return $icons;
2014-11-30 05:30:59 -05:00
}
public function getHostname()
{
return $this->hostname;
}
}