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 a56dacb9c5
commit b8e00e9b8c
2 changed files with 20 additions and 2 deletions

View File

@ -355,14 +355,23 @@ class IcingaService extends IcingaObject implements ExportInterface
$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

@ -401,6 +401,15 @@ class IcingaServiceSet extends IcingaObject implements ExportInterface
// 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;
}