Fail if host is disabled
This commit is contained in:
parent
182c8feb29
commit
660779c848
1 changed files with 10 additions and 7 deletions
|
|
@ -16,9 +16,10 @@ allowed_methods = None
|
|||
|
||||
@export
|
||||
def saveFailedTree(taskID, full=False, **opts):
|
||||
'''xmlrpc method for creating saveFailedTree task. If arguments are
|
||||
invalid, error message is returned. Otherwise task id of newly created
|
||||
task is returned.'''
|
||||
"""Create saveFailedTree task
|
||||
|
||||
If arguments are invalid, error message is returned. Otherwise task id of
|
||||
newly created task is returned."""
|
||||
global config, allowed_methods
|
||||
|
||||
# let it raise errors
|
||||
|
|
@ -35,12 +36,14 @@ def saveFailedTree(taskID, full=False, **opts):
|
|||
|
||||
task_info = kojihub.Task(taskID).getInfo()
|
||||
if task_info['state'] != koji.TASK_STATES['FAILED']:
|
||||
raise koji.PreBuildError, 'Task %s has not failed. Only failed tasks can upload their buildroots.' % taskID
|
||||
raise koji.PreBuildError("Task %s has not failed. Only failed tasks can upload their buildroots." % taskID)
|
||||
elif allowed_methods != '*' and task_info['method'] not in allowed_methods:
|
||||
raise koji.PreBuildError, 'Only %s tasks can upload their buildroots (Task %s is %s).' % \
|
||||
(', '.join(allowed_methods), task_info['id'], task_info['method'])
|
||||
raise koji.PreBuildError("Only %s tasks can upload their buildroots (Task %s is %s)." % \
|
||||
(', '.join(allowed_methods), task_info['id'], task_info['method']))
|
||||
elif task_info["owner"] != context.session.user_id and not context.session.assertPerm('admin'):
|
||||
raise koji.ActionNotAllowed, "only owner of failed task or 'admin' can run this task"
|
||||
raise koji.ActionNotAllowed("Only owner of failed task or 'admin' can run this task.")
|
||||
elif not kojihub.get_host(task_info['host_id'])['enabled']:
|
||||
raise koji.PreBuildError("Host is disabled.")
|
||||
|
||||
args = koji.encode_args(taskID, full, **opts)
|
||||
taskopts = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue