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

git at icinga.org git at icinga.org
Thu Nov 3 14:23:23 CET 2016


Module: icingaweb2-module-director
Branch: master
Commit: 1e70cface0996d86df5edac7fd7bf22bdd7e3f0b
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=1e70cface0996d86df5edac7fd7bf22bdd7e3f0b

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 f9c37b9..b420356 100644
--- a/library/Director/Objects/IcingaObject.php
+++ b/library/Director/Objects/IcingaObject.php
@@ -1866,6 +1866,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 = '';
@@ -2009,7 +2021,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 8ec06c2..e78c31a 100644
--- a/library/Director/Objects/IcingaObjectGroups.php
+++ b/library/Director/Objects/IcingaObjectGroups.php
@@ -9,6 +9,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
 {
@@ -344,6 +345,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