IcingaConfig: respect inheritance for auto-agents

This commit is contained in:
Thomas Gelf 2015-12-18 11:28:01 +01:00
parent c03aaada92
commit 6e6c2ee6e5

View File

@ -356,15 +356,17 @@ throw $e;
$zones = array(); $zones = array();
$endpoints = array(); $endpoints = array();
foreach (IcingaHost::prefetchAll($this->connection) as $host) { foreach (IcingaHost::prefetchAll($this->connection) as $host) {
if ($host->object_type !== 'object') continue;
if ($host->getResolvedProperty('has_agent') !== 'y') continue;
$name = $host->object_name; $name = $host->object_name;
if ($host->has_agent === 'y') {
$props = array( $props = array(
'object_name' => $name, 'object_name' => $name,
'object_type' => 'object', 'object_type' => 'object',
); );
if ($host->master_should_connect === 'y') { if ($host->getResolvedProperty('master_should_connect') === 'y') {
$props['host'] = $host->address; $props['host'] = $host->getResolvedProperty('address');
$props['zone_id'] = $host->zone_id; $props['zone_id'] = $host->getResolvedProperty('zone_id');
} }
$endpoints[] = IcingaEndpoint::create($props); $endpoints[] = IcingaEndpoint::create($props);
@ -372,7 +374,6 @@ throw $e;
'object_name' => $name 'object_name' => $name
))->setEndpointList(array($name)); ))->setEndpointList(array($name));
} }
}
$this->createFileForObjects('endpoint', $endpoints); $this->createFileForObjects('endpoint', $endpoints);
$this->createFileForObjects('zone', $zones); $this->createFileForObjects('zone', $zones);