[icinga-checkins] icinga.org: icinga2/feature/configconvert-2743: ConfigConvert: fix undocumented contact templates conversion

git at icinga.org git at icinga.org
Mon Apr 29 16:39:36 CEST 2013


Module: icinga2
Branch: feature/configconvert-2743
Commit: 84162a4daa6fafb96d65dc704c562fb914bd9f6e
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=84162a4daa6fafb96d65dc704c562fb914bd9f6e

Author: Michael Friedrich <michael.friedrich at netways.de>
Date:   Fri Apr  5 17:52:49 2013 +0200

ConfigConvert: fix undocumented contact templates conversion

refs #2743

---

 contrib/configconvert/Icinga2/Convert.pm        |   10 +++++++++-
 contrib/configconvert/Icinga2/DumpIcinga2Cfg.pm |    2 +-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/contrib/configconvert/Icinga2/Convert.pm b/contrib/configconvert/Icinga2/Convert.pm
index 035bc76..2dc1b01 100644
--- a/contrib/configconvert/Icinga2/Convert.pm
+++ b/contrib/configconvert/Icinga2/Convert.pm
@@ -802,6 +802,14 @@ sub convert_2x {
 
     foreach my $contact_obj_1x_key (keys %{@$cfg_obj_1x{'contact'}}) {
         my $obj_1x_contact = @$cfg_obj_1x{'contact'}->{$contact_obj_1x_key};
+
+        ####################################################
+        # verify template is/use
+        ####################################################
+        $obj_1x_contact->{'__IS_TEMPLATE'} = obj_1x_is_template($obj_1x_contact);
+        $obj_1x_contact->{'__USES_TEMPLATE'} = obj_1x_uses_template($obj_1x_contact);
+        $obj_1x_contact->{'__TEMPLATE_NAME'} = $obj_1x_contact->{'name'};
+
         my $notification_commands_2x = Icinga2::Convert::convert_notificationcommand(@$cfg_obj_1x{'command'}, $obj_1x_contact, $user_macros_1x);
 
         # clone it into our users hash
@@ -819,7 +827,7 @@ sub convert_2x {
         delete($cfg_obj_2x->{'user'}->{$contact_obj_1x_key}->{'usergroups'});
         if(defined($obj_1x_contact->{'contactgroups'})) {
             push @{$cfg_obj_2x->{'user'}->{$contact_obj_1x_key}->{'usergroups'}}, sort (map { s/^\s+//; s/\s+$//; $_ } split (/,/, $obj_1x_contact->{'contactgroups'}) );
-            print "DEBUG: usergroups " . join (" ", @{$cfg_obj_2x->{'user'}->{$contact_obj_1x_key}->{'usergroups'}});
+            #print "DEBUG: usergroups " . join (" ", @{$cfg_obj_2x->{'user'}->{$contact_obj_1x_key}->{'usergroups'}});
         }
         # we need to rebuild that notification logic entirely for 2.x
         # 1.x
diff --git a/contrib/configconvert/Icinga2/DumpIcinga2Cfg.pm b/contrib/configconvert/Icinga2/DumpIcinga2Cfg.pm
index 6488f70..621db22 100644
--- a/contrib/configconvert/Icinga2/DumpIcinga2Cfg.pm
+++ b/contrib/configconvert/Icinga2/DumpIcinga2Cfg.pm
@@ -357,7 +357,7 @@ sub dump_user_2x {
     }
 
     # if this is a _template_ we need to use 'name' instead of 'host_name'
-    if (defined($user_2x->{'__USES_TEMPLATE'})) {
+    if (defined($user_2x->{'__USES_TEMPLATE'}) && $user_2x->{'__USES_TEMPLATE'} == 1) {
         dump_config_line("$object_type User \"$user_name\" inherits \"$user_2x->{'use'}\" {");
     } else {
         dump_config_line("$object_type User \"$user_name\" {");





More information about the icinga-checkins mailing list