legacy: Ignore hosts that are disabled or blacklisted properly

This commit is contained in:
Markus Frosch 2019-03-06 14:58:35 +01:00
parent aeebc0f0bb
commit a9e9a73624
2 changed files with 20 additions and 2 deletions

View File

@ -256,14 +256,23 @@ class IcingaService extends IcingaObject
$this->set('object_type', 'object');
foreach ($this->mapHostsToZones($hostnames) as $zone => $names) {
$this->set('host_id', $names);
$blacklisted = $this->getBlacklistedHostnames();
$zoneNames = array_diff($names, $blacklisted);
$disabled = [];
foreach ($zoneNames as $name) {
if (IcingaHost::load($name, $this->getConnection())->isDisabled()) {
$disabled[] = $name;
}
}
$zoneNames = array_diff($zoneNames, $disabled);
if (empty($zoneNames)) {
continue;
}
$this->set('host_id', $zoneNames);
$config->configFile('director/' . $zone . '/service_apply', '.cfg')
->addLegacyObject($this);
}

View File

@ -258,6 +258,15 @@ class IcingaServiceSet extends IcingaObject
// check if all hosts in the zone ignore this service
$zoneNames = array_diff($names, $blacklists[$object_name]);
$disabled = [];
foreach ($zoneNames as $name) {
if (IcingaHost::load($name, $this->getConnection())->isDisabled()) {
$disabled[] = $name;
}
}
$zoneNames = array_diff($zoneNames, $disabled);
if (empty($zoneNames)) {
continue;
}