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
10 i = 0
11 while True:
12 yield i
13 i += 1
14
15
17 - def __init__(self, hostgroupname, members, hosts, hostServices, threshold, parent=None):
18 self.members = members
19 self.hosts = hosts
20 self.hostServices = hostServices
21 self.threshold = threshold
22 self.parent = parent
23 self.name = generateId()
24
25 self.jobs = []
26
28 return "JobInfo " + str(self.name)
29
32
35
37 nextExecution = None
38 for job in self.jobs:
39 jobExec = job.trigger.get_next_fire_time()
40 if nextExecution is None or nextExecution > jobExec:
41 nextExecution = jobExec
42 return nextExecution
43
45 self.log.d("handle call")
46 self.log.d(self.hostServices)
47 try:
48
49 for hs in self.hostServices:
50 self.log.d(str(hs))
51 cmd = Command(hs.service.command, self.log)
52 cmd.call()
53 self.log.d(cmd.getAllOutput())
54 except Exception:
55 self.log.d(Exception)
56