[icinga-checkins] icinga.org: icinga2-migration/master: Properly quote several attributes

git at icinga.org git at icinga.org
Tue Jun 10 23:10:31 CEST 2014


Module: icinga2-migration
Branch: master
Commit: ace6680db02f43ce5420eda4d15c31457e9481ae
URL:    https://git.icinga.org/?p=icinga2-migration.git;a=commit;h=ace6680db02f43ce5420eda4d15c31457e9481ae

Author: Michael Friedrich <michael.friedrich at gmail.com>
Date:   Tue Jun 10 21:16:03 2014 +0200

Properly quote several attributes

---

 .../library/Conftool/Icinga2/Icinga2Host.php         |    5 -----
 .../Conftool/Icinga2/Icinga2ObjectDefinition.php     |   18 +++++++++++++++++-
 .../library/Conftool/Icinga2/Icinga2Service.php      |    5 -----
 .../library/Conftool/Icinga2/Icinga2User.php         |   10 ++++++++++
 4 files changed, 27 insertions(+), 11 deletions(-)

diff --git a/modules/conftool/library/Conftool/Icinga2/Icinga2Host.php b/modules/conftool/library/Conftool/Icinga2/Icinga2Host.php
index e04cf00..3222559 100644
--- a/modules/conftool/library/Conftool/Icinga2/Icinga2Host.php
+++ b/modules/conftool/library/Conftool/Icinga2/Icinga2Host.php
@@ -12,17 +12,12 @@ class Icinga2Host extends Icinga2ObjectDefinition
 
     protected $v1AttributeMap = array(
         //keep
-        'display_name' => 'display_name',
         'notes' => 'notes',
         'notes_url' => 'notes_url',
         'action_url' => 'action_url',
         'icon_image' => 'icon_image',
         'icon_image_alt' => 'icon_image_alt',
-        'check_interval' => 'check_interval',
-        'retry_interval' => 'retry_interval',
-        'check_period' => 'check_period',
         'max_check_attempts' => 'max_check_attempts',
-        'check_command' => 'check_command',
         //rename
         'alias' => 'display_name',
         'hostgroups' => 'groups',
diff --git a/modules/conftool/library/Conftool/Icinga2/Icinga2ObjectDefinition.php b/modules/conftool/library/Conftool/Icinga2/Icinga2ObjectDefinition.php
index c1b47b0..7de0b0d 100644
--- a/modules/conftool/library/Conftool/Icinga2/Icinga2ObjectDefinition.php
+++ b/modules/conftool/library/Conftool/Icinga2/Icinga2ObjectDefinition.php
@@ -90,7 +90,7 @@ class Icinga2ObjectDefinition
             if ($key == "check_command" && ($object instanceof IcingaService || $object instanceof IcingaHost)) {
                 $command_arr = explode("!", $value);
 
-                $this->properties['check_command'] = $command_arr[0]; //first is always the command name
+                $this->properties['check_command'] = "\"".$command_arr[0]."\""; //first is always the command name
 
                 for($i = 1; $i < count($command_arr); $i++) {
                     $varname = "ARG".$i;
@@ -98,6 +98,7 @@ class Icinga2ObjectDefinition
                     //TODO check against legacy macros and replace them
                     $this->vars($varname, $varvalue);
                 }
+		continue;
             }
 
             //convert host/service notifications
@@ -176,11 +177,26 @@ class Icinga2ObjectDefinition
         $this->check_interval = $value.'m';
     }
 
+    protected function convertCheck_period($value)
+    {
+        $this->check_period = "\"".$value."\"";
+    }
+
     protected function convertRetry_interval($value)
     {
         $this->retry_interval = $value.'m';
     }
 
+    protected function convertDisplay_name($value)
+    {
+        $this->display_name = "\"".$value."\"";
+    }
+
+    protected function convertAlias($value)
+    {
+        $this->display_name = "\"".$value."\"";
+    }
+
     protected function migrateUseImport($value, $key = null)
     {
         if ($key != "use") {
diff --git a/modules/conftool/library/Conftool/Icinga2/Icinga2Service.php b/modules/conftool/library/Conftool/Icinga2/Icinga2Service.php
index cfee52f..48a69a0 100644
--- a/modules/conftool/library/Conftool/Icinga2/Icinga2Service.php
+++ b/modules/conftool/library/Conftool/Icinga2/Icinga2Service.php
@@ -14,17 +14,12 @@ class Icinga2Service extends Icinga2ObjectDefinition
 
     protected $v1AttributeMap = array(
         //keep
-        'display_name' => 'display_name',
         'notes' => 'notes',
         'notes_url' => 'notes_url',
         'action_url' => 'action_url',
         'icon_image' => 'icon_image',
         'icon_image_alt' => 'icon_image_alt',
-        'check_interval' => 'check_interval',
-        'retry_interval' => 'retry_interval',
-        'check_period' => 'check_period',
         'max_check_attempts' => 'max_check_attempts',
-        'check_command' => 'check_command',
         //rename
         'alias' => 'display_name',
         'servicegroups' => 'groups',
diff --git a/modules/conftool/library/Conftool/Icinga2/Icinga2User.php b/modules/conftool/library/Conftool/Icinga2/Icinga2User.php
index e4dcd08..aa91551 100644
--- a/modules/conftool/library/Conftool/Icinga2/Icinga2User.php
+++ b/modules/conftool/library/Conftool/Icinga2/Icinga2User.php
@@ -34,4 +34,14 @@ class Icinga2User extends Icinga2ObjectDefinition
         'address5',
         'address6',
     );
+
+    protected function convertEmail($value)
+    {
+        $this->email = "\"".$value."\"";
+    }
+
+    protected function convertPager($value)
+    {
+        $this->pager = "\"".$value."\"";
+    }
 }



More information about the icinga-checkins mailing list