CoreApi: fetch endpoint objects with zones

This commit is contained in:
Thomas Gelf 2015-12-15 19:00:11 +01:00
parent 81be63c74d
commit ce772dd085
1 changed files with 36 additions and 0 deletions

View File

@ -175,6 +175,42 @@ constants
));
}
protected function buildEndpointZoneMap()
{
$zones = $this->getObjects('zone', 'zones', $attrs = array('endpoints'), 'director');
$zoneMap = array();
foreach ($zones as $name => $zone) {
if (! is_array($zone->attrs->endpoints)) {
continue;
}
foreach ($zone->attrs->endpoints as $endpoint) {
$zoneMap[$endpoint] = $name;
}
}
return $zoneMap;
}
public function getEndpointObjects()
{
$zoneMap = $this->buildEndpointZoneMap();
$objects = $this->getDirectorObjects('Endpoint', 'Endpoint', 'endpoints', array(
'host' => 'host',
'port' => 'port',
'log_duration' => 'log_duration',
));
foreach ($objects as $object) {
$name = $object->object_name;
if (array_key_exists($name, $zoneMap)) {
$object->zone = $zoneMap[$name];
}
}
return $objects;
}
public function getCheckCommandObjects()
{
IcingaCommand::setPluginDir($this->getConstant('PluginDir'));