diff --git a/library/Director/Objects/IcingaService.php b/library/Director/Objects/IcingaService.php index cd28b361..0be85540 100644 --- a/library/Director/Objects/IcingaService.php +++ b/library/Director/Objects/IcingaService.php @@ -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; + } }