How to disable a Slave using a py script

Hi,

Is there a command that allows to disable/enable a slave (In the monitor) with a python script ?

Not using the DeadlineCommand like this: "DeadlineCommand SetSlaveSetting [Slave Name] Enabled 0"

but something closer to that: SlaveUtils.SendRemoteCommandNoWait( slaveName, "deadlineslave -s )"

or… Any other way :slight_smile:
Thanks

Hi,
Try this:

[code]from Deadline.Slaves import *

mySlaveSettings = SlaveSettings()

Set Slave Disabled

mySlaveSettings.SlaveEnabled = False

Set Slave Enabled

mySlaveSettings.SlaveEnabled = True

RepositoryUtils.SaveSlaveSettings()[/code]

Mike

Thanks a lot,
Is there a way to do this per slave ?

here is the code I am writing: to launch a vrayspawner, shutdown the slave and disable it:

[code]from System.IO import *
from Deadline.Scripting import *

def main():
mySlaveSettings = SlaveSettings()
slaveNames = SlaveUtils.GetSelectedSlaveNames()
for slaveName in slaveNames:
SlaveUtils.SendRemoteCommandNoWait( slaveName, ““cmd” /C START “aa” “C:/Program Files/Autodesk/3ds Max 2011/vrayspawner2011.exe””)
SlaveUtils.SendRemoteCommandNoWait( slaveName, “deadlineslave -s”)[/code]

Then, when I’m done, I use another script to reverse the sequence:

[code]from System.IO import *
from Deadline.Scripting import *

def main():
slaveNames = SlaveUtils.GetSelectedSlaveNames()
for slaveName in slaveNames:
SlaveUtils.SendRemoteCommandNoWait( slaveName, “taskkill /im vrayspawner2011.exe /f /t” )
SlaveUtils.SendRemoteCommandNoWait( slaveName, “deadlineslave”)[/code]

I am trying to find a command that would include the “slavename” to allow multiple slave selection.

Regards,

Would this work?

slaveNames = SlaveUtils.GetSelectedSlaveNames()
slaveList = StringUtils.ToCommaSeparatedString( slaveNames )
ClientUtils.ExecuteCommand( "SetSlaveSetting "\" + slaveList + "\" Enabled False" )

Note that if you’re using Deadline 4.x, you’ll have to use ScriptUtils.ExecuteCommand instead (ScriptUtils is deprecated in 5.0).

Cheers,

  • Ryan