AWS Thinkbox Discussion Forums

Change machine limit doesn't work

From a job script, I try to change the machine limit slave list. Therefor I use the following commands:

limit = 'myMachine,'
slaves = [str(s).lower() for s in limit.split(', ') if s]
RepositoryUtils.SetMachineLimitListedSlaves(job.JobId, slaves)
print "Limit Slaves: ", [str(s) for s in jobLimitGroup(job.JobId).LimitGroupListedSlaves]

RepositoryUtils.SetMachineLimitWhiteListFlag(job.JobId, True)
print "White Flagged:", jobLimitGroup(job.JobId).LimitGroupWhitelistFlag

The cosole print:

2017-04-11 14:55:04:  PYTHON: Limit Slaves:  ['myMachine']
2017-04-11 14:55:04:  PYTHON: White Flagged: True

But when I check the job properties, no machines are in the list. But the list is flagged as whiteList.

I was also trying to save the job, but it doesn’t seem to make a difference

No need to save the job here, as we are using “Set” methods. The syntax needs to be in a certain form. Here’s an example:

[code]from Deadline.Scripting import *

def main():
selectedJobs = MonitorUtils.GetSelectedJobs()
for job in selectedJobs:
# slaves = [str(s).lower() for s in limit.split(",") if s] #wrong syntax
slaves = [‘myMachine’,] #syntax must be in this form
RepositoryUtils.SetMachineLimitListedSlaves(job.JobId, slaves)
RepositoryUtils.SetMachineLimitWhiteListFlag(job.JobId, True)[/code]

I think I was overwriting the job settings as I was saving the job in the end of a loop to change multiple jobs.

Example:

for job in hobs:
    job.SetJobEnvironmentKeyValue("myVar", "1")
    
    # Save job changes, before doing further changes
    # to avoid overwriting
    RepositoryUtils.SaveJob(job)
    
    slaves = [str(s).lower().strip() for s in limit.split(',')]
    RepositoryUtils.SetMachineLimitListedSlaves(job.JobId, slaves)
    RepositoryUtils.SetMachineLimitWhiteListFlag(job.JobId, status)    

Anyway, it’s working now.
Thanks

Privacy | Site terms | Cookie preferences