# XXX make sure to always add the service specific command arguments, since we have a n .. 1 relation here
# add the command macros to the command 2x object
if(defined($service_check_command_2x->{'command_macros'})) {
- @$cfg_obj_2x{'service'}->{$service_cnt}->{command_macros} = dclone($service_check_command_2x->{'command_macros'});
+ @$cfg_obj_2x{'service'}->{$service_cnt}->{'__I2CONVERT_MACROS'} = dclone($service_check_command_2x->{'command_macros'});
}
# our PK
# - check_command
####################################################
+ ##########################################
+ # macros (address*, etc)
+ ##########################################
+ if(defined($cfg_obj_2x->{'host'}->{$host_obj_1x_key}->{'address'})) {
+ $cfg_obj_2x->{'host'}->{$host_obj_1x_key}->{'__I2CONVERT_MACROS'}->{'address'} = $cfg_obj_2x->{'host'}->{$host_obj_1x_key}->{'address'};
+ }
+ if(defined($cfg_obj_2x->{'host'}->{$host_obj_1x_key}->{'address6'})) {
+ $cfg_obj_2x->{'host'}->{$host_obj_1x_key}->{'__I2CONVERT_MACROS'}->{'address6'} = $cfg_obj_2x->{'host'}->{$host_obj_1x_key}->{'address6'};
+ }
+
##########################################
# escape strings in attributes
##########################################
# set our own __I2CONVERT_TYPE
$cfg_obj_2x->{'user'}->{$contact_obj_1x_key}->{'__I2CONVERT_TYPE'} = "user";
+ ##########################################
+ # macros (email, pager, address1..6)
+ ##########################################
+ if(defined($obj_1x_contact->{'email'})) {
+ $cfg_obj_2x->{'user'}->{$contact_obj_1x_key}->{'__I2CONVERT_MACROS'}->{'email'} = $obj_1x_contact->{'email'};
+ }
+ if(defined($obj_1x_contact->{'pager'})) {
+ $cfg_obj_2x->{'user'}->{$contact_obj_1x_key}->{'__I2CONVERT_MACROS'}->{'pager'} = $obj_1x_contact->{'pager'};
+ }
+ for(my $i=1;$i<=6;$i++) {
+ my $address = "address$i";
+ if(defined($obj_1x_contact->{$address})) {
+ $cfg_obj_2x->{'user'}->{$contact_obj_1x_key}->{'__I2CONVERT_MACROS'}->{$address} = $obj_1x_contact->{$address};
+ }
+ }
+
####################################################
# migrate renamed attributes
####################################################
#print "DEBUG: usergroups " . join (" ", @{$cfg_obj_2x->{'user'}->{$contact_obj_1x_key}->{'usergroups'}});
}
+
# we need to rebuild that notification logic entirely for 2.x
# do that later when all objects are processed and prepared (all relations?)
#say Dumper($notification_commands_2x);
# macros
####################################################
- if(defined($service_2x->{'command_macros'}) && $service_2x->{'command_macros'} != 0) {
+ if(defined($service_2x->{'__I2CONVERT_MACROS'}) && $service_2x->{'__I2CONVERT_MACROS'} != 0) {
dump_config_line($icinga2_cfg, "\tmacros = {");
- foreach my $cmd_arg (keys %{$service_2x->{'command_macros'}}) {
- dump_config_line($icinga2_cfg, "\t\t$cmd_arg = \"$service_2x->{'command_macros'}->{$cmd_arg}\",");
+ foreach my $macro_key (keys %{$service_2x->{'__I2CONVERT_MACROS'}}) {
+ dump_config_line($icinga2_cfg, "\t\t$macro_key = \"$service_2x->{'__I2CONVERT_MACROS'}->{$macro_key}\",");
}
dump_config_line($icinga2_cfg, "\t},");
}
####################################################
# macros
####################################################
- if(defined($host_2x->{'address'})) {
+ dump_config_line($icinga2_cfg, "");
+
+ if(defined($host_2x->{'__I2CONVERT_MACROS'}) && $host_2x->{'__I2CONVERT_MACROS'} != 0) {
dump_config_line($icinga2_cfg, "\tmacros = {");
- dump_config_line($icinga2_cfg, "\t\taddress = \"$host_2x->{'address'}\",");
+ foreach my $macro_key (keys %{$host_2x->{'__I2CONVERT_MACROS'}}) {
+ dump_config_line($icinga2_cfg, "\t\t$macro_key = \"$host_2x->{'__I2CONVERT_MACROS'}->{$macro_key}\",");
+ }
dump_config_line($icinga2_cfg, "\t},");
}
dump_config_line($icinga2_cfg, "");
####################################################
# macros
####################################################
- if(defined($service_2x->{'command_macros'}) && $service_2x->{'command_macros'} != 0) {
+ if(defined($service_2x->{'__I2CONVERT_MACROS'}) && $service_2x->{'__I2CONVERT_MACROS'} != 0) {
dump_config_line($icinga2_cfg, "\t\tmacros = {");
- foreach my $cmd_arg (keys %{$service_2x->{'command_macros'}}) {
- dump_config_line($icinga2_cfg, "\t\t\t$cmd_arg = \"$service_2x->{'command_macros'}->{$cmd_arg}\",");
+ foreach my $cmd_arg (keys %{$service_2x->{'__I2CONVERT_MACROS'}}) {
+ dump_config_line($icinga2_cfg, "\t\t\t$cmd_arg = \"$service_2x->{'__I2CONVERT_MACROS'}->{$cmd_arg}\",");
}
dump_config_line($icinga2_cfg, "\t\t},");
}
dump_config_line($icinga2_cfg, "\tdisplay_name = \"$user_2x->{'display_name'}\",");
}
+ ####################################################
+ # macros
+ ####################################################
+
+ if(defined($user_2x->{'__I2CONVERT_MACROS'}) && $user_2x->{'__I2CONVERT_MACROS'} != 0) {
+ dump_config_line($icinga2_cfg, "\tmacros = {");
+ foreach my $macro_key (keys %{$user_2x->{'__I2CONVERT_MACROS'}}) {
+ dump_config_line($icinga2_cfg, "\t\t$macro_key = \"$user_2x->{'__I2CONVERT_MACROS'}->{$macro_key}\",");
+ }
+ dump_config_line($icinga2_cfg, "\t},");
+ }
+
+ dump_config_line($icinga2_cfg, "");
+
####################################################
# usergroups
####################################################