From df36071c9c38c5c03b35947a5a56cf2e8cf0cd03 Mon Sep 17 00:00:00 2001 From: Markus Frosch Date: Fri, 7 Oct 2016 15:19:03 +0200 Subject: [PATCH] IcingaService: single objects should respect... ...their host's zone where not overriden by a service template fixes #11988 --- library/Director/Objects/IcingaService.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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; + } }