From e7fc4d3009d5c6f856c41bc2e78c1f8923b2aa5a Mon Sep 17 00:00:00 2001 From: Thomas Gelf <thomas@gelf.net> Date: Fri, 15 Jun 2018 12:10:44 +0200 Subject: [PATCH] IcingaScheduledDowntime: render object header --- .../Objects/IcingaScheduledDowntime.php | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/library/Director/Objects/IcingaScheduledDowntime.php b/library/Director/Objects/IcingaScheduledDowntime.php index cba17d3a..40a3f974 100644 --- a/library/Director/Objects/IcingaScheduledDowntime.php +++ b/library/Director/Objects/IcingaScheduledDowntime.php @@ -2,6 +2,9 @@ namespace Icinga\Module\Director\Objects; +use Icinga\Exception\ConfigurationError; +use Icinga\Module\Director\IcingaConfig\IcingaConfigHelper as c; + class IcingaScheduledDowntime extends IcingaObject { protected $table = 'icinga_scheduled_downtime'; @@ -53,10 +56,30 @@ class IcingaScheduledDowntime extends IcingaObject return ''; } + /** + * @return string + * @throws ConfigurationError + */ protected function renderObjectHeader() { - return parent::renderObjectHeader() - . ' import "legacy-timeperiod"' . "\n"; + if ($this->isApplyRule()) { + if (($to = $this->get('apply_to')) === null) { + throw new ConfigurationError( + 'Applied notification "%s" has no valid object type', + $this->getObjectName() + ); + } + + return sprintf( + "%s %s %s to %s {\n", + $this->getObjectTypeName(), + $this->getType(), + c::renderString($this->getObjectName()), + ucfirst($to) + ); + } else { + return parent::renderObjectHeader(); + } } public function isActive($now = null)