some new idea of message creation in services
This commit is contained in:
parent
bfcabe18e5
commit
1f75340e59
2 changed files with 25 additions and 6 deletions
|
|
@ -59,6 +59,7 @@ class Job:
|
||||||
UNKNOWN when a job throws an exception which is not handled by the job itself (not implemented)
|
UNKNOWN when a job throws an exception which is not handled by the job itself (not implemented)
|
||||||
"""
|
"""
|
||||||
self.status = "NONE"
|
self.status = "NONE"
|
||||||
|
self.response = None
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return str(self.__dict__)
|
return str(self.__dict__)
|
||||||
|
|
@ -116,7 +117,7 @@ class Job:
|
||||||
for task in member.get_tasks():
|
for task in member.get_tasks():
|
||||||
if self.status.lower() == task.get_task_type_name():
|
if self.status.lower() == task.get_task_type_name():
|
||||||
logger.debug("Executing Task of type: " + self.status)
|
logger.debug("Executing Task of type: " + self.status)
|
||||||
TaskExecutor.Instance().schedule_task(self.status + " " + self.get_message(), task)
|
TaskExecutor.Instance().schedule_task(self.get_response_message(), task)
|
||||||
|
|
||||||
def handle_call(self):
|
def handle_call(self):
|
||||||
logger.debug("handle call")
|
logger.debug("handle call")
|
||||||
|
|
@ -143,9 +144,18 @@ class Job:
|
||||||
def get_host(self):
|
def get_host(self):
|
||||||
return self.host
|
return self.host
|
||||||
|
|
||||||
|
def get_hostgroup(self):
|
||||||
|
return self.hostgroup
|
||||||
|
|
||||||
def set_result(self, result):
|
def set_result(self, result):
|
||||||
self.result = result
|
self.result = result
|
||||||
|
|
||||||
|
def get_response(self):
|
||||||
|
return self.response
|
||||||
|
|
||||||
|
def set_response(self, response):
|
||||||
|
self.response = response
|
||||||
|
|
||||||
def set_execution_end(self):
|
def set_execution_end(self):
|
||||||
self.execution_end = datetime.now()
|
self.execution_end = datetime.now()
|
||||||
|
|
||||||
|
|
@ -165,4 +175,9 @@ class Job:
|
||||||
self.errorcode = errcode
|
self.errorcode = errcode
|
||||||
|
|
||||||
def get_errorcode(self):
|
def get_errorcode(self):
|
||||||
return self.errorcode
|
return self.errorcode
|
||||||
|
|
||||||
|
def get_response_message(self):
|
||||||
|
message = str(self.status) + " [CLASS: " + str(self.jobHex) + "] " + \
|
||||||
|
str(self.get_hostgroup) + " " + str(self.get_host()) + " " + str(self.get_response())
|
||||||
|
return message
|
||||||
|
|
@ -71,14 +71,18 @@ class DummyService(Service):
|
||||||
|
|
||||||
if self.fail:
|
if self.fail:
|
||||||
job.set_errorcode(1)
|
job.set_errorcode(1)
|
||||||
job.set_message("[etc/dummy: " + job.jobHex + "] Failed on host: " + job.get_host() +
|
#job.set_message("[etc/dummy: " + job.jobHex + "] Failed on host: " + job.get_host() +
|
||||||
" Sleep: " + str(self.sleep) + " Fail: " + str(self.fail))
|
# " Sleep: " + str(self.sleep) + " Fail: " + str(self.fail))
|
||||||
|
|
||||||
|
job.set_response({"Message": "Failed", "Sleep": str(self.sleep), "Fail": str(self.fail)})
|
||||||
|
|
||||||
if job.get_errorcode() == -1:
|
if job.get_errorcode() == -1:
|
||||||
job.set_execution_successful(True)
|
job.set_execution_successful(True)
|
||||||
job.set_errorcode(0)
|
job.set_errorcode(0)
|
||||||
job.set_message("[etc/dummy: " + job.jobHex + "] Success on host: " + job.get_host() +
|
#job.set_message("[etc/dummy: " + job.jobHex + "] Success on host: " + job.get_host() +
|
||||||
" Sleep: " + str(self.sleep) + " Fail: " + str(self.fail))
|
# " Sleep: " + str(self.sleep) + " Fail: " + str(self.fail))
|
||||||
|
|
||||||
|
job.set_response({"Message": "Success", "Sleep": str(self.sleep), "Fail": str(self.fail)})
|
||||||
|
|
||||||
|
|
||||||
def create(kwargs):
|
def create(kwargs):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue