[icinga-checkins] icinga.org: icinga2/feature/configconvert-2743: configconvert: make host-> service linked service a template object, referenced by the host

git at icinga.org git at icinga.org
Fri May 3 12:55:41 CEST 2013


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

Author: Michael Friedrich <michael.friedrich at netways.de>
Date:   Fri May  3 11:33:35 2013 +0200

configconvert: make host->service linked service a template object, referenced by the host

this is not the best solution, as it it creates a service template for
each host-service relation. if you have many host_name entries defined
in your Icinga 1.x config for a service, this will create duplicates
then. requires some more code refactoring, therefore leaving the issue
open.

refs #3933

---

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

diff --git a/contrib/configconvert/Icinga2/Convert.pm b/contrib/configconvert/Icinga2/Convert.pm
index af0bb1c..dc59cf2 100644
--- a/contrib/configconvert/Icinga2/Convert.pm
+++ b/contrib/configconvert/Icinga2/Convert.pm
@@ -1510,10 +1510,24 @@ sub convert_2x {
             if ($obj_2x_service_host_name eq $obj_1x_host->{'__I2CONVERT_HOSTNAME'}) {
                 #debug("service_description: $obj_2x_service_service_description host_name: $obj_2x_service_host_name");
 
+                # 1. generate template name "host-service"
+                my $service_template_name = $obj_2x_service_host_name."-".$obj_2x_service_service_description;
+
+                # 2. make the service object a template with a special unique name
+                $cfg_obj_2x->{'service'}->{$service_obj_2x_key}->{'__I2CONVERT_IS_TEMPLATE'} = 1;
+                $cfg_obj_2x->{'service'}->{$service_obj_2x_key}->{'__I2CONVERT_TEMPLATE_NAME'} = $service_template_name;
+
+                # 3. use the template name as reference for the host->service
+                $cfg_obj_2x->{'host'}->{$host_obj_1x_key}->{'SERVICE'}->{$obj_2x_host_service_cnt}->{'__I2CONVERT_USES_TEMPLATE'} = 1;
+                push @{$cfg_obj_2x->{'host'}->{$host_obj_1x_key}->{'SERVICE'}->{$obj_2x_host_service_cnt}->{'__I2CONVERT_TEMPLATE_NAMES'}}, $service_template_name;
+                
+                # 4. define the service description for the service
+                $cfg_obj_2x->{'host'}->{$host_obj_1x_key}->{'SERVICE'}->{$obj_2x_host_service_cnt}->{'__I2CONVERT_SERVICEDESCRIPTION'} = $obj_2x_service_service_description;
+
                 ######################################
                 # memcpy prep'ed 2x service onto host
                 ######################################
-                @$cfg_obj_2x{'host'}->{$host_obj_1x_key}->{'SERVICE'}->{$obj_2x_host_service_cnt} = dclone(@$cfg_obj_2x{'service'}->{$service_obj_2x_key});
+                #@$cfg_obj_2x{'host'}->{$host_obj_1x_key}->{'SERVICE'}->{$obj_2x_host_service_cnt} = dclone(@$cfg_obj_2x{'service'}->{$service_obj_2x_key});
 
                 ######################################
                 # COMMAND MAGIC





More information about the icinga-checkins mailing list