IcingaConfig: start to work on zone magic...

...still incomplete
This commit is contained in:
Thomas Gelf 2015-07-28 15:24:05 +02:00
parent d381fddfff
commit 51c7a258ce
1 changed files with 21 additions and 4 deletions

View File

@ -276,13 +276,30 @@ class IcingaConfig
$class = 'Icinga\\Module\\Director\\Objects\\Icinga' . ucfirst($type);
$objects = $class::loadAll($this->connection);
if (! empty($objects)) {
$file = new IcingaConfigFile();
foreach ($objects as $object) {
if ($object->isTemplate()) {
$filename = strtolower($type) . '_templates';
$zone = 'master';
} else {
$filename = strtolower($type) . 's';
$zone = 'global';
}
if ($type === 'zone') {
$this->zoneMap[$object->id] = $object->object_name;
$zone = 'global'; // which one?
} elseif ($object->hasProperty('zone_id') && ($zone_id = $object->zone_id)) {
$zone = $this->getZoneName($zone_id);
} else {
$zone = 'master';
}
$filename = $zone . '/' . $filename;
$file = $this->configFile($filename);
if ($type === 'command') {
$file->prepend("library \"methods\"\n\n");
}
$file->addObjects($objects);
$this->files[strtolower($type) . 's.conf'] = $file;
$file->addObject($object);
}
return $this;