ServiceActions: Show inspect link on all services

Not only services of hosts managed by Director. This aligns behavior
with HostActions itself.
This commit is contained in:
Markus Frosch 2018-02-20 16:01:53 +01:00 committed by Thomas Gelf
parent 41e379b008
commit 63a98c05a9
1 changed files with 13 additions and 19 deletions

View File

@ -5,7 +5,6 @@ namespace Icinga\Module\Director\ProvidedHook\Monitoring;
use Exception; use Exception;
use Icinga\Application\Config; use Icinga\Application\Config;
use Icinga\Module\Director\Db; use Icinga\Module\Director\Db;
use Icinga\Module\Director\Objects\IcingaHost;
use Icinga\Module\Director\Util; use Icinga\Module\Director\Util;
use Icinga\Module\Monitoring\Hook\ServiceActionsHook; use Icinga\Module\Monitoring\Hook\ServiceActionsHook;
use Icinga\Module\Monitoring\Object\Service; use Icinga\Module\Monitoring\Object\Service;
@ -24,33 +23,28 @@ class ServiceActions extends ServiceActionsHook
protected function getThem(Service $service) protected function getThem(Service $service)
{ {
if (! Util::hasPermission('director/inspect')) { $actions = array();
return array();
}
$db = $this->db(); $db = $this->db();
if (! $db) { if (! $db) {
return array(); return array();
} }
if (IcingaHost::exists($service->host_name, $db)) { if (Util::hasPermission('director/inspect')) {
return array( $actions['Inspect'] = Url::fromPath(
'Inspect' => Url::fromPath( 'director/inspect/object',
'director/inspect/object', array(
array( 'type' => 'service',
'type' => 'service', 'plural' => 'services',
'plural' => 'services', 'name' => sprintf(
'name' => sprintf( '%s!%s',
'%s!%s', $service->host_name,
$service->host_name, $service->service_description
$service->service_description
)
) )
) )
); );
} else {
return array();
} }
return $actions;
} }
protected function db() protected function db()