added job handling... a bit... :)
This commit is contained in:
parent
93a3d626d8
commit
0616ea4701
5 changed files with 77 additions and 36 deletions
|
|
@ -2,9 +2,7 @@
|
|||
This is what job_function needs as parameter for each job to successfully
|
||||
execute.
|
||||
"""
|
||||
|
||||
from lib.core.command import Command
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
def generateId():
|
||||
i = 0
|
||||
|
|
@ -12,16 +10,18 @@ def generateId():
|
|||
yield i
|
||||
i += 1
|
||||
|
||||
|
||||
class JobInfo:
|
||||
class Job:
|
||||
def __init__(self, service):
|
||||
self.service = service
|
||||
self.name = generateId()
|
||||
self.job = None
|
||||
self.jobInfos = []
|
||||
self.hostThreshold = {}
|
||||
for host in service.get_hostgroup().get_hosts():
|
||||
self.hostThreshold[host] = service.get_threshold()
|
||||
|
||||
|
||||
def __str__(self):
|
||||
return "JobInfo " + str(self.name)
|
||||
|
||||
return str(self.__dict__)
|
||||
|
||||
def set_logger(self, log):
|
||||
self.log = log
|
||||
|
||||
|
|
@ -31,8 +31,33 @@ class JobInfo:
|
|||
def handle_call(self):
|
||||
self.log.d("handle call")
|
||||
self.log.d(self.service)
|
||||
try:
|
||||
|
||||
self.service._execute()
|
||||
except Exception, e:
|
||||
self.log.d(e)
|
||||
for host in self.service.get_hostgroup().get_hosts():
|
||||
try:
|
||||
jobInfo = JobInfo(host, self.service)
|
||||
result = self.service._execute(host)
|
||||
jobInfo.set_result(result)
|
||||
jobInfo.set_successfull(self.service.was_execution_successful())
|
||||
jobInfo.set_execution_end()
|
||||
|
||||
except Exception, e:
|
||||
self.log.d(e)
|
||||
|
||||
|
||||
class JobInfo:
|
||||
def __init__(self, host, service):
|
||||
self.id = generateId()
|
||||
self.host = host
|
||||
self.service = service
|
||||
self.executionBegin = datetime.now()
|
||||
|
||||
def set_result(self, result):
|
||||
self.result = result
|
||||
|
||||
def set_execution_end(self):
|
||||
self.executionEnd = datetime.now()
|
||||
|
||||
def set_execution_successful(self, successful):
|
||||
self.executionSuccess = successful
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue