[icinga-checkins] icinga.org: icingaweb2-module-director/master: show/activitylog: fallback rendering for hosts...

git at icinga.org git at icinga.org
Thu Oct 6 18:47:27 CEST 2016


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

Author: Thomas Gelf <thomas at gelf.net>
Date:   Thu Oct  6 16:29:50 2016 +0000

show/activitylog: fallback rendering for hosts...

...with obsolete parents, that have been removed in the meantime

---

 application/controllers/ShowController.php |    4 ++++
 library/Director/Objects/IcingaHost.php    |    5 +++++
 library/Director/Objects/IcingaObject.php  |   16 +++++++++++++---
 3 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/application/controllers/ShowController.php b/application/controllers/ShowController.php
index f533d27..8d26788 100644
--- a/application/controllers/ShowController.php
+++ b/application/controllers/ShowController.php
@@ -77,6 +77,10 @@ class ShowController extends ActionController
     protected function getObjectConfig($object)
     {
         $config = new IcingaConfig($this->db());
+        if ($object->isExternal()) {
+            $object->object_type = 'object';
+        }
+
         $object->renderToConfig($config);
         return $config;
     }
diff --git a/library/Director/Objects/IcingaHost.php b/library/Director/Objects/IcingaHost.php
index 5d88580..e8cd776 100644
--- a/library/Director/Objects/IcingaHost.php
+++ b/library/Director/Objects/IcingaHost.php
@@ -110,6 +110,7 @@ class IcingaHost extends IcingaObject
         }
 
         $hostVars = array();
+
         if ($connection !== null) {
             foreach ($connection->fetchDistinctHostVars() as $var) {
                 if ($var->datatype) {
@@ -167,6 +168,10 @@ class IcingaHost extends IcingaObject
             return;
         }
 
+        if ($this->getRenderingZone($config) === self::RESOLVE_ERROR) {
+            return;
+        }
+
         if ($this->getResolvedProperty('has_agent') !== 'y') {
             return;
         }
diff --git a/library/Director/Objects/IcingaObject.php b/library/Director/Objects/IcingaObject.php
index d1854d7..bb19d8a 100644
--- a/library/Director/Objects/IcingaObject.php
+++ b/library/Director/Objects/IcingaObject.php
@@ -16,6 +16,8 @@ use Exception;
 
 abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
 {
+    const RESOLVE_ERROR = '(unable to resolve)';
+
     protected $keyName = 'object_name';
 
     protected $autoincKeyName = 'id';
@@ -1295,9 +1297,17 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
 
     public function getRenderingZone(IcingaConfig $config = null)
     {
-        if ($zoneId = $this->getResolvedProperty('zone_id')) {
-            // Config has a lookup cache, is faster:
-            return $config->getZoneName($zoneId);
+        if ($this->hasUnresolvedRelatedProperty('zone_id')) {
+            return $this->zone;
+        }
+
+        try {
+            if ($zoneId = $this->getResolvedProperty('zone_id')) {
+                // Config has a lookup cache, is faster:
+                return $config->getZoneName($zoneId);
+            }
+        } catch (Exception $e) {
+            return self::RESOLVE_ERROR;
         }
 
         if ($this->prefersGlobalZone()) {



More information about the icinga-checkins mailing list