Expose assignTask via CLI
This commit is contained in:
parent
1158070b83
commit
a1b5f3ce67
1 changed files with 39 additions and 0 deletions
39
cli/koji
39
cli/koji
|
|
@ -559,6 +559,45 @@ def handle_add_group(options, session, args):
|
||||||
|
|
||||||
session.groupListAdd(tag, group)
|
session.groupListAdd(tag, group)
|
||||||
|
|
||||||
|
def handle_assign_task(options, session, args):
|
||||||
|
"[admin] Assign a task to a host"
|
||||||
|
usage = _('usage: %prog assign-task task_id hostname')
|
||||||
|
usage += _('\n(Specify the --help global option for a list of other help options)')
|
||||||
|
parser = OptionParser(usage=usage)
|
||||||
|
parser.add_option('-f', '--force', action='store_true', default=False,
|
||||||
|
help=_('force to assign a non-free task'))
|
||||||
|
(options, args) = parser.parse_args(args)
|
||||||
|
|
||||||
|
if len(args) != 2:
|
||||||
|
parser.error(_('please specify a task id and a hostname'))
|
||||||
|
else:
|
||||||
|
task_id = int(args[0])
|
||||||
|
hostname = args[1]
|
||||||
|
|
||||||
|
taskinfo = session.getTaskInfo(task_id, request=False)
|
||||||
|
if taskinfo is None:
|
||||||
|
raise koji.GenericError, "No such task: %s" % task_id
|
||||||
|
|
||||||
|
hostinfo = session.getHost(hostname)
|
||||||
|
if hostinfo is None:
|
||||||
|
raise koji.GenericError, "No such host: %s" % hostname
|
||||||
|
|
||||||
|
force = False
|
||||||
|
if options.force:
|
||||||
|
force = True
|
||||||
|
|
||||||
|
activate_session(session)
|
||||||
|
if not session.hasPerm('admin'):
|
||||||
|
print "This action requires admin privileges"
|
||||||
|
return 1
|
||||||
|
|
||||||
|
ret = session.assignTask(task_id, hostname, force)
|
||||||
|
if ret:
|
||||||
|
print 'assigned task %d to host %s' % (task_id, hostname)
|
||||||
|
else:
|
||||||
|
print 'failed to assign task %d to host %s' %s (task_id, hostname)
|
||||||
|
|
||||||
|
|
||||||
def handle_add_host(options, session, args):
|
def handle_add_host(options, session, args):
|
||||||
"[admin] Add a host"
|
"[admin] Add a host"
|
||||||
usage = _("usage: %prog add-host [options] hostname arch [arch2 ...]")
|
usage = _("usage: %prog add-host [options] hostname arch [arch2 ...]")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue