IcingaServiceSet: respect indivicual template zone
fixes #1589 fixes #2356
This commit is contained in:
parent
071df2a072
commit
51380a9e0b
|
@ -12,6 +12,9 @@ This version hasn't been released yet
|
|||
### UI
|
||||
* FEATURE: allow to clone commands with fields (#2264)
|
||||
|
||||
### Icinga Configuration
|
||||
* FIX: render Set Services to individual zones where required (#1589, #2356)
|
||||
|
||||
### Fixed issues
|
||||
* You can find issues and feature requests related to this release on our
|
||||
[roadmap](https://github.com/Icinga/icingaweb2-module-director/milestone/32?closed=1)
|
||||
|
|
|
@ -295,8 +295,8 @@ class IcingaServiceSet extends IcingaObject implements ExportInterface
|
|||
*/
|
||||
public function renderToConfig(IcingaConfig $config)
|
||||
{
|
||||
// always print the header, so you have minimal info present
|
||||
$file = $this->getConfigFileWithHeader($config);
|
||||
$files = [];
|
||||
$zone = $this->getRenderingZone($config) ;
|
||||
|
||||
if ($this->get('assign_filter') === null && $this->isTemplate()) {
|
||||
return;
|
||||
|
@ -334,8 +334,15 @@ class IcingaServiceSet extends IcingaObject implements ExportInterface
|
|||
}
|
||||
|
||||
$this->copyVarsToService($service);
|
||||
$zone = $service->getRenderingZone($config);
|
||||
$file = $this->getConfigFileWithHeader($config, $zone, $files);
|
||||
$file->addObject($service);
|
||||
}
|
||||
|
||||
if (empty($files)) {
|
||||
// always print the header, so you have minimal info present
|
||||
$this->getConfigFileWithHeader($config, $zone, $files);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -355,14 +362,18 @@ class IcingaServiceSet extends IcingaObject implements ExportInterface
|
|||
return $lookup->getBlacklistedHostnamesForService($service);
|
||||
}
|
||||
|
||||
protected function getConfigFileWithHeader(IcingaConfig $config)
|
||||
protected function getConfigFileWithHeader(IcingaConfig $config, $zone, &$files = [])
|
||||
{
|
||||
$file = $config->configFile(
|
||||
'zones.d/' . $this->getRenderingZone($config) . '/servicesets'
|
||||
);
|
||||
if (!isset($files[$zone])) {
|
||||
$file = $config->configFile(
|
||||
'zones.d/' . $zone . '/servicesets'
|
||||
);
|
||||
|
||||
$file->addContent($this->getConfigHeaderComment($config));
|
||||
return $file;
|
||||
$file->addContent($this->getConfigHeaderComment($config));
|
||||
$files[$zone] = $file;
|
||||
}
|
||||
|
||||
return $files[$zone];
|
||||
}
|
||||
|
||||
protected function getConfigHeaderComment(IcingaConfig $config)
|
||||
|
|
Loading…
Reference in New Issue