[icinga-checkins] icinga.org: icingaweb2-module-director/feature/icinga1-config-12919: IcingaObject(legacy): Add flag to render only supported objects

git at icinga.org git at icinga.org
Fri Oct 14 15:36:22 CEST 2016


Module: icingaweb2-module-director
Branch: feature/icinga1-config-12919
Commit: eab08e9845987b9d613c0022908143004ee414ea
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=eab08e9845987b9d613c0022908143004ee414ea

Author: Markus Frosch <markus.frosch at icinga.com>
Date:   Thu Oct 13 15:44:53 2016 +0200

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 ++++++++++++++++++++
 library/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 523cfff..a0fff94 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 65837de..2f69c90 100644
--- a/library/Director/Objects/IcingaHost.php
+++ b/library/Director/Objects/IcingaHost.php
@@ -81,6 +81,8 @@ class IcingaHost extends IcingaObject
 
     protected $supportsFields = true;
 
+    protected $supportedInLegacy = true;
+
     public static function enumProperties(DbConnection $connection = null, $prefix = '')
     {
         $hostProperties = array($prefix . 'name' => 'name');
diff --git a/library/Director/Objects/IcingaObject.php b/library/Director/Objects/IcingaObject.php
index 71397b2..d10d278 100644
--- a/library/Director/Objects/IcingaObject.php
+++ b/library/Director/Objects/IcingaObject.php
@@ -48,6 +48,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;
@@ -1382,6 +1385,10 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
         return $config;
     }
 
+    public function isSupportedInLegacy()
+    {
+        return $this->supportedInLegacy;
+    }
 
     public function renderToLegacyConfig(IcingaConfig $config)
     {
@@ -1389,6 +1396,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 ff84087..3b4c334 100644
--- a/library/Director/Objects/IcingaObjectGroup.php
+++ b/library/Director/Objects/IcingaObjectGroup.php
@@ -8,6 +8,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 31eecb4..b127fa6 100644
--- a/library/Director/Objects/IcingaService.php
+++ b/library/Director/Objects/IcingaService.php
@@ -80,6 +80,8 @@ class IcingaService extends IcingaObject
 
     protected $supportsSets = true;
 
+    protected $supportedInLegacy = true;
+
     protected $keyName = array('host_id', 'object_name');
 
     protected $prioritizedProperties = array('host_id');
diff --git a/library/Director/Objects/IcingaServiceSet.php b/library/Director/Objects/IcingaServiceSet.php
index 4e40741..a9b39c5 100644
--- a/library/Director/Objects/IcingaServiceSet.php
+++ b/library/Director/Objects/IcingaServiceSet.php
@@ -27,6 +27,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 c912eb0..4b97b88 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',
     );



More information about the icinga-checkins mailing list