AWS Thinkbox Discussion Forums

Autoconfigure Groups/Pools?

Is it possible to have pools and groups also defined by IP or computer name?

I would like to have it be like

Render-i7* => Group i7_v01 + Rendernodes etc.

Hello Gavin,

So we actually have some code you can use to base this functionality off of. github.com/ThinkboxSoftware/Dea … gureSlaves is the github link for that.

You can also do this with an event listener by hooking the OnSlaveStarted callback. That way you never have to think about it if you add new nodes/slaves.

is there any documentation for the onSlavestarted callback etc?

Well, you just need to implement an event listener subclass. The boilerplate would look something like this:

[code]from Deadline.Events import DeadlineEventListener

class CustomEventListener(DeadlineEventListener):
def init(self):
self.OnSlaveStartedCallback += self.slaveStarted

def slaveStarted(self, slaveName):
    # Do stuff

def doCleanup(self):
    del self.OnSlaveStartedCallback

def GetDeadlineEventListener():
return CustomEventListener()

def CleanupDeadlineEventListener(listener):
listener.doCleanup()[/code]

I got that far, I more meant, does OnSlaveStarted() pass a slave? The documentation I could find is pretty sparse:

GenericDelegate1<string> Deadline.Events.DeadlineEventListener.OnSlaveStartedCallback If a function is assigned to this callback, it will be called when a slave is started.

Is that the slave name? How do I get the slave that is currently starting?

Yes. That’s a generic way of saying that whatever you connect to the callback will be passed a string, and since Deadline only refers to slaves by name, it should be the slave name.

Thanks, Ok for the sake of future generations here is a basic script.

###############################################################
## Imports
###############################################################
from System.Diagnostics import *
from System.IO import *
from System import TimeSpan

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

import re, sys, os, subprocess, traceback, shlex

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

def CleanupDeadlineEventListener( eventListener ):
    eventListener.Cleanup()

###############################################################
## The Draft event listener class.
###############################################################
class ConfigSlaveEventListener (DeadlineEventListener):
    def __init__( self ):
        self.OnSlaveStartedCallback += self.OnSlaveStarted
    
    def Cleanup( self ):
        del self.OnSlaveStartedCallback

    
    ## This is called when the job finishes rendering.
    def OnSlaveStarted( self, slavename ):
        try:
			slaveSettings = RepositoryUtils.GetSlaveSettings(slavename, True)
			if slavename.lower()[0:10] == "render-vm-":

				remotehost="render-" + slavename[-2:] + "-host"
				cmd="getmac /S " + remotehost + " /NH"
				p=subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
				output, errors = p.communicate()
				if output is not None :
					if output != "":
						item =  output.split("\n")[1].split(" ")[0]
						slaveSettings.SlaveMacAddressOverride = item
						RepositoryUtils.SaveSlaveSettings(slaveSettings)
			
			
				RepositoryUtils.AddPoolToSlave(slavename, "urgent")
				RepositoryUtils.AddPoolToSlave(slavename, "global")
				RepositoryUtils.AddGroupToSlave(slavename, "global")
				RepositoryUtils.AddGroupToSlave(slavename, "i7_v01")
				RepositoryUtils.AddGroupToSlave(slavename, "rendernodes")
				
				pmanage = RepositoryUtils.GetPowerManagementOptions()
				pmanage.Groups[0].SlaveNames.append(slavename)
			
        except:
            ClientUtils.LogText( traceback.format_exc() )[/code]


If you append a slavename to a powermanagement group can you just get multiple duplicates? I'm getting an error[code]
 'String[]' object has no attribute 'append'

By the way, again for the sake of future generations who might run across this post and might want to configure slaves to set the MAC override if they’re a VM there is a more straight forward way than parsing the slave name (since that could be a random generated name).

HKLM:\SOFTWARE\Microsoft\Virtual Machine\Guest\Parameters\PhysicalHostName

Thanks Gavin, that registry key could come in handy. I would add that it only applies to Hyper-V virtual machines.

Hey Gavin,

Thanks for sharing that, I am sure the future generations will be pleased.

I’mma put this on Github :stuck_out_tongue:

Boop:
github.com/ThinkboxSoftware/Dea … veAutoconf

Cool, you could make it even fancier by adding a pool list to the dlint/param scripts.

You underestimate my laziness sir!

Actually, I’m trying to get into the habit of polishing them up as I make them. I’m still not that fast with the Deadline API believe it or not.

You could also open a pull request :smiley:

Damnit you called my bluff! I wanted to see how you would do it to learn haha.

Privacy | Site terms | Cookie preferences