[icinga-checkins] icinga.org: icingaweb2-module-director/feature/icinga1-config-12919: IcingaCommand(Legacy): Fix type and render command_line

git at icinga.org git at icinga.org
Wed Oct 19 13:17:42 CEST 2016


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

Author: Markus Frosch <markus.frosch at icinga.com>
Date:   Fri Oct 14 10:32:51 2016 +0200

IcingaCommand(Legacy): Fix type and render command_line

refs #12919

---

 library/Director/Objects/IcingaCommand.php |   22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/library/Director/Objects/IcingaCommand.php b/library/Director/Objects/IcingaCommand.php
index a0fff94..8563add 100644
--- a/library/Director/Objects/IcingaCommand.php
+++ b/library/Director/Objects/IcingaCommand.php
@@ -3,6 +3,7 @@
 namespace Icinga\Module\Director\Objects;
 
 use Icinga\Module\Director\IcingaConfig\IcingaConfigHelper as c;
+use Icinga\Module\Director\IcingaConfig\IcingaLegacyConfigHelper as c1;
 
 class IcingaCommand extends IcingaObject
 {
@@ -175,4 +176,25 @@ class IcingaCommand extends IcingaObject
     {
         self::$pluginDir = $pluginDir;
     }
+
+    protected function getLegacyObjectType()
+    {
+        // there is only one type of command in Icinga 1.x
+        return 'command';
+    }
+
+    protected function renderLegacyCommand()
+    {
+        $command = $this->command;
+        if (preg_match('~^(\$USER\d+\$/?)(.+)$~', $command)) {
+            // should be fine, since the user decided to use a macro
+        } elseif (! $this->isAbsolutePath($command)) {
+            $command = '$USER1$/'.$command;
+        }
+
+        return c1::renderKeyValue(
+            $this->getLegacyObjectType().'_line',
+            c1::renderString($command)
+        );
+    }
 }



More information about the icinga-checkins mailing list