2021-01-16 09:04:29 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Icinga\Module\Director\DirectorObject\Lookup;
|
|
|
|
|
|
|
|
|
|
use gipfl\IcingaWeb2\Url;
|
|
|
|
|
use Icinga\Authentication\Auth;
|
2023-02-22 05:46:24 -05:00
|
|
|
use Icinga\Module\Director\Auth\Permission;
|
|
|
|
|
use Icinga\Module\Director\Integration\MonitoringModule\Monitoring;
|
2021-01-16 09:04:29 -05:00
|
|
|
use Icinga\Module\Director\Objects\HostApplyMatches;
|
|
|
|
|
use Icinga\Module\Director\Objects\IcingaHost;
|
2022-07-11 04:06:48 -04:00
|
|
|
use RuntimeException;
|
2021-01-16 09:04:29 -05:00
|
|
|
|
|
|
|
|
class ServiceFinder
|
|
|
|
|
{
|
|
|
|
|
/** @var IcingaHost */
|
|
|
|
|
protected $host;
|
|
|
|
|
|
2022-07-11 04:06:48 -04:00
|
|
|
/** @var ?Auth */
|
2021-01-16 09:04:29 -05:00
|
|
|
protected $auth;
|
|
|
|
|
|
|
|
|
|
/** @var IcingaHost[] */
|
|
|
|
|
protected $parents;
|
|
|
|
|
|
|
|
|
|
/** @var HostApplyMatches */
|
|
|
|
|
protected $applyMatcher;
|
|
|
|
|
|
|
|
|
|
/** @var \Icinga\Module\Director\Db */
|
|
|
|
|
protected $db;
|
|
|
|
|
|
2026-01-29 09:22:40 -05:00
|
|
|
public function __construct(IcingaHost $host, ?Auth $auth = null)
|
2021-01-16 09:04:29 -05:00
|
|
|
{
|
|
|
|
|
$this->host = $host;
|
|
|
|
|
$this->auth = $auth;
|
|
|
|
|
$this->db = $host->getConnection();
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-18 10:03:24 -05:00
|
|
|
public static function find(IcingaHost $host, $serviceName)
|
|
|
|
|
{
|
2024-10-22 08:31:14 -04:00
|
|
|
foreach (
|
|
|
|
|
[
|
2021-01-18 10:03:24 -05:00
|
|
|
SingleServiceInfo::class,
|
|
|
|
|
InheritedServiceInfo::class,
|
|
|
|
|
ServiceSetServiceInfo::class,
|
|
|
|
|
AppliedServiceInfo::class,
|
|
|
|
|
AppliedServiceSetServiceInfo::class,
|
2024-10-22 08:31:14 -04:00
|
|
|
] as $class
|
|
|
|
|
) {
|
2021-01-18 10:03:24 -05:00
|
|
|
/** @var ServiceInfo $class */
|
|
|
|
|
if ($info = $class::find($host, $serviceName)) {
|
|
|
|
|
return $info;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2021-01-16 09:04:29 -05:00
|
|
|
}
|