[icinga-checkins] icinga.org: icingaweb2-module-director/master: IcingaObject: render disabled objects as comments

git at icinga.org git at icinga.org
Fri Jun 10 00:31:35 CEST 2016


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

Author: Thomas Gelf <thomas at gelf.net>
Date:   Sat Jun 11 00:21:24 2016 +0200

IcingaObject: render disabled objects as comments

fixes #11922

---

 application/views/scripts/object/show.phtml |    2 +-
 library/Director/Objects/IcingaObject.php   |   11 +++++++++--
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/application/views/scripts/object/show.phtml b/application/views/scripts/object/show.phtml
index bc20c9f..01848a4 100644
--- a/application/views/scripts/object/show.phtml
+++ b/application/views/scripts/object/show.phtml
@@ -7,7 +7,7 @@
 </div>
 
 <div class="content">
-<?php if ($object->disabled === 'y'): ?>
+<?php if ($this->isDisabled): ?>
 <p class="error"><?= $this->translate('This object will not be deployed as it has been disabled') ?></p>
 <?php endif ?>
 <?php if ($this->isExternal): ?>
diff --git a/library/Director/Objects/IcingaObject.php b/library/Director/Objects/IcingaObject.php
index be4ff13..6954c38 100644
--- a/library/Director/Objects/IcingaObject.php
+++ b/library/Director/Objects/IcingaObject.php
@@ -1123,7 +1123,7 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
 
     public function renderToConfig(IcingaConfig $config)
     {
-        if ($this->isDisabled() || $this->isExternal()) {
+        if ($this->isExternal()) {
             return;
         }
 
@@ -1373,7 +1373,7 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
 
     public function toConfigString()
     {
-        return implode(array(
+        $str = implode(array(
             $this->renderObjectHeader(),
             $this->renderImports(),
             $this->renderProperties(),
@@ -1387,6 +1387,13 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
             $this->renderAssignments(),
             $this->renderSuffix()
         ));
+
+        if ($this->isDisabled()) {
+            return "// --- This object has been disabled ---\n// \n// "
+                . str_replace("\n", "\n// ", $str);
+        } else {
+            return $str;
+        }
     }
 
     public function isGroup()



More information about the icinga-checkins mailing list