Package linspector :: Package lib :: Package core :: Module job
[hide private]
[frames] | no frames]

Source Code for Module linspector.lib.core.job

 1  """ 
 2  This is what job_function needs as parameter for each job to successfully 
 3  execute. 
 4  """ 
 5   
 6  from command import Command 
 7   
8 -def generateId():
9 i=0 10 while True: 11 yield i 12 i+=1
13
14 -class JobInfo:
15 - def __init__(self, hostgroupname, members, hosts, hostServices, threshold, parent=None):
16 self.members = members 17 self.hosts = hosts 18 self.hostServices = hostServices 19 self.threshold = threshold 20 self.parent = parent 21 self.name = generateId() 22 #self.name = hostgroupname + str([str("_" + s.service.name ) for s in hostServices]) 23 self.jobs = []
24
25 - def __str__(self):
26 return self.name
27
28 - def setLogger(self, log):
29 self.log = log
30
31 - def appendJob(self, job):
32 self.jobs.append(job)
33
34 - def getNextExecutionTime(self):
35 nextExecution = None 36 for job in self.jobs: 37 jobExec = job.trigger.get_next_fire_time() 38 if nextExecution is None or nextExecution > jobExec: 39 nextExecution = jobExec 40 return nextExecution
41
42 - def handleCall(self):
43 self.log.d("handle call") 44 self.log.d(self.hostServices) 45 try: 46 47 for hs in self.hostServices: 48 self.log.d(str(hs)) 49 cmd=Command(hs.service.command, self.log) 50 cmd.call() 51 self.log.d(cmd.getAllOutput()) 52 except Error: 53 self.log.d(Error)
54 55 56 #must find real service command stored in hosts... 57 #but because of error, mentioned in NOTES,ruff, there is no ping i.e. 58 59 #cmd = Command(service.command) 60 #self.log.d("executing command: " + str(command)) 61 #cmd.call() 62 #return cmd 63