This commit is contained in:
Tomas Kopecek 2022-12-06 16:34:25 +01:00
parent c3c0a6a139
commit 6a23a12fd0
5 changed files with 150 additions and 5 deletions

View file

@ -7899,3 +7899,59 @@ def anon_handle_repoinfo(goptions, session, args):
# repoID option added in 1.33
if options.buildroots:
warn("--buildroots option is available with hub 1.33 or newer")
def anon_handle_scheduler_info(goptions, session, args):
"""[monitor] Show information about scheduling"""
usage = "usage: %prog schedulerinfo [options]"
parser = OptionParser(usage=get_usage_str(usage))
parser.add_option("-t", "--task", action="store", type=int, default=None,
help="Limit data to given task id")
parser.add_option("--host", action="store", default=None,
help="Limit data to given builder (name/id)")
parser.add_option("--state", action="store", type='str', default=None,
choices=[x for x in koji.TASK_STATES.keys()],
help="Limit data to task state")
(options, args) = parser.parse_args(args)
if len(args) > 0:
parser.error("This command takes no arguments")
ensure_connection(session, goptions)
host_id = None
if options.host:
try:
host_id = int(options.host)
except ValueError:
host_id = session.getHost(options.host, strict=True)['id']
if options.state:
state = koji.TASK_STATES[options.state]
else:
state = None
# get the data
runs = session.scheduler.getTaskRuns(taskID=options.task, hostID=host_id, state=state)
mask = '%(task_id)s\t%(host_id)s\t%(state)s\t%(create_time)s\t%(start_time)s\t%(end_time)s'
if not goptions.quiet:
header = mask % {
'task_id': 'Task',
'host_name': 'Host',
'state': 'State',
'create_time': 'Created',
'start_time': 'Started',
'end_time': 'Ended'
}
print(header)
print('-' * len(header))
for run in runs:
run['state'] = koji.TASK_STATES[runs['state']]
print(mask % run)
if host_id:
print('Host data for %s:' % options.host)
host_data = session.scheduler.getHostData(hostID=host_id)
if len(host_data) > 0:
print(host_data[0]['data'])
else:
print('-')