[icinga-checkins] icinga.org: icingaweb2-module-director/master: IcingaService: single objects should respect...

git at icinga.org git at icinga.org
Mon Oct 10 13:13:06 CEST 2016


Module: icingaweb2-module-director
Branch: master
Commit: df36071c9c38c5c03b35947a5a56cf2e8cf0cd03
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=df36071c9c38c5c03b35947a5a56cf2e8cf0cd03

Author: Markus Frosch <lazyfrosch at icinga.org>
Date:   Fri Oct  7 15:19:03 2016 +0200

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 cd28b36..0be8554 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;
+    }
 }



More information about the icinga-checkins mailing list