]> granicus.if.org Git - icinga2/commitdiff
configconvert: fix 'n' and 'a' notification_options (filter = 0, filter = ...)
authorMichael Friedrich <michael.friedrich@netways.de>
Wed, 26 Jun 2013 12:12:38 +0000 (14:12 +0200)
committerMichael Friedrich <michael.friedrich@netways.de>
Wed, 26 Jun 2013 12:12:38 +0000 (14:12 +0200)
refs #4060

tools/configconvert/Icinga2/Convert.pm
tools/configconvert/Icinga2/ExportIcinga2Cfg.pm

index 040fe1e35583e2bc4dc65bb9fce6288c5ae2f616..0b81d602c931400f4a5fa9d64303eb56a29a1b85 100644 (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;
     }
index 6ebe9ad4815c52c8351856669dabbcd2176c35c2..c5d7fb0b2a2b3e1f1af03bd32fac7f7f2bc36e36 100644 (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,");
         }
     }