mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-29 08:44:11 +02:00
HostServiceRedirector: add applied service sets
This commit is contained in:
parent
0f4fd471e2
commit
14cd540ce9
@ -45,6 +45,8 @@ class HostServiceRedirector
|
|||||||
return $url;
|
return $url;
|
||||||
} elseif ($url = $this->getServiceSetServiceUrl($serviceName)) {
|
} elseif ($url = $this->getServiceSetServiceUrl($serviceName)) {
|
||||||
return $url;
|
return $url;
|
||||||
|
} elseif ($url = $this->getAppliedServiceSetUrl($serviceName)) {
|
||||||
|
return $url;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Url::fromPath('director/host/invalidservice', [
|
return Url::fromPath('director/host/invalidservice', [
|
||||||
@ -167,6 +169,27 @@ class HostServiceRedirector
|
|||||||
{
|
{
|
||||||
$matcher = $this->getHostApplyMatcher();
|
$matcher = $this->getHostApplyMatcher();
|
||||||
foreach ($this->fetchAllApplyRulesForService($serviceName) as $rule) {
|
foreach ($this->fetchAllApplyRulesForService($serviceName) as $rule) {
|
||||||
|
if ($matcher->matchesFilter($rule->filter)) {
|
||||||
|
return Url::fromPath('director/host/servicesetservice', [
|
||||||
|
'name' => $this->host->getObjectName(),
|
||||||
|
'service' => $serviceName,
|
||||||
|
'set' => $rule->service_set_name
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $serviceName
|
||||||
|
* @return Url|null
|
||||||
|
* @throws \Icinga\Exception\ProgrammingError
|
||||||
|
*/
|
||||||
|
protected function getAppliedServiceSetUrl($serviceName)
|
||||||
|
{
|
||||||
|
$matcher = $this->getHostApplyMatcher();
|
||||||
|
foreach ($this->fetchAllServiceSetApplyRulesForService($serviceName) as $rule) {
|
||||||
if ($matcher->matchesFilter($rule->filter)) {
|
if ($matcher->matchesFilter($rule->filter)) {
|
||||||
return Url::fromPath('director/host/appliedservice', [
|
return Url::fromPath('director/host/appliedservice', [
|
||||||
'name' => $this->host->getObjectName(),
|
'name' => $this->host->getObjectName(),
|
||||||
@ -207,4 +230,30 @@ class HostServiceRedirector
|
|||||||
|
|
||||||
return $allRules;
|
return $allRules;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function fetchAllServiceSetApplyRulesForService($serviceName)
|
||||||
|
{
|
||||||
|
$db = $this->db->getDbAdapter();
|
||||||
|
$query = $db->select()->from(
|
||||||
|
['s' => 'icinga_service'],
|
||||||
|
[
|
||||||
|
'id' => 's.id',
|
||||||
|
'name' => 's.object_name',
|
||||||
|
'assign_filter' => 'ss.assign_filter',
|
||||||
|
'service_set_name' => 'ss.object_name',
|
||||||
|
]
|
||||||
|
)->join(
|
||||||
|
['ss' => 'icinga_service_set'],
|
||||||
|
's.service_set_id = ss.id',
|
||||||
|
[]
|
||||||
|
)->where('s.object_name = ?', $serviceName)
|
||||||
|
->where('ss.assign_filter IS NOT NULL');
|
||||||
|
|
||||||
|
$allRules = $db->fetchAll($query);
|
||||||
|
foreach ($allRules as $rule) {
|
||||||
|
$rule->filter = Filter::fromQueryString($rule->assign_filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $allRules;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user