Hi all.
I am attempting to write up a utility script to help speed up some of the tasks I perform regularly. At the moment I need to blacklist any slaves that have failed the task, delete all error reports and resume the failed job.
I am aware that there is already a system for this within deadline that does roughly the same thing, but this has been a great opportunity to learn some more about writing scripts in deadline.
I’ve got all the bones worked out, at the moment the stumbling block is that I cannot reset the error counter to zero. I am able to delete all error reports on the jobs themselves but the error counter doesn’t change. Any help would be greatly appriciated!
Here’s what I have so far:
import os
import sys
from Deadline.Scripting import *
from Deadline.Jobs import *
from DeadlineUI.Controls.Scripting.DeadlineScriptDialog import DeadlineScriptDialog
def __main__(*args):
selectedJobs = MonitorUtils.GetSelectedJobs()
if len(selectedJobs) > 0:
# collect bad slaves on all jobs + blacklist them on all selected jobs.
slaves_to_blacklist = []
for job in selectedJobs:
for task in RepositoryUtils.GetJobTasks(job, True):
# If the task has failed, add it to the bad list.
if task.TaskStatus == 'Failed':
slaves_to_blacklist.append(task.TaskSlaveName)
# Iterate over all the jobs and set the slaves to blacklist.
for job in selectedJobs:
if job.JobStatus == 'Failed':
RepositoryUtils.AddSlavesToMachineLimitList(job.ID, slaves_to_blacklist)
RepositoryUtils.DeleteAllJobReports(job.ID)
RepositoryUtils.ResumeFailedJob(job)