]> granicus.if.org Git - icinga2/commitdiff
Conversion: Fix notification attributes.
authorMichael Friedrich <michael.friedrich@netways.de>
Wed, 9 Oct 2013 16:54:09 +0000 (18:54 +0200)
committerMichael Friedrich <michael.friedrich@netways.de>
Wed, 9 Oct 2013 16:54:09 +0000 (18:54 +0200)
tools/configconvert/Icinga2/Convert.pm
tools/configconvert/Icinga2/ExportIcinga2Cfg.pm

index fa82f191c14df01cebda3090b4bf2c90e9a7185b..a75d6a247665f52368ea4e169fa40c806f2e6903 100644 (file)
@@ -2348,9 +2348,15 @@ sub convert_2x {
             foreach my $notification_key (keys %{$notification}) {
                 next if $notification->{$notification_key}->{'type'} ne 'service';
 
+                my $notifications_enabled = obj_1x_get_service_attr($cfg_obj_2x, $obj_2x_service, $obj_2x_service->{'__I2CONVERT_SERVICE_HOSTNAME'}, 'notifications_enabled');
+                my $notification_interval = obj_1x_get_service_attr($cfg_obj_2x, $obj_2x_service, $obj_2x_service->{'__I2CONVERT_SERVICE_HOSTNAME'}, 'notification_internval');
+                my $notification_period = obj_1x_get_service_attr($cfg_obj_2x, $obj_2x_service, $obj_2x_service->{'__I2CONVERT_SERVICE_HOSTNAME'}, 'notification_period');
+
                 $notification->{$notification_key}->{'__I2CONVERT_NOTIFICATION_FILTERS'} = $cfg_obj_2x->{'service'}->{$service_obj_2x_key}->{'__I2CONVERT_NOTIFICATION_FILTERS'};
-                $notification->{$notification_key}->{'__I2CONVERT_NOTIFICATION_INTERVAL'} = $cfg_obj_2x->{'service'}->{$service_obj_2x_key}->{'notification_interval'};
-                $notification->{$notification_key}->{'__I2CONVERT_NOTIFICATION_PERIOD'} = $cfg_obj_2x->{'service'}->{$service_obj_2x_key}->{'notification_period'};
+                $notification->{$notification_key}->{'__I2CONVERT_NOTIFICATION_INTERVAL'} = $notification_interval;
+                $notification->{$notification_key}->{'__I2CONVERT_NOTIFICATION_PERIOD'} = $notification_period;
+                $notification->{$notification_key}->{'__I2CONVERT_NOTIFICATION_ENABLED'} = $notifications_enabled;
+                #say Dumper($notification->{$notification_key});
             }
         }
         #say Dumper($obj_2x_service);
index b06a8c7eabf15b8811072f9f42b858d36108ff3a..2c241f54fa4d726be37bcc52fd6cd48612913659 100644 (file)
@@ -433,10 +433,6 @@ sub dump_service_2x {
         }
     }
 
-    if(defined($service_2x->{'notifications_enabled'})) {
-        dump_config_line($icinga2_cfg, "\tenable_notifications = $service_2x->{'notifications_enabled'},");
-    }
-
     ####################################################
     # other service attributes, if set
     ####################################################
@@ -729,10 +725,6 @@ sub dump_host_2x {
             }
         }
 
-        if(defined($service_2x->{'notifications_enabled'})) {
-            dump_config_line($icinga2_cfg, "\tenable_notifications = $service_2x->{'notifications_enabled'},");
-        }
-
         ####################################################
         # other service attributes, if set
         ####################################################
@@ -845,6 +837,9 @@ sub dump_user_2x {
         }
     }
 
+    if(defined($user_2x->{'notifications_enabled'})) {
+        dump_config_line($icinga2_cfg, "\tenable_notifications = \"$user_2x->{'notifications_enabled'}\",");
+    }
     ####################################################
     # usergroups
     ####################################################
@@ -953,7 +948,7 @@ sub dump_notification_2x {
     }
 
     if(defined($notification_2x->{'__I2CONVERT_NOTIFICATION_PERIOD'})) {
-        dump_config_line($icinga2_cfg, "\tnotification_period = $notification_2x->{'__I2CONVERT_NOTIFICATION_PERIOD'},");
+        dump_config_line($icinga2_cfg, "\tnotification_period = \"$notification_2x->{'__I2CONVERT_NOTIFICATION_PERIOD'}\",");
     }
 
     # this is set for escalations