From: Michael Friedrich Date: Wed, 9 Oct 2013 16:54:09 +0000 (+0200) Subject: Conversion: Fix notification attributes. X-Git-Tag: v0.0.3~215 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4c6f4261ee371f62c9e2bd38aa54c505fedb174e;p=icinga2 Conversion: Fix notification attributes. --- diff --git a/tools/configconvert/Icinga2/Convert.pm b/tools/configconvert/Icinga2/Convert.pm index fa82f191c..a75d6a247 100644 --- a/tools/configconvert/Icinga2/Convert.pm +++ b/tools/configconvert/Icinga2/Convert.pm @@ -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); diff --git a/tools/configconvert/Icinga2/ExportIcinga2Cfg.pm b/tools/configconvert/Icinga2/ExportIcinga2Cfg.pm index b06a8c7ea..2c241f54f 100644 --- a/tools/configconvert/Icinga2/ExportIcinga2Cfg.pm +++ b/tools/configconvert/Icinga2/ExportIcinga2Cfg.pm @@ -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