From 131ce1a75be6dd93f84f48bb25e28a29073c3c33 Mon Sep 17 00:00:00 2001 From: Johannes Findeisen Date: Thu, 10 Oct 2013 23:16:36 +0200 Subject: [PATCH] added hostgroup to Job --- bin/linspector | 2 +- linspector/core/job.py | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/bin/linspector b/bin/linspector index 38359bb..cc287a8 100755 --- a/bin/linspector +++ b/bin/linspector @@ -114,7 +114,7 @@ def main(): for service in hostgroup.get_services(): for host in hostgroup.get_hosts(): for period in service.get_periods(): - job = Job(service, host, hostgroup.get_members(), hostgroup.get_processors(), core) + job = Job(service, host, hostgroup.get_members(), hostgroup.get_processors(), core, hostgroup) schedulerJob = period.createJob(scheduler, job, handleJob) if schedulerJob is not None: job.set_job(schedulerJob) diff --git a/linspector/core/job.py b/linspector/core/job.py index fc49733..a82f5be 100644 --- a/linspector/core/job.py +++ b/linspector/core/job.py @@ -32,21 +32,21 @@ def generateId(): class Job: - def __init__(self, service, host, members, processors, core): + def __init__(self, service, host, members, processors, core, hostgroup): self.service = service self.host = host self.members = members self.processors = processors self.core = core + self.hostgroup = hostgroup self.jobInfos = [] self.jobThreshold = 0 def __str__(self): return str(self.__dict__) - def __hex__(self): - return hex(crc32(str(self.service) + str(self.host) + str(self.members))) + return hex(crc32(str(self.hostgroup) + str(self.host) + str(self.service) + str(self.members))) def hex_string(self): ret = self.__hex__() @@ -62,7 +62,9 @@ class Job: self.log = log def pretty_string(self): - return self.hex_string() + ": (" + str(self.host) + str(self.service) + str(self.job) + ")" + ret = (self.hex_string() + ": (Hostgroup: " + str(self.hostgroup.get_name()) + + " Host: " + str(self.host) + " Service: " + str(self.service) + str(self.job) + ")") + return ret def set_job(self, job): self.job = job @@ -103,7 +105,7 @@ class Job: class JobInfo(object): - def __init__(self,jobHex, host, service): + def __init__(self, jobHex, host, service): self.id = generateId() self.jobHex = jobHex self.host = host