added hostgroup to Job

This commit is contained in:
Johannes Findeisen 2013-10-10 23:16:36 +02:00
commit 131ce1a75b
2 changed files with 8 additions and 6 deletions

View file

@ -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)

View file

@ -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