From dd984fedae1da967f9439d208d3b40ab6d4ea64b Mon Sep 17 00:00:00 2001 From: "Rafael.Timmerberg" Date: Wed, 19 Jun 2013 23:48:19 +0200 Subject: [PATCH] added pointer for hostgroup in service --- lib/config/parser.py | 4 ++++ lib/config/services.py | 4 ++++ lib/services/ping.py | 2 +- lib/services/service.py | 6 ++++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/config/parser.py b/lib/config/parser.py index a16205b..d2b9da7 100644 --- a/lib/config/parser.py +++ b/lib/config/parser.py @@ -251,4 +251,8 @@ class FullConfigParser(ConfigParser): id_get_func = lambda hostgroup: hostgroup.get_name() self.replace_pointer(layouts, hostgroups, id_list_func, id_get_func) + for hg in hostgroups: + for service in hg.get_services(): + service.set_hostgroup(hg) + return layouts \ No newline at end of file diff --git a/lib/config/services.py b/lib/config/services.py index 143c22d..9232a5a 100644 --- a/lib/config/services.py +++ b/lib/config/services.py @@ -4,6 +4,10 @@ class Service: self.command = command self.comment = comment self.parser = parser + self.hostgroup = None + + def set_hostgroup(self, hostgroup): + self.hostgroup = hostgroup def __str__(self): return "Service('Name: " + self.name + "', 'Command: " + self.command + ", 'Parser: " + self.parser + "')" diff --git a/lib/services/ping.py b/lib/services/ping.py index 33668f8..5553e09 100644 --- a/lib/services/ping.py +++ b/lib/services/ping.py @@ -8,7 +8,7 @@ from lib.services.service import Service class PingService(Service): def __init__(self, **kwargs): - Service.__init__(self, **kwargs) + super(PingService, self).__init__(**kwargs) def create(kwargs): diff --git a/lib/services/service.py b/lib/services/service.py index f77fef1..9ae770f 100644 --- a/lib/services/service.py +++ b/lib/services/service.py @@ -57,6 +57,12 @@ class Service(object): self._periods.extend(period) else: self._periods.append(period) + + def set_hostgroup(self, hostgroup): + self.hostgroup = hostgroup + + def get_hostgroup(self): + return self.hostgroup def get_periods(self): return self._periods