fix scheduler-info
This commit is contained in:
parent
fab35bedcb
commit
9b62b2cbea
2 changed files with 30 additions and 13 deletions
|
|
@ -7901,6 +7901,12 @@ def anon_handle_repoinfo(goptions, session, args):
|
||||||
warn("--buildroots option is available with hub 1.33 or newer")
|
warn("--buildroots option is available with hub 1.33 or newer")
|
||||||
|
|
||||||
|
|
||||||
|
def _format_ts(ts):
|
||||||
|
if ts:
|
||||||
|
return time.strftime("%y-%m-%d %H:%M:%S", time.localtime(ts))
|
||||||
|
else:
|
||||||
|
return ''
|
||||||
|
|
||||||
def anon_handle_scheduler_info(goptions, session, args):
|
def anon_handle_scheduler_info(goptions, session, args):
|
||||||
"""[monitor] Show information about scheduling"""
|
"""[monitor] Show information about scheduling"""
|
||||||
usage = "usage: %prog schedulerinfo [options]"
|
usage = "usage: %prog schedulerinfo [options]"
|
||||||
|
|
@ -7908,8 +7914,8 @@ def anon_handle_scheduler_info(goptions, session, args):
|
||||||
parser.add_option("-t", "--task", action="store", type=int, default=None,
|
parser.add_option("-t", "--task", action="store", type=int, default=None,
|
||||||
help="Limit data to given task id")
|
help="Limit data to given task id")
|
||||||
parser.add_option("--host", action="store", default=None,
|
parser.add_option("--host", action="store", default=None,
|
||||||
help="Limit data to given builder (name/id)")
|
help="Limit data to given builder id")
|
||||||
parser.add_option("--state", action="store", type='str', default=None,
|
parser.add_option("--state", action="store", type='choice', default=None,
|
||||||
choices=[x for x in koji.TASK_STATES.keys()],
|
choices=[x for x in koji.TASK_STATES.keys()],
|
||||||
help="Limit data to task state")
|
help="Limit data to task state")
|
||||||
(options, args) = parser.parse_args(args)
|
(options, args) = parser.parse_args(args)
|
||||||
|
|
@ -7925,27 +7931,36 @@ def anon_handle_scheduler_info(goptions, session, args):
|
||||||
except ValueError:
|
except ValueError:
|
||||||
host_id = session.getHost(options.host, strict=True)['id']
|
host_id = session.getHost(options.host, strict=True)['id']
|
||||||
|
|
||||||
if options.state:
|
|
||||||
state = koji.TASK_STATES[options.state]
|
|
||||||
else:
|
|
||||||
state = None
|
|
||||||
|
|
||||||
# get the data
|
# get the data
|
||||||
runs = session.scheduler.getTaskRuns(taskID=options.task, hostID=host_id, state=state)
|
clauses = []
|
||||||
mask = '%(task_id)s\t%(host_id)s\t%(state)s\t%(create_time)s\t%(start_time)s\t%(end_time)s'
|
if options.task:
|
||||||
|
clauses.append(('task_id', options.task))
|
||||||
|
if options.host:
|
||||||
|
clauses.append(('host_id', options.host))
|
||||||
|
if options.state:
|
||||||
|
clauses.append(('state', koji.TASK_STATES[options.state]))
|
||||||
|
|
||||||
|
runs = session.scheduler.getTaskRuns(
|
||||||
|
clauses=clauses,
|
||||||
|
fields=('task_id', 'host_name', 'state', 'create_ts', 'start_ts', 'completion_ts')
|
||||||
|
)
|
||||||
|
mask = '%(task_id)-9s %(host_name)-20s %(state)-7s ' \
|
||||||
|
'%(create_ts)-17s %(start_ts)-17s %(completion_ts)-17s'
|
||||||
if not goptions.quiet:
|
if not goptions.quiet:
|
||||||
header = mask % {
|
header = mask % {
|
||||||
'task_id': 'Task',
|
'task_id': 'Task',
|
||||||
'host_name': 'Host',
|
'host_name': 'Host',
|
||||||
'state': 'State',
|
'state': 'State',
|
||||||
'create_time': 'Created',
|
'create_ts': 'Created',
|
||||||
'start_time': 'Started',
|
'start_ts': 'Started',
|
||||||
'end_time': 'Ended'
|
'completion_ts': 'Ended',
|
||||||
}
|
}
|
||||||
print(header)
|
print(header)
|
||||||
print('-' * len(header))
|
print('-' * len(header))
|
||||||
for run in runs:
|
for run in runs:
|
||||||
run['state'] = koji.TASK_STATES[runs['state']]
|
run['state'] = koji.TASK_STATES[run['state']]
|
||||||
|
for ts in ('create_ts', 'start_ts', 'completion_ts'):
|
||||||
|
run[ts] = _format_ts(run[ts])
|
||||||
print(mask % run)
|
print(mask % run)
|
||||||
|
|
||||||
if host_id:
|
if host_id:
|
||||||
|
|
|
||||||
|
|
@ -172,6 +172,8 @@ class TaskRunsQuery(QueryView):
|
||||||
'host_id': ['scheduler_task_runs.host_id', None],
|
'host_id': ['scheduler_task_runs.host_id', None],
|
||||||
'active': ['scheduler_task_runs.active', None],
|
'active': ['scheduler_task_runs.active', None],
|
||||||
'create_ts': ["date_part('epoch', scheduler_task_runs.create_time)", None],
|
'create_ts': ["date_part('epoch', scheduler_task_runs.create_time)", None],
|
||||||
|
'start_ts': ["date_part('epoch', task.start_time)", 'task'],
|
||||||
|
'completion_ts': ["date_part('epoch', task.completion_time)", 'task'],
|
||||||
}
|
}
|
||||||
default_fields = ('id', 'task_id', 'host_id', 'active', 'create_ts')
|
default_fields = ('id', 'task_id', 'host_id', 'active', 'create_ts')
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue