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

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


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

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 2f69c90..76b2ccb 100644
--- a/library/Director/Objects/IcingaHost.php
+++ b/library/Director/Objects/IcingaHost.php
@@ -6,6 +6,7 @@ use Icinga\Data\Db\DbConnection;
 use Icinga\Exception\NotFoundError;
 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
@@ -331,6 +332,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 9388767..c3b7e60 100644
--- a/library/Director/Objects/IcingaObject.php
+++ b/library/Director/Objects/IcingaObject.php
@@ -1538,6 +1538,20 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
         return $this->renderLegacyRelationProperty('host', $this->host_id, 'host_name');
     }
 
+    /**
+     * 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 b127fa6..5c8eee0 100644
--- a/library/Director/Objects/IcingaService.php
+++ b/library/Director/Objects/IcingaService.php
@@ -5,6 +5,7 @@ namespace Icinga\Module\Director\Objects;
 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
 {
@@ -220,10 +221,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