def runner_on_unreachable(self, host, res): Logger.debug("unreachable -----------------------------------") a = json.dumps(res) Logger.debug(a) end_time = datetime.datetime.now() end_time = end_time.strftime('%Y-%m-%dT%H:%M:%SZ%z') self.log(host, UNREACHABLE, res) Service.update_log(host=host, global_id=self.global_id, task_uuid=self.task_uuid, task_status="unreachable", end_time=end_time,data=a )
def runner_on_failed(self, host, res, ignore_errors=False): Logger.debug("fail -----------------------------------") a = json.dumps(res) Logger.debug(a) end_time = datetime.datetime.now() end_time = end_time.strftime('%Y-%m-%dT%H:%M:%SZ%z') self.log(host, FAILED, res) Service.update_log(host=host, global_id=self.global_id, task_uuid=self.task_uuid, task_status="failed",end_time=end_time, data=a)
def runner_on_async_failed(self, host, res, jid): Logger.debug("async fail -----------------------------------") end_time = datetime.datetime.now() end_time = end_time.strftime('%Y-%m-%dT%H:%M:%SZ%z') a = json.dumps(res) Logger.debug(a) self.log(host, ASYNC_FAILED, res) Service.update_log(host=host, global_id=self.global_id, task_uuid=self.task_uuid, task_status="async_failed", end_time=end_time,data=a )
def runner_on_ok(self, host, res): Logger.debug("success **********************************") a = json.dumps(res) Logger.debug(a) end_time = datetime.datetime.now() end_time = end_time.strftime('%Y-%m-%dT%H:%M:%SZ%z') self.log(host, OK, res) Service.update_log(host=host, global_id=self.global_id, task_uuid=self.task_uuid, task_status="ok", end_time=end_time,data=a )
def update_log(self, task_status, detail): finish_time = time.strftime(self.TIME_FORMAT, time.localtime()) for i in range(1, self.max_try + 1): try: Service.update_log(host=self.host, global_id=self.global_id, task_uuid=self.uid, task_status=task_status, end_time=finish_time, data=detail) return except Exception as err: Logger.error( "Update log err for %d times:{}".format(str(err)) % i) raise AnsibleError("Update log DB error retry for %d times" % self.max_try)