How to get SlaveInfo[] in post job script?

Hi Dwight

I have another scripting query I could do with a hand with.

I’m trying to create a post job script that fetches the slave IP address and possibly other info. From the SlaveUtils section of the scripting reference I’ve found the relevant GetMachineIPAddresses ( SlaveInfo[ ] slaveInfos ) function, however I can’t work out how to get/create the required SlaveInfo[] parameter. Can I use the slave name to create this parameter? Or is there another way?

Here’s my basic test script:

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

def main(*args):
deadlinePlugin = args[0]

# Attempt to fetch slave IP using deadline
slaveIpAddress = SlaveUtils.GetMachineIPAddresses ( SlaveInfo[ ] slaveInfos )

# Backup method of fetching slave IP
localIP = socket.gethostbyname(socket.gethostname())[/code]

Any pointers really appreciated, I’ve done my best to look through all the scripting resources but can’t find any solutions.

Thanks

Hey Dave,

There’s some weird stuff with our documentation at the moment that the devs fixed.

I did some digging, and it looks like the MachineInfo class has a “MachineIPAddress” attribute that’s a string. Info here:
docs.thinkboxsoftware.com/produc … 7d2663241a

That means if you get a SlaveInfo or PulseInfo, you can use that property.

To get a SlaveInfo object, you can use RepositoryUtils.GetSlaveInfo()
docs.thinkboxsoftware.com/produc … 760d1eb177

You can get the name of the current Slave using your deadlinePlugin variable there. The function is GetSlaveName()
docs.thinkboxsoftware.com/produc … fbb4a5bcf6

These new doc urls are crazy long…

Sorry for the confusion, but I meant to say I’m doing this from inside a post task script, not post job.

As I understand it you can’t access the RepositoryUtils functions from within a post task script, only the SlaveUtils. Is that correct?

You’ll have access to that class from just about everywhere within Deadline if you do your imports right.

I usually just steal the line that reads “from Deadline.Scripting import *”