[icinga-checkins] icinga.org: icingaweb2-module-director/feature/icinga1-config-12919: IcingaObject(legacy): Only render passive objects for checkables

git at icinga.org git at icinga.org
Fri Oct 14 15:36:21 CEST 2016


Module: icingaweb2-module-director
Branch: feature/icinga1-config-12919
Commit: 8d7397d9ba0764dfe1d25eb8046b0a5dcfa387bd
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=8d7397d9ba0764dfe1d25eb8046b0a5dcfa387bd

Author: Markus Frosch <markus.frosch at icinga.com>
Date:   Thu Oct 13 15:22:15 2016 +0200

IcingaObject(legacy): Only render passive objects for checkables

Also simplify renderToLegacyConfig.

refs #12919

---

 library/Director/Objects/IcingaObject.php |   43 ++++++++++-------------------
 1 file changed, 14 insertions(+), 29 deletions(-)

diff --git a/library/Director/Objects/IcingaObject.php b/library/Director/Objects/IcingaObject.php
index e366d17..71397b2 100644
--- a/library/Director/Objects/IcingaObject.php
+++ b/library/Director/Objects/IcingaObject.php
@@ -1391,38 +1391,23 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
 
         $filename = $this->getRenderingFilename();
 
-        if ($config->isLegacy()) {
-
-            if ($this->getResolvedProperty('zone_id')) {
-
-                $a = clone($this);
-                $a->enable_active_checks = true;
-
-                $b = clone($this);
-                $a->enable_active_checks = false;
-
-                $config->configFile(
-                    'director/master/' . $filename,
-                    '.cfg'
-                )->addLegacyObject($a);
-
-                $config->configFile(
-                    'director/' . $this->getRenderingZone($config) . '/' . $filename,
-                    '.cfg'
-                )->addLegacyObject($b);
-
-            } else {
-                $config->configFile(
-                    'director/' . $this->getRenderingZone($config) . '/' . $filename,
-                    '.cfg'
-                )->addLegacyObject($this);
-            }
+        if (
+            $this->getResolvedProperty('zone_id')
+            && array_key_exists('enable_active_checks', $this->defaultProperties)
+        ) {
+            $passive = clone($this);
+            $passive->enable_active_checks = false;
 
-        } else {
             $config->configFile(
-                'director/' . $this->getRenderingZone($config) . '/' . $filename
-            )->addObject($this);
+                'director/master/' . $filename,
+                '.cfg'
+            )->addLegacyObject($passive);
         }
+
+        $config->configFile(
+            'director/' . $this->getRenderingZone($config) . '/' . $filename,
+            '.cfg'
+        )->addLegacyObject($this);
     }
 
     public function renderToConfig(IcingaConfig $config)



More information about the icinga-checkins mailing list