[icinga-checkins] icinga.org: icingaweb2-module-director/master: IcingaObject(Legacy): Render display_name as alias

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


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

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

IcingaObject(Legacy): Render display_name as alias

With the execption of Host and Service.

refs #12919

---

 library/Director/Objects/IcingaHost.php    |    6 ++++++
 library/Director/Objects/IcingaObject.php  |   14 ++++++++++++++
 library/Director/Objects/IcingaService.php |    8 +++++++-
 3 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/library/Director/Objects/IcingaHost.php b/library/Director/Objects/IcingaHost.php
index 1b21704..3f1083b 100644
--- a/library/Director/Objects/IcingaHost.php
+++ b/library/Director/Objects/IcingaHost.php
@@ -7,6 +7,7 @@ use Icinga\Exception\NotFoundError;
 use Icinga\Module\Director\Data\PropertiesFilter;
 use Icinga\Module\Director\Db;
 use Icinga\Module\Director\IcingaConfig\IcingaConfig;
+use Icinga\Module\Director\IcingaConfig\IcingaLegacyConfigHelper as c1;
 use Icinga\Module\Director\Web\Form\DirectorObjectForm;
 
 class IcingaHost extends IcingaObject
@@ -336,6 +337,11 @@ class IcingaHost extends IcingaObject
         return '';
     }
 
+    protected function renderLegacyDisplay_Name()
+    {
+        return c1::renderKeyValue('display_name', $this->display_name);
+    }
+
     public static function loadWithApiKey($key, Db $db)
     {
         $query = $db->getDbAdapter()
diff --git a/library/Director/Objects/IcingaObject.php b/library/Director/Objects/IcingaObject.php
index fc66e58..10d1aa7 100644
--- a/library/Director/Objects/IcingaObject.php
+++ b/library/Director/Objects/IcingaObject.php
@@ -1611,6 +1611,20 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
         );
     }
 
+    /**
+     * Display Name only exists for host/service in Icinga 1
+     *
+     * Render it as alias for everything by default.
+     *
+     * Alias does not exist in Icinga 2 currently!
+     *
+     * @return string
+     */
+    protected function renderLegacyDisplay_Name()
+    {
+        return c1::renderKeyValue('alias', $this->display_name);
+    }
+
     protected function renderLegacyTimeout()
     {
         return '';
diff --git a/library/Director/Objects/IcingaService.php b/library/Director/Objects/IcingaService.php
index 34b88bc..228c4ee 100644
--- a/library/Director/Objects/IcingaService.php
+++ b/library/Director/Objects/IcingaService.php
@@ -6,6 +6,7 @@ use Icinga\Data\Filter\Filter;
 use Icinga\Exception\ProgrammingError;
 use Icinga\Module\Director\IcingaConfig\IcingaConfig;
 use Icinga\Module\Director\IcingaConfig\IcingaConfigHelper as c;
+use Icinga\Module\Director\IcingaConfig\IcingaLegacyConfigHelper as c1;
 
 class IcingaService extends IcingaObject
 {
@@ -282,10 +283,15 @@ class IcingaService extends IcingaObject
 
     public function renderUse_var_overrides()
     {
-        // @codingStandardsIgnoreEnd
         return '';
     }
 
+    protected function renderLegacyDisplay_Name()
+    {
+        // @codingStandardsIgnoreEnd
+        return c1::renderKeyValue('display_name', $this->display_name);
+    }
+
     public function hasCheckCommand()
     {
         return $this->getResolvedProperty('check_command_id') !== null;



More information about the icinga-checkins mailing list