From ce1c6f309919297c80b241dbec2f44c912ff85d1 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Thu, 28 Jul 2016 15:44:42 +0000 Subject: [PATCH] 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 0ae9e9b7..0d799e52 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 f2bf8975..37e74f1a 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 76ed572b..b47b43a6 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 3c4103ad..6f766f5c 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 a344093e..c50a2312 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(); - } }