From f4dcab2bf6f71f8d9ee367fdc634d7cfea3bfa7f Mon Sep 17 00:00:00 2001 From: Olivier Hanesse Date: Fri, 14 Aug 2015 17:10:36 +0200 Subject: [PATCH] Fix issue when using duplicate and inheritance (close #1676) --- shinken/objects/service.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/shinken/objects/service.py b/shinken/objects/service.py index 8c899bc89f..887afd763d 100644 --- a/shinken/objects/service.py +++ b/shinken/objects/service.py @@ -1754,6 +1754,13 @@ def explode(self, hosts, hostgroups, contactgroups, # items::explode_trigger_string_into_triggers self.explode_trigger_string_into_triggers(triggers) + # Explode services that have a duplicate_foreach clause + duplicates = [s.id for s in self if getattr(s, 'duplicate_foreach', '')] + for id in duplicates: + s = self.items[id] + self.explode_services_duplicates(hosts, s) + if not s.configuration_errors: + self.remove_item(s) # Then for every host create a copy of the service with just the host # because we are adding services, we can't just loop in it @@ -1786,14 +1793,6 @@ def explode(self, hosts, hostgroups, contactgroups, self.explode_contact_groups_into_contacts(t, contactgroups) self.explode_services_from_templates(hosts, t) - # Explode services that have a duplicate_foreach clause - duplicates = [s.id for s in self if getattr(s, 'duplicate_foreach', '')] - for id in duplicates: - s = self.items[id] - self.explode_services_duplicates(hosts, s) - if not s.configuration_errors: - self.remove_item(s) - to_remove = [] for service in self: host = hosts.find_by_name(service.host_name)