linspector-old/lib/core/job.py

45 lines
1.3 KiB
Python
Raw Normal View History

2013-05-16 23:03:00 +02:00
"""
2013-05-27 20:27:57 +02:00
This is what job_function needs as parameter for each job to successfully
2013-05-16 23:03:00 +02:00
execute.
"""
from command import Command
2013-05-16 23:03:00 +02:00
2013-05-27 01:44:28 +02:00
class JobInfo:
def __init__(self, hostgroupname, members, hosts, service, threshold, parent=None):
2013-05-16 23:03:00 +02:00
self.members = members
2013-05-27 01:44:28 +02:00
self.hosts = hosts
2013-05-16 23:03:00 +02:00
self.service = service
2013-05-27 01:44:28 +02:00
self.threshold = threshold
self.parent = parent
2013-05-27 20:28:36 +02:00
self.name = hostgroupname + "_" + service.name
self.jobs = []
2013-05-27 01:44:28 +02:00
def __str__(self):
return self.name
def setLogger(self, log):
self.log = log
def appendJob(self, job):
self.jobs.append(job)
def getNextExecutionTime(self):
nextExecution = None
for job in self.jobs:
jobExec = job.trigger.get_next_fire_time()
if nextExecution is None or nextExecution > jobExec:
nextExecution = jobExec
return nextExecution
def handleCall(self):
print "about to call command " + str(self.service.command)
#must find real service command stored in hosts...
#but because of error, mentioned in NOTES,ruff, there is no ping i.e.
#cmd = Command(service.command)
#self.log.d("executing command: " + str(command))
#cmd.call()
#return cmd