[icinga-checkins] icinga.org: icingaweb2-module-director/master: Objects: simplify default rendering zone handling

git at icinga.org git at icinga.org
Thu Jul 28 17:46:44 CEST 2016


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

Author: Thomas Gelf <thomas at gelf.net>
Date:   Thu Jul 28 15:44:42 2016 +0000

Objects: simplify default rendering zone handling

For existing installations this should only affect Timeperiods, as
they will now prefer the global zone. Also some custom zone settings
might now take effect while they have formerly been ignored.

fixes #12252

---

 library/Director/Objects/IcingaCommand.php      |    5 ++---
 library/Director/Objects/IcingaNotification.php |    5 +++++
 library/Director/Objects/IcingaObject.php       |    7 ++++++-
 library/Director/Objects/IcingaTimePeriod.php   |    5 +++++
 library/Director/Objects/IcingaUser.php         |    7 -------
 5 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/library/Director/Objects/IcingaCommand.php b/library/Director/Objects/IcingaCommand.php
index 0ae9e9b..0d799e5 100644
--- a/library/Director/Objects/IcingaCommand.php
+++ b/library/Director/Objects/IcingaCommand.php
@@ -2,7 +2,6 @@
 
 namespace Icinga\Module\Director\Objects;
 
-use Icinga\Module\Director\IcingaConfig\IcingaConfig;
 use Icinga\Module\Director\IcingaConfig\IcingaConfigHelper as c;
 
 class IcingaCommand extends IcingaObject
@@ -98,9 +97,9 @@ class IcingaCommand extends IcingaObject
         return $value;
     }
 
-    public function getRenderingZone(IcingaConfig $config = null)
+    protected function prefersGlobalZone()
     {
-        return $this->connection->getDefaultGlobalZoneName();
+        return true;
     }
 
     protected function renderCommand()
diff --git a/library/Director/Objects/IcingaNotification.php b/library/Director/Objects/IcingaNotification.php
index f2bf897..37e74f1 100644
--- a/library/Director/Objects/IcingaNotification.php
+++ b/library/Director/Objects/IcingaNotification.php
@@ -57,6 +57,11 @@ class IcingaNotification extends IcingaObject
         'times_end'             => 'times_end',
     );
 
+    protected function prefersGlobalZone()
+    {
+        return false;
+    }
+
     /**
      * We have distinct properties in the db
      *
diff --git a/library/Director/Objects/IcingaObject.php b/library/Director/Objects/IcingaObject.php
index 76ed572..b47b43a 100644
--- a/library/Director/Objects/IcingaObject.php
+++ b/library/Director/Objects/IcingaObject.php
@@ -1177,13 +1177,18 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
             return $config->getZoneName($zoneId);
         }
 
-        if ($this->isTemplate() || $this->isApplyRule()) {
+        if ($this->prefersGlobalZone()) {
             return $this->connection->getDefaultGlobalZoneName();
         }
 
         return $this->connection->getMasterZoneName();
     }
 
+    protected function prefersGlobalZone()
+    {
+        return $this->isTemplate() || $this->isApplyRule();
+    }
+
     protected function renderImports()
     {
         // TODO: parent_host ORDERed by weigth...
diff --git a/library/Director/Objects/IcingaTimePeriod.php b/library/Director/Objects/IcingaTimePeriod.php
index 3c4103a..6f766f5 100644
--- a/library/Director/Objects/IcingaTimePeriod.php
+++ b/library/Director/Objects/IcingaTimePeriod.php
@@ -56,4 +56,9 @@ class IcingaTimePeriod extends IcingaObject
         //       different. Figure out whether and how we should support this
         return false;
     }
+
+    protected function prefersGlobalZone()
+    {
+        return true;
+    }
 }
diff --git a/library/Director/Objects/IcingaUser.php b/library/Director/Objects/IcingaUser.php
index a344093..c50a231 100644
--- a/library/Director/Objects/IcingaUser.php
+++ b/library/Director/Objects/IcingaUser.php
@@ -2,8 +2,6 @@
 
 namespace Icinga\Module\Director\Objects;
 
-use Icinga\Module\Director\IcingaConfig\IcingaConfig;
-
 class IcingaUser extends IcingaObject
 {
     protected $table = 'icinga_user';
@@ -42,9 +40,4 @@ class IcingaUser extends IcingaObject
         'period' => 'IcingaTimePeriod',
         'zone'   => 'IcingaZone',
     );
-
-    public function getRenderingZone(IcingaConfig $config = null)
-    {
-        return $this->connection->getMasterZoneName();
-    }
 }



More information about the icinga-checkins mailing list