[icinga-checkins] icinga.org: icingaweb2-module-director/feature/icinga1-config-12919: IcingaObject(Legacy): Render directly added groups

git at icinga.org git at icinga.org
Fri Oct 14 11:08:51 CEST 2016


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

Author: Markus Frosch <markus.frosch at icinga.com>
Date:   Fri Oct 14 11:08:47 2016 +0200

IcingaObject(Legacy): Render directly added groups

refs #12919

---

 library/Director/Objects/IcingaObject.php       |   14 +++++++++++++-
 library/Director/Objects/IcingaObjectGroups.php |   13 +++++++++++++
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/library/Director/Objects/IcingaObject.php b/library/Director/Objects/IcingaObject.php
index ad8ac64..7bc14db 100644
--- a/library/Director/Objects/IcingaObject.php
+++ b/library/Director/Objects/IcingaObject.php
@@ -1746,6 +1746,18 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
     /**
      * @return string
      */
+    protected function renderLegacyGroups()
+    {
+        if ($this->supportsGroups()) {
+            return $this->groups()->toLegacyConfigString();
+        } else {
+            return '';
+        }
+    }
+
+    /**
+     * @return string
+     */
     protected function renderMultiRelations()
     {
         $out = '';
@@ -1887,7 +1899,7 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
             //$this->renderRanges(),
             //$this->renderArguments(),
             //$this->renderRelatedSets(),
-            //$this->renderGroups(),
+            $this->renderLegacyGroups(),
             //$this->renderMultiRelations(),
             //$this->renderCustomExtensions(),
             //$this->renderCustomVars(),
diff --git a/library/Director/Objects/IcingaObjectGroups.php b/library/Director/Objects/IcingaObjectGroups.php
index cccbeeb..76babab 100644
--- a/library/Director/Objects/IcingaObjectGroups.php
+++ b/library/Director/Objects/IcingaObjectGroups.php
@@ -8,6 +8,7 @@ use Countable;
 use Icinga\Module\Director\Db\Cache\PrefetchCache;
 use Icinga\Module\Director\IcingaConfig\IcingaConfigRenderer;
 use Icinga\Module\Director\IcingaConfig\IcingaConfigHelper as c;
+use Icinga\Module\Director\IcingaConfig\IcingaLegacyConfigHelper as c1;
 
 class IcingaObjectGroups implements Iterator, Countable, IcingaConfigRenderer
 {
@@ -341,6 +342,18 @@ class IcingaObjectGroups implements Iterator, Countable, IcingaConfigRenderer
         return c::renderKeyValue('groups', c::renderArray($groups));
     }
 
+    public function toLegacyConfigString()
+    {
+        $groups = array_keys($this->groups);
+
+        if (empty($groups)) {
+            return '';
+        }
+
+        $type = $this->object->getLegacyObjectType();
+        return c1::renderKeyValue($type.'groups', c1::renderArray($groups));
+    }
+
     public function __toString()
     {
         try {



More information about the icinga-checkins mailing list