mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-31 01:34:12 +02:00
HostController: show services for hosts created...
...in a branch
This commit is contained in:
parent
e3cae7c20a
commit
f77d5b8d0c
@ -207,12 +207,7 @@ class HostController extends ObjectController
|
|||||||
$host = $this->getHostObject();
|
$host = $this->getHostObject();
|
||||||
$this->addTitle($this->translate('Services: %s'), $host->getObjectName());
|
$this->addTitle($this->translate('Services: %s'), $host->getObjectName());
|
||||||
$branch = $this->getBranch();
|
$branch = $this->getBranch();
|
||||||
if ($branch->isBranch() && $host->get('id') === null) {
|
$hostHasBeenCreatedInBranch = $branch->isBranch() && $host->get('id');
|
||||||
$this->content()->add(Hint::info(
|
|
||||||
$this->translate('Managing services on new Hosts is possible only after they have been merged.')
|
|
||||||
));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$content = $this->content();
|
$content = $this->content();
|
||||||
$table = (new ObjectsTableService($this->db()))->setAuth($this->Auth())->setHost($host)
|
$table = (new ObjectsTableService($this->db()))->setAuth($this->Auth())->setHost($host)
|
||||||
->setTitle($this->translate('Individual Service objects'));
|
->setTitle($this->translate('Individual Service objects'));
|
||||||
@ -242,7 +237,9 @@ class HostController extends ObjectController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->addHostServiceSetTables($host);
|
if (! $hostHasBeenCreatedInBranch) {
|
||||||
|
$this->addHostServiceSetTables($host);
|
||||||
|
}
|
||||||
foreach ($parents as $parent) {
|
foreach ($parents as $parent) {
|
||||||
$this->addHostServiceSetTables($parent, $host);
|
$this->addHostServiceSetTables($parent, $host);
|
||||||
}
|
}
|
||||||
@ -356,6 +353,9 @@ class HostController extends ObjectController
|
|||||||
if ($affectedHost === null) {
|
if ($affectedHost === null) {
|
||||||
$affectedHost = $host;
|
$affectedHost = $host;
|
||||||
}
|
}
|
||||||
|
if ($host->get('id') === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$query = $db->getDbAdapter()->select()
|
$query = $db->getDbAdapter()->select()
|
||||||
->from(
|
->from(
|
||||||
|
@ -179,6 +179,7 @@ class IcingaHostAppliedServicesTable extends SimpleQueryBasedTable
|
|||||||
protected function fetchAllApplyRules()
|
protected function fetchAllApplyRules()
|
||||||
{
|
{
|
||||||
$db = $this->db;
|
$db = $this->db;
|
||||||
|
$hostId = $this->host->get('id');
|
||||||
$query = $db->select()->from(
|
$query = $db->select()->from(
|
||||||
['s' => 'icinga_service'],
|
['s' => 'icinga_service'],
|
||||||
[
|
[
|
||||||
@ -187,14 +188,17 @@ class IcingaHostAppliedServicesTable extends SimpleQueryBasedTable
|
|||||||
'assign_filter' => 's.assign_filter',
|
'assign_filter' => 's.assign_filter',
|
||||||
'apply_for' => 's.apply_for',
|
'apply_for' => 's.apply_for',
|
||||||
'disabled' => 's.disabled',
|
'disabled' => 's.disabled',
|
||||||
'blacklisted' => "CASE WHEN hsb.service_id IS NULL THEN 'n' ELSE 'y' END",
|
'blacklisted' => $hostId ? "CASE WHEN hsb.service_id IS NULL THEN 'n' ELSE 'y' END" : "('n')",
|
||||||
]
|
]
|
||||||
)->joinLeft(
|
|
||||||
['hsb' => 'icinga_host_service_blacklist'],
|
|
||||||
$db->quoteInto('s.id = hsb.service_id AND hsb.host_id = ?', $this->host->get('id')),
|
|
||||||
[]
|
|
||||||
)->where('object_type = ? AND assign_filter IS NOT NULL', 'apply')
|
)->where('object_type = ? AND assign_filter IS NOT NULL', 'apply')
|
||||||
->order('s.object_name');
|
->order('s.object_name');
|
||||||
|
if ($hostId) {
|
||||||
|
$query->joinLeft(
|
||||||
|
['hsb' => 'icinga_host_service_blacklist'],
|
||||||
|
$db->quoteInto('s.id = hsb.service_id AND hsb.host_id = ?', $hostId),
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return $db->fetchAll($query);
|
return $db->fetchAll($query);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user