[icinga-checkins] icinga.org: icinga2/feature/configconvert-2743: configconvert: add wildcard detection for 'members *' in hostgroup

git at icinga.org git at icinga.org
Tue May 28 19:52:13 CEST 2013


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

Author: Michael Friedrich <michael.friedrich at netways.de>
Date:   Tue May 28 19:49:16 2013 +0200

configconvert: add wildcard detection for 'members *' in hostgroup

currently adds itself to the host's hostgroups array, but maybe a global
template where all hosts inherit from, plus additive inheritance fit
better here.

refs #4010

---

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

diff --git a/contrib/configconvert/Icinga2/Convert.pm b/contrib/configconvert/Icinga2/Convert.pm
index b0c73e4..1cb4132 100644
--- a/contrib/configconvert/Icinga2/Convert.pm
+++ b/contrib/configconvert/Icinga2/Convert.pm
@@ -1096,7 +1096,17 @@ sub convert_2x {
         # 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 = Icinga2::Utils::str2arr_by_delim_without_excludes($obj_1x_hostgroup->{'members'}, ',', 1);
+
+            my @hg_members = ();
+            # check if members is a wildcard, or a possible comma seperated list
+            # using object tricks - http://docs.icinga.org/latest/en/objecttricks.html#objecttricks-service
+            # XXX better create a master template where all hosts inherit from, and use additive hostgroups attribute
+            if ($obj_1x_hostgroup->{'members'} =~ /^\*$/) {
+                @hg_members = obj_1x_get_all_hostnames_arr($cfg_obj_2x);
+            } else {
+                @hg_members = Icinga2::Utils::str2arr_by_delim_without_excludes($obj_1x_hostgroup->{'members'}, ',', 1);
+            }
+
             foreach my $hg_member (@hg_members) {
                 my $obj_2x_hg_member = obj_get_host_obj_by_host_name($cfg_obj_2x, $hg_member);           
                 #print "DEBUG: $hg_member found.\n";





More information about the icinga-checkins mailing list