[icinga-checkins] icinga.org: icinga2/feature/configconvert-2743: configconvert: support ' name' for groups' if *group_name is not set

git at icinga.org git at icinga.org
Thu May 2 22:17:32 CEST 2013


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

Author: Michael Friedrich <michael.friedrich at netways.de>
Date:   Tue Apr 30 14:22:53 2013 +0200

configconvert: support 'name' for groups' if *group_name is not set

this is a fallback for broken configs only, and since i got some, added
a small fix.

refs #2743

---

 contrib/configconvert/Icinga2/Convert.pm |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/contrib/configconvert/Icinga2/Convert.pm b/contrib/configconvert/Icinga2/Convert.pm
index 2d671e4..198440c 100644
--- a/contrib/configconvert/Icinga2/Convert.pm
+++ b/contrib/configconvert/Icinga2/Convert.pm
@@ -961,6 +961,13 @@ sub convert_2x {
             $cfg_obj_2x->{'hostgroup'}->{$hostgroup_obj_1x_key}->{'display_name'} = $obj_1x_hostgroup->{'alias'};
         }
 
+        # check if host_groupname exists, if not, try to copy it from 'name' (no template inheritance possible in groups!)
+        if(!defined($obj_1x_hostgroup->{'hostgroup_name'})) {
+            if(defined($obj_1x_hostgroup->{'name'})) {
+                $cfg_obj_2x->{'hostgroup'}->{$hostgroup_obj_1x_key}->{'hostgroup_name'} = $obj_1x_hostgroup->{'name'};
+            }
+        }
+
         # check if there are members defined, we must re-link them in their host object again
         if(defined($obj_1x_hostgroup->{'members'})) {
             my @hg_members = sort (map { s/^\s+//; s/\s+$//; $_ } split (/,/, $obj_1x_hostgroup->{'members'}) );
@@ -981,6 +988,13 @@ sub convert_2x {
             $cfg_obj_2x->{'servicegroup'}->{$servicegroup_obj_1x_key}->{'display_name'} = $obj_1x_servicegroup->{'alias'};
         }
 
+        # check if service_groupname exists, if not, try to copy it from 'name' (no template inheritance possible in groups!)
+        if(!defined($obj_1x_servicegroup->{'servicegroup_name'})) {
+            if(defined($obj_1x_servicegroup->{'name'})) {
+                $cfg_obj_2x->{'servicegroup'}->{$servicegroup_obj_1x_key}->{'servicegroup_name'} = $obj_1x_servicegroup->{'name'};
+            }
+        }
+
         # check if there are members defined, we must re-link them in their service object again
         if(defined($obj_1x_servicegroup->{'members'})) {
 
@@ -1019,6 +1033,13 @@ sub convert_2x {
             $cfg_obj_2x->{'usergroup'}->{$contactgroup_obj_1x_key}->{'display_name'} = $obj_1x_contactgroup->{'alias'};
         }
 
+        # check if contact_groupname exists, if not, try to copy it from 'name' (no template inheritance possible in groups!)
+        if(!defined($obj_1x_contactgroup->{'contactgroup_name'})) {
+            if(defined($obj_1x_contactgroup->{'name'})) {
+                $cfg_obj_2x->{'usergroup'}->{$contactgroup_obj_1x_key}->{'usergroup_name'} = $obj_1x_contactgroup->{'name'};
+            }
+        }
+
         # check if there are members defined, we must re-link them in their host object again
         # XXX fix it for users
         if(defined($obj_1x_contactgroup->{'members'})) {





More information about the icinga-checkins mailing list