From: Gunnar Beutner Date: Fri, 13 Sep 2013 07:28:32 +0000 (+0200) Subject: Convert custom attributes to macros. X-Git-Tag: v0.0.3~522 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6a40fe7a404234b1c5b5e48def879e8d76da4069;p=icinga2 Convert custom attributes to macros. --- diff --git a/tools/configconvert/Icinga2/ExportIcinga2Cfg.pm b/tools/configconvert/Icinga2/ExportIcinga2Cfg.pm index af2ce13ed..bddabf161 100644 --- a/tools/configconvert/Icinga2/ExportIcinga2Cfg.pm +++ b/tools/configconvert/Icinga2/ExportIcinga2Cfg.pm @@ -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, "");