]> granicus.if.org Git - icinga2/commitdiff
Config Conversion: introduce resource.conf with global macros
authorMichael Friedrich <michael.friedrich@netways.de>
Thu, 12 Sep 2013 16:08:07 +0000 (18:08 +0200)
committerMichael Friedrich <michael.friedrich@netways.de>
Thu, 12 Sep 2013 16:41:18 +0000 (18:41 +0200)
refs #4701

tools/configconvert/Icinga2/ExportIcinga2Cfg.pm
tools/configconvert/icinga2_convert_v1_v2.pl

index d50b9f7e3ebb73d4e7a55bb3799760a672ac5c22..af2ce13eda23815881784e8ee054fb2c95dacae7 100644 (file)
@@ -103,6 +103,21 @@ sub end_object_type_config_dump {
 # DUMP ALL OBJECTS 2.x
 ################################################################################
 
+sub dump_cfg_resource_2x {
+    my $icinga2_cfg = shift;
+    my $icinga2_global_macros = shift;
+
+    start_object_type_config_dump($icinga2_cfg, 'resource');
+
+    dump_config_line($icinga2_cfg, "set IcingaMacros = {");
+    foreach my $global_macro_2x_key (sort keys %{$icinga2_global_macros}) {
+        dump_config_line($icinga2_cfg, "\t\"$global_macro_2x_key\" = \"$icinga2_global_macros->{$global_macro_2x_key}\",");
+    }
+
+    dump_config_line($icinga2_cfg, "}");
+
+    end_object_type_config_dump($icinga2_cfg);
+}
 
 sub dump_cfg_obj_2x {
     my $icinga2_cfg = shift;
index fa007adcf444c72d8295133609f943ac8d20da57..4c778f05d531e32bb0ae92d4ef5408834d170bdd 100755 (executable)
@@ -112,6 +112,7 @@ if (defined $opt->{version}) { print $version."\n"; exit 0; }
 if ($opt->{help}) { pod2usage(1); }
 
 $icinga2_cfg->{'main'}= "$conf_prefix/icinga2.conf";
+$icinga2_cfg->{'resource'}= "$conf_prefix/resource.conf";
 $icinga2_cfg->{'hosts'}= "$conf_prefix/hosts.conf";
 $icinga2_cfg->{'services'}= "$conf_prefix/services.conf";
 $icinga2_cfg->{'users'}= "$conf_prefix/users.conf";
@@ -152,6 +153,7 @@ my $icinga1_user_macros = Icinga2::ImportIcinga1Cfg::parse_icinga1_user_macros($
 my $icinga2_cfg_obj = Icinga2::Convert::convert_2x($icinga2_cfg, $icinga1_cfg_obj, $icinga1_cfg_obj_cache, $icinga1_user_macros);
 
 # the export
+Icinga2::ExportIcinga2Cfg::dump_cfg_resource_2x($icinga2_cfg, $icinga1_user_macros);
 Icinga2::ExportIcinga2Cfg::dump_cfg_obj_2x($icinga2_cfg, $icinga2_cfg_obj);
 
 # vi: sw=4 ts=4 expandtab :