IcingaService: single objects should respect...

...their host's zone where not overriden by a service template

fixes #11988
This commit is contained in:
Markus Frosch 2016-10-07 15:19:03 +02:00 committed by Thomas Gelf
parent 82c5b10eef
commit df36071c9c
1 changed files with 18 additions and 0 deletions

View File

@ -3,6 +3,7 @@
namespace Icinga\Module\Director\Objects;
use Icinga\Exception\ProgrammingError;
use Icinga\Module\Director\IcingaConfig\IcingaConfig;
use Icinga\Module\Director\IcingaConfig\IcingaConfigHelper as c;
class IcingaService extends IcingaObject
@ -232,4 +233,21 @@ class IcingaService extends IcingaObject
return parent::getOnDeleteUrl();
}
}
public function getRenderingZone(IcingaConfig $config = null)
{
if ($this->prefersGlobalZone()) {
return $this->connection->getDefaultGlobalZoneName();
}
$zone = parent::getRenderingZone($config);
// if bound to a host, and zone is fallback to master
if ($this->host_id !== null && $zone === $this->connection->getMasterZoneName()) {
/** @var IcingaHost $host */
$host = $this->getRelatedObject('host', $this->host_id);
return $host->getRenderingZone($config);
}
return $zone;
}
}