configconvert: fix 'n' and 'a' notification_options (filter = 0, filter = ...)

refs #4060
This commit is contained in:
Michael Friedrich 2013-06-26 14:12:38 +02:00
parent 1faba25e9c
commit 18e3bdc581
2 changed files with 31 additions and 9 deletions

View File

@ -749,11 +749,13 @@ sub convert_notification_options_to_filter {
# verify if there's 'n' (none) or 'a' (all) and ignore the rest then
if (grep /n/, @options) {
push @{$filter->{'state'}}, 0;
push @{$filter->{'type'}}, 0;
return $filter;
}
if (grep /a/, @options) {
foreach my $by (keys %{$filter_by}) {
push @{$filter->{$by}}, $filter_names->{$by};
push @{$filter->{$filter_by->{$by}}}, $filter_names->{$by};
}
return $filter;
}

View File

@ -392,8 +392,13 @@ sub dump_service_2x {
#say Dumper($service_2x);
foreach my $by (keys %{$service_2x->{'__I2CONVERT_NOTIFICATION_FILTERS'}}) {
next if !@{$service_2x->{'__I2CONVERT_NOTIFICATION_FILTERS'}->{$by}};
my $notification_filter = "notification_".$by."_filter = (". (join ' | ', @{$service_2x->{'__I2CONVERT_NOTIFICATION_FILTERS'}->{$by}}) .")";
dump_config_line($icinga2_cfg, "\t$notification_filter,");
my $notification_filter;
if (grep /0/, @{$service_2x->{'__I2CONVERT_NOTIFICATION_FILTERS'}->{$by}}) {
$notification_filter = 0;
} else {
$notification_filter = "(". (join ' | ', @{$service_2x->{'__I2CONVERT_NOTIFICATION_FILTERS'}->{$by}}) .")";
}
dump_config_line($icinga2_cfg, "\tnotification_".$by."_filter = $notification_filter,");
}
}
@ -516,8 +521,13 @@ sub dump_host_2x {
if(defined($host_2x->{'__I2CONVERT_NOTIFICATION_FILTERS'})) {
foreach my $by (keys %{$host_2x->{'__I2CONVERT_NOTIFICATION_FILTERS'}}) {
next if !@{$host_2x->{'__I2CONVERT_NOTIFICATION_FILTERS'}->{$by}};
my $notification_filter = "notification_".$by."_filter = (". (join ' | ', @{$host_2x->{'__I2CONVERT_NOTIFICATION_FILTERS'}->{$by}}) .")";
dump_config_line($icinga2_cfg, "\t$notification_filter,");
my $notification_filter;
if (grep /0/, @{$host_2x->{'__I2CONVERT_NOTIFICATION_FILTERS'}->{$by}}) {
$notification_filter = 0;
} else {
$notification_filter = "(". (join ' | ', @{$host_2x->{'__I2CONVERT_NOTIFICATION_FILTERS'}->{$by}}) .")";
}
dump_config_line($icinga2_cfg, "\tnotification_".$by."_filter = $notification_filter,");
}
}
@ -670,8 +680,13 @@ sub dump_host_2x {
if(defined($service_2x->{'__I2CONVERT_NOTIFICATION_FILTERS'})) {
foreach my $by (keys %{$service_2x->{'__I2CONVERT_NOTIFICATION_FILTERS'}}) {
next if !@{$service_2x->{'__I2CONVERT_NOTIFICATION_FILTERS'}->{$by}};
my $notification_filter = "notification_".$by."_filter = (". (join ' | ', @{$service_2x->{'__I2CONVERT_NOTIFICATION_FILTERS'}->{$by}}) .")";
dump_config_line($icinga2_cfg, "\t$notification_filter,");
my $notification_filter;
if (grep /0/, @{$service_2x->{'__I2CONVERT_NOTIFICATION_FILTERS'}->{$by}}) {
$notification_filter = 0;
} else {
$notification_filter = "(". (join ' | ', @{$service_2x->{'__I2CONVERT_NOTIFICATION_FILTERS'}->{$by}}) .")";
}
dump_config_line($icinga2_cfg, "\tnotification_".$by."_filter = $notification_filter,");
}
}
@ -817,8 +832,13 @@ sub dump_user_2x {
if(defined($user_2x->{'__I2CONVERT_NOTIFICATION_FILTERS'})) {
foreach my $by (keys %{$user_2x->{'__I2CONVERT_NOTIFICATION_FILTERS'}}) {
next if !@{$user_2x->{'__I2CONVERT_NOTIFICATION_FILTERS'}->{$by}};
my $notification_filter = "notification_".$by."_filter = (". (join ' | ', @{$user_2x->{'__I2CONVERT_NOTIFICATION_FILTERS'}->{$by}}) .")";
dump_config_line($icinga2_cfg, "\t$notification_filter,");
my $notification_filter;
if (grep /0/, @{$user_2x->{'__I2CONVERT_NOTIFICATION_FILTERS'}->{$by}}) {
$notification_filter = 0;
} else {
$notification_filter = "(". (join ' | ', @{$user_2x->{'__I2CONVERT_NOTIFICATION_FILTERS'}->{$by}}) .")";
}
dump_config_line($icinga2_cfg, "\tnotification_".$by."_filter = $notification_filter,");
}
}