AWS Thinkbox Discussion Forums

Configure Event on Pool

Hi !

I try to execut a events script only on selected pool or selected Slave
I do not see how to do that
Can you help me please ?

Regards

There is no event for pool changes, but you could add the following to a slave level event:

from Deadline.Events import *
from Deadline.Scripting import *


##################################################################################################
# This is the function called by Deadline to get an instance of the Draft event listener.
##################################################################################################
def GetDeadlineEventListener():
    return slave_jobStartListener()


######################################################################
## This is the function that Deadline calls when the event plugin is
## no longer in use so that it can get cleaned up.
######################################################################
def CleanupDeadlineEventListener(deadlinePlugin):
    deadlinePlugin.Cleanup()


class slave_jobStartListener(DeadlineEventListener):
    

    def __init__(self):
        # Set up the event callbacks here
        
        self.OnSlaveStartingJobCallback += self.OnSlaveStartingJob

    def Cleanup(self):
        del self.OnSlaveRenderingCallback


     def OnSlaveStartingJob(self, slave_name, job):
        
        # slave_name will give you the string of the slave that is currently running
        self.LogInfo("slave_jobStart:: slave_name: %s" % slave_name)

        # so we can use this in other places
        # this returns a slave settings object
        slaveSettings = RepositoryUtils.GetSlaveSettings(slave_name, True)

        #get the pools that the machine is assigned:
        my_pools = slaveSettings.SlavePools

        # not sure what is getting returned for this?
        self.LogInfo("slave_jobStart:: pools assigned: %s" % my_pools)


        if 'cool_pool' in my_pools:
            self.special_slave_function()


	# you can also see the pool that the job is set to, via the job object that was passed to the event:
	self.LogInfo("job.JobPool: %s" % job.JobPool)

    def special_slave_function(self):

        # do something cool here.
        pass

This should give you a base to start with.
Hope this helps.

Cheers
Kym

Ho thanks ! Many Thanks !! :smiley:

Edit : i just use this function for get slave Name

Deadline.Slaves.SlaveInfo.SlaveName

Thanks for the assist Kym!

Privacy | Site terms | Cookie preferences