IcingaObject(legacy): Only render passive objects for checkables

Also simplify renderToLegacyConfig.

refs #12919
This commit is contained in:
Markus Frosch 2016-10-13 15:22:15 +02:00
parent c32cc3ca92
commit 2e2f4739c7

View File

@ -1459,40 +1459,25 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
$filename = $this->getRenderingFilename(); $filename = $this->getRenderingFilename();
if ($config->isLegacy()) { if (
$this->getResolvedProperty('zone_id')
if ($this->getResolvedProperty('zone_id')) { && array_key_exists('enable_active_checks', $this->defaultProperties)
) {
$a = clone($this); $passive = clone($this);
$a->set('enable_active_checks', true); $passive->enable_active_checks = false;
$b = clone($this);
$a->set('enable_active_checks', false);
$config->configFile( $config->configFile(
'director/master/' . $filename, 'director/master/' . $filename,
'.cfg' '.cfg'
)->addLegacyObject($a); )->addLegacyObject($passive);
}
$config->configFile(
'director/' . $this->getRenderingZone($config) . '/' . $filename,
'.cfg'
)->addLegacyObject($b);
} else {
$config->configFile( $config->configFile(
'director/' . $this->getRenderingZone($config) . '/' . $filename, 'director/' . $this->getRenderingZone($config) . '/' . $filename,
'.cfg' '.cfg'
)->addLegacyObject($this); )->addLegacyObject($this);
} }
} else {
$config->configFile(
'director/' . $this->getRenderingZone($config) . '/' . $filename
)->addObject($this);
}
}
public function renderToConfig(IcingaConfig $config) public function renderToConfig(IcingaConfig $config)
{ {
if ($config->isLegacy()) { if ($config->isLegacy()) {