Commit a76184b2 authored by Nikos Skalkotos's avatar Nikos Skalkotos

eventd: cleanup get_time_from_status()

Make sure InvalidBackendStatus is raised if we run into an unknown
status.
parent 8107b4ec
......@@ -80,21 +80,19 @@ def get_time_from_status(op, job):
"""
status = op.status
if status == constants.JOB_STATUS_QUEUED:
time = job.received_timestamp
return job.received_timestamp
try: # Compatibility with Ganeti version
if status == constants.JOB_STATUS_WAITLOCK:
time = op.start_timestamp
return op.start_timestamp or job.end_timestamp
except AttributeError:
if status == constants.JOB_STATUS_WAITING:
time = op.start_timestamp
return op.start_timestamp or job.end_timestamp
if status == constants.JOB_STATUS_CANCELING:
time = op.start_timestamp
return op.start_timestamp or job.end_timestamp
if status == constants.JOB_STATUS_RUNNING:
time = op.exec_timestamp
return op.exec_timestamp or job.end_timestamp
if status in constants.JOBS_FINALIZED:
time = op.end_timestamp
return time and time or job.end_timestamp
return op.end_timestamp or job.end_timestamp
raise InvalidBackendStatus(status, job)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment