[icinga-checkins] icinga.org: icinga2/feature/configconvert-2743: configconvert: fix service description handling, it's now an inner conversion value

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


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

Author: Michael Friedrich <michael.friedrich at netways.de>
Date:   Thu May  2 20:36:44 2013 +0200

configconvert: fix service description handling, it's now an inner conversion value

previously, i've just re-used 'service_description' which isn't a valid
2.x attribute either. the lookup of service_description attribute in 1.x
templates works already, but populated __I2CONVERT_SERVICEDESCRIPTION
instead. in favor of having a generated value for all our objects, we'll
use that one, also for dumping the configuration.

even further, this is also changed for the service->hostgroup<-hosts
conversion then.

this also avoids writing empty service names into host->service objects.

fixes #4019

---

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

diff --git a/contrib/configconvert/Icinga2/Convert.pm b/contrib/configconvert/Icinga2/Convert.pm
index c7b6390..ca50f5b 100644
--- a/contrib/configconvert/Icinga2/Convert.pm
+++ b/contrib/configconvert/Icinga2/Convert.pm
@@ -669,6 +669,7 @@ sub convert_2x {
 
             # we can only look up services with their uniqueness to the host_name
             $obj_1x_service->{'__I2CONVERT_SERVICEDESCRIPTION'} = obj_1x_get_service_service_description($cfg_obj_1x, $obj_1x_service, $service_host_name);
+            #say Dumper($obj_1x_service);
 
             # skip non-template objects without a valid service description (we cannot tolerate 'name' here!)
             # XXX find a better way - we actually need all services in the list, even if __I2CONVERT_SERVICEDESCRIPTION is undef
@@ -1264,6 +1265,7 @@ sub convert_2x {
             $obj_2x_service_inherit->{__I2CONVERT_USES_TEMPLATE} = 1;
             push @{$obj_2x_service_inherit->{'__I2CONVERT_TEMPLATE_NAMES'}}, $obj_2x_service->{'__I2CONVERT_TEMPLATE_NAME'};
             $obj_2x_service_inherit->{'service_description'} = $obj_2x_service->{'service_description'};
+            $obj_2x_service_inherit->{'__I2CONVERT_SERVICEDESCRIPTION'} = $obj_2x_service->{'service_description'};
 
             # link the service inherit to the host template
             $obj_2x_host_template->{'SERVICE'}->{$svc_count} = $obj_2x_service_inherit;
diff --git a/contrib/configconvert/Icinga2/ExportIcinga2Cfg.pm b/contrib/configconvert/Icinga2/ExportIcinga2Cfg.pm
index 6a9640e..e592f2a 100644
--- a/contrib/configconvert/Icinga2/ExportIcinga2Cfg.pm
+++ b/contrib/configconvert/Icinga2/ExportIcinga2Cfg.pm
@@ -228,7 +228,7 @@ sub dump_service_2x {
     my $icinga2_cfg = shift;
     my $service_2x = shift;
     my $object_type = "object"; # object or template
-    my $service_description = $service_2x->{'service_description'};
+    my $service_description = $service_2x->{__I2CONVERT_SERVICEDESCRIPTION};
 
     # only dump templates, the objects will be directly created in host objects
     if ($service_2x->{__I2CONVERT_IS_TEMPLATE} == 0) {
@@ -506,7 +506,7 @@ sub dump_host_2x {
     foreach my $service_2x_key (keys %{$host_2x->{'SERVICE'}}) {
         my $service_2x = $host_2x->{'SERVICE'}->{$service_2x_key};
 
-        dump_config_line($icinga2_cfg, "\tservices[\"$service_2x->{'service_description'}\"] = {");
+        dump_config_line($icinga2_cfg, "\tservices[\"$service_2x->{__I2CONVERT_SERVICEDESCRIPTION}\"] = {");
 
         ####################################################
         # templates





More information about the icinga-checkins mailing list