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
This commit is contained in:
Thomas Gelf 2016-07-28 15:44:42 +00:00
parent 0d36d56cbb
commit ce1c6f3099
5 changed files with 18 additions and 11 deletions

View File

@ -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()

View File

@ -57,6 +57,11 @@ class IcingaNotification extends IcingaObject
'times_end' => 'times_end',
);
protected function prefersGlobalZone()
{
return false;
}
/**
* We have distinct properties in the db
*

View File

@ -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...

View File

@ -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;
}
}

View File

@ -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();
}
}