]> granicus.if.org Git - icinga2/commitdiff
Convert custom attributes to macros.
authorGunnar Beutner <gunnar.beutner@netways.de>
Fri, 13 Sep 2013 07:28:32 +0000 (09:28 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Fri, 13 Sep 2013 07:28:32 +0000 (09:28 +0200)
tools/configconvert/Icinga2/ExportIcinga2Cfg.pm

index af2ce13eda23815881784e8ee054fb2c95dacae7..bddabf161975760823da300c24ef9dee7430a41d 100644 (file)
@@ -475,6 +475,17 @@ sub dump_service_2x {
             dump_config_line($icinga2_cfg, "\t\t$custom_key = \"$service_2x->{'__I2CONVERT_CUSTOM_ATTR'}->{$custom_key}\",");
         }
         dump_config_line($icinga2_cfg, "\t},");
+
+        dump_config_line($icinga2_cfg, "\tmacros += {");
+        foreach my $custom_key (keys %{$service_2x->{'__I2CONVERT_CUSTOM_ATTR'}}) {
+            if ($custom_key =~ /^_/) {
+                next;
+            }
+
+            my $key = substr($custom_key, 1);
+            dump_config_line($icinga2_cfg, "\t\t_SERVICE$key = \"$service_2x->{'__I2CONVERT_CUSTOM_ATTR'}->{$custom_key}\",");
+        }
+        dump_config_line($icinga2_cfg, "\t},");
     }
 
     dump_config_line($icinga2_cfg, "");
@@ -609,6 +620,17 @@ sub dump_host_2x {
             dump_config_line($icinga2_cfg, "\t\t$custom_key = \"$host_2x->{'__I2CONVERT_CUSTOM_ATTR'}->{$custom_key}\",");
         }
         dump_config_line($icinga2_cfg, "\t},");
+
+        dump_config_line($icinga2_cfg, "\tmacros += {");
+        foreach my $custom_key (keys %{$host_2x->{'__I2CONVERT_CUSTOM_ATTR'}}) {
+            if ($custom_key =~ /^_/) {
+                next;
+            }
+
+            my $key = substr($custom_key, 1);
+            dump_config_line($icinga2_cfg, "\t\t_HOST$key = \"$host_2x->{'__I2CONVERT_CUSTOM_ATTR'}->{$custom_key}\",");
+        }
+        dump_config_line($icinga2_cfg, "\t},");
     }
 
     ####################################################
@@ -822,6 +844,17 @@ sub dump_host_2x {
                 dump_config_line($icinga2_cfg, "\t\t\t$custom_key = \"$service_2x->{'__I2CONVERT_CUSTOM_ATTR'}->{$custom_key}\",");
             }
             dump_config_line($icinga2_cfg, "\t\t},");
+
+            dump_config_line($icinga2_cfg, "\t\tmacros += {");
+            foreach my $custom_key (keys %{$service_2x->{'__I2CONVERT_CUSTOM_ATTR'}}) {
+                if ($custom_key =~ /^_/) {
+                    next;
+                }
+
+                my $key = substr($custom_key, 1);
+                dump_config_line($icinga2_cfg, "\t\t\t_SERVICE$key = \"$service_2x->{'__I2CONVERT_CUSTOM_ATTR'}->{$custom_key}\",");
+            }
+            dump_config_line($icinga2_cfg, "\t\t},");
         }
 
         dump_config_line($icinga2_cfg, "\t},");
@@ -916,6 +949,17 @@ sub dump_user_2x {
             dump_config_line($icinga2_cfg, "\t\t$custom_key = \"$user_2x->{'__I2CONVERT_CUSTOM_ATTR'}->{$custom_key}\",");
         }
         dump_config_line($icinga2_cfg, "\t},");
+
+        dump_config_line($icinga2_cfg, "\tmacros += {");
+        foreach my $custom_key (keys %{$user_2x->{'__I2CONVERT_CUSTOM_ATTR'}}) {
+            if ($custom_key =~ /^_/) {
+                next;
+            }
+
+            my $key = substr($custom_key, 1);
+            dump_config_line($icinga2_cfg, "\t\t_CONTACT$key = \"$user_2x->{'__I2CONVERT_CUSTOM_ATTR'}->{$custom_key}\",");
+        }
+        dump_config_line($icinga2_cfg, "\t},");
     }
 
     dump_config_line($icinga2_cfg, "");