From 31a321e13e642e2e49590af61d41f40761b20855 Mon Sep 17 00:00:00 2001 From: Markus Frosch Date: Thu, 13 Oct 2016 15:44:53 +0200 Subject: [PATCH] IcingaObject(legacy): Add flag to render only supported objects refs #12919 --- library/Director/Objects/IcingaCommand.php | 2 ++ library/Director/Objects/IcingaHost.php | 2 ++ library/Director/Objects/IcingaObject.php | 20 +++++++++++++++++++ .../Director/Objects/IcingaObjectGroup.php | 2 ++ library/Director/Objects/IcingaService.php | 2 ++ library/Director/Objects/IcingaServiceSet.php | 2 ++ library/Director/Objects/IcingaTimePeriod.php | 2 ++ 7 files changed, 32 insertions(+) diff --git a/library/Director/Objects/IcingaCommand.php b/library/Director/Objects/IcingaCommand.php index 523cfffa..a0fff940 100644 --- a/library/Director/Objects/IcingaCommand.php +++ b/library/Director/Objects/IcingaCommand.php @@ -29,6 +29,8 @@ class IcingaCommand extends IcingaObject protected $supportsArguments = true; + protected $supportedInLegacy = true; + protected $intervalProperties = array( 'timeout' => 'timeout', ); diff --git a/library/Director/Objects/IcingaHost.php b/library/Director/Objects/IcingaHost.php index 25abadd5..1b217045 100644 --- a/library/Director/Objects/IcingaHost.php +++ b/library/Director/Objects/IcingaHost.php @@ -82,6 +82,8 @@ class IcingaHost extends IcingaObject protected $supportsFields = true; + protected $supportedInLegacy = true; + public static function enumProperties( DbConnection $connection = null, $prefix = '', diff --git a/library/Director/Objects/IcingaObject.php b/library/Director/Objects/IcingaObject.php index dde7c309..af9e412d 100644 --- a/library/Director/Objects/IcingaObject.php +++ b/library/Director/Objects/IcingaObject.php @@ -51,6 +51,9 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer /** @var bool Whether Sets of object can be defined */ protected $supportsSets = false; + /** @var bool If the object is rendered in legacy config */ + protected $supportedInLegacy = false; + protected $rangeClass; protected $type; @@ -1450,6 +1453,10 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer return $config; } + public function isSupportedInLegacy() + { + return $this->supportedInLegacy; + } public function renderToLegacyConfig(IcingaConfig $config) { @@ -1457,6 +1464,19 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer return; } + if (! $this->isSupportedInLegacy()) { + $config->configFile( + 'director/ignored-objects', '.cfg' + )->prepend( + sprintf( + "# Not supported for legacy config: %s object_name=%s\n", + get_class($this), + $this->getObjectName() + ) + ); + return; + } + $filename = $this->getRenderingFilename(); if ( diff --git a/library/Director/Objects/IcingaObjectGroup.php b/library/Director/Objects/IcingaObjectGroup.php index b92a31ef..5612f5ee 100644 --- a/library/Director/Objects/IcingaObjectGroup.php +++ b/library/Director/Objects/IcingaObjectGroup.php @@ -11,6 +11,8 @@ abstract class IcingaObjectGroup extends IcingaObject { protected $supportsImports = true; + protected $supportedInLegacy = true; + protected $defaultProperties = array( 'id' => null, 'object_name' => null, diff --git a/library/Director/Objects/IcingaService.php b/library/Director/Objects/IcingaService.php index c2a0f00f..34b88bc5 100644 --- a/library/Director/Objects/IcingaService.php +++ b/library/Director/Objects/IcingaService.php @@ -85,6 +85,8 @@ class IcingaService extends IcingaObject protected $supportsSets = true; + protected $supportedInLegacy = true; + protected $keyName = array('host_id', 'service_set_id', 'object_name'); protected $prioritizedProperties = array('host_id'); diff --git a/library/Director/Objects/IcingaServiceSet.php b/library/Director/Objects/IcingaServiceSet.php index 7de95e13..4e996794 100644 --- a/library/Director/Objects/IcingaServiceSet.php +++ b/library/Director/Objects/IcingaServiceSet.php @@ -28,6 +28,8 @@ class IcingaServiceSet extends IcingaObject protected $supportsApplyRules = true; + protected $supportedInLegacy = true; + protected $relations = array( 'host' => 'IcingaHost', ); diff --git a/library/Director/Objects/IcingaTimePeriod.php b/library/Director/Objects/IcingaTimePeriod.php index c912eb02..4b97b884 100644 --- a/library/Director/Objects/IcingaTimePeriod.php +++ b/library/Director/Objects/IcingaTimePeriod.php @@ -22,6 +22,8 @@ class IcingaTimePeriod extends IcingaObject protected $supportsRanges = true; + protected $supportedInLegacy = true; + protected $relations = array( 'zone' => 'IcingaZone', );