[icinga-checkins] icinga.org: icinga2/feature/configconvert-2743: configconvert: only dump macros if there are key-val pairs

git at icinga.org git at icinga.org
Tue Apr 30 18:48:46 CEST 2013


Module: icinga2
Branch: feature/configconvert-2743
Commit: 112a187ff7958e3a7db75d24b5606b8c27ee007f
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=112a187ff7958e3a7db75d24b5606b8c27ee007f

Author: Michael Friedrich <michael.friedrich at netways.de>
Date:   Tue Apr 30 18:48:17 2013 +0200

configconvert: only dump macros if there are key-val pairs

---

 contrib/configconvert/Icinga2/ExportIcinga2Cfg.pm |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/contrib/configconvert/Icinga2/ExportIcinga2Cfg.pm b/contrib/configconvert/Icinga2/ExportIcinga2Cfg.pm
index 17e701e..eaee62d 100644
--- a/contrib/configconvert/Icinga2/ExportIcinga2Cfg.pm
+++ b/contrib/configconvert/Icinga2/ExportIcinga2Cfg.pm
@@ -93,15 +93,15 @@ sub dump_service_2x {
     ####################################################
     # macros
     ####################################################
-    dump_config_line($icinga2_cfg, "\tmacros = {");
 
     if(defined($service_2x->{'command_macros'}) && $service_2x->{'command_macros'} != 0) {
+        dump_config_line($icinga2_cfg, "\tmacros = {");
         foreach my $cmd_arg (keys %{$service_2x->{'command_macros'}}) {
             dump_config_line($icinga2_cfg, "\t\t$cmd_arg = \"$service_2x->{'command_macros'}->{$cmd_arg}\",");
         }
+        dump_config_line($icinga2_cfg, "\t},");
     }
 
-    dump_config_line($icinga2_cfg, "\t},");
     dump_config_line($icinga2_cfg, "");
 
     ####################################################
@@ -191,12 +191,11 @@ sub dump_host_2x {
     ####################################################
     # macros 
     ####################################################
-    dump_config_line($icinga2_cfg, "\tmacros = {");
     if(defined($host_2x->{'address'})) {
+        dump_config_line($icinga2_cfg, "\tmacros = {");
         dump_config_line($icinga2_cfg, "\t\taddress = \"$host_2x->{'address'}\",");
+        dump_config_line($icinga2_cfg, "\t},");
     }
-
-    dump_config_line($icinga2_cfg, "\t},");
     dump_config_line($icinga2_cfg, "");
 
     ####################################################
@@ -289,13 +288,13 @@ sub dump_host_2x {
         ####################################################
         # macros 
         ####################################################
-        dump_config_line($icinga2_cfg, "\t\tmacros = {");
         if(defined($service_2x->{'command_macros'}) && $service_2x->{'command_macros'} != 0) {
+            dump_config_line($icinga2_cfg, "\t\tmacros = {");
             foreach my $cmd_arg (keys %{$service_2x->{'command_macros'}}) {
                 dump_config_line($icinga2_cfg, "\t\t\t$cmd_arg = \"$service_2x->{'command_macros'}->{$cmd_arg}\",");
             }
+            dump_config_line($icinga2_cfg, "\t\t},");
         }
-        dump_config_line($icinga2_cfg, "\t\t},");
 
         ####################################################
         # check_command 





More information about the icinga-checkins mailing list