05 September 2012

Scripting the backburner.xml file for Amazon EC2

A couple of people have contacted me about the PowerShell script I wrote while setting up 3DS Max Design to run in the cloud. Here it is, complete with comments. I'm also posting the backburner.xml file it modifies.

backburner.ps1
/* You must issue this command in a PowerShell window before the script will execute. It tells PS to run all local scripts, but none from the internet unless they're signed:

Set-ExecutionPolicy RemoteSigned

Run the script from the Startup menu using this command line (change path as appropriate):

powershell c:\backburner.ps1
*/

/* Stop Backburner service (should be started automatically) so we can alter the backburner.xml file. Change service name here (and at bottom) if it differs on your system. */

Stop-Service -displayname "Backburner Server version 2008.1.1"
Start-Sleep -s 10

# Retrieve computer name.
$computer = gc env:ComputerName

# Retrieve EC2 instance ID.
$wc = New-Object System.Net.WebClient
$id = $wc.DownloadString("http://169.254.169.254/latest/meta-data/instance-id")

# Retrieve and format MAC address.
$macaddress = getmac /fo csv /nh
$macaddress = $macaddress.substring(1,17)
$macaddress = $macaddress.replace("-","")

/* Copy content of backburner.xml template, replace placeholder values with real ones, write to user profile. If you run Backburner as a different user, adjust the location appropriately. */

$file = Get-Content p:\setup\backburner.xml
$file = Foreach-Object {$file -replace "SERVERHERE", $computer}
$file = Foreach-Object {$file -replace "MACHERE", $macaddress}
$file = Foreach-Object {$file -replace "DESCHERE", $id}
Set-Content C:\Users\Administrator\AppData\Local\backburner\backburner.xml $file

# Start Backburner service.
Start-Sleep -s 10
Start-Service -displayname "Backburner Server version 2008.1.1"

backburner.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!DOCTYPE SystemConfiguration [
<!ELEMENT SystemConfiguration (GeneralCfg*, TimerCfg*, LogCfg*, AppDetails*)>
<!ELEMENT GeneralCfg (ManagerPort, MaxBlockSize, NetworkMask)>
<!ELEMENT ManagerPort (#PCDATA)>
<!ELEMENT MaxBlockSize (#PCDATA)>
<!ELEMENT NetworkMask (#PCDATA)>
<!ELEMENT TimerCfg (AckTimeout, AckRetries, FastTimeout)>
<!ELEMENT AckTimeout (#PCDATA)>
<!ELEMENT AckRetries (#PCDATA)>
<!ELEMENT FastTimeout (#PCDATA)>
<!ELEMENT LogCfg (LogError, LogWarning, LogInfo, LogDebug, LogDebugex)>
<!ELEMENT LogError (#PCDATA)>
<!ELEMENT LogWarning (#PCDATA)>
<!ELEMENT LogInfo (#PCDATA)>
<!ELEMENT LogDebug (#PCDATA)>
<!ELEMENT LogDebugex (#PCDATA)>
<!ELEMENT AppDetails ANY>
]>
<SystemConfiguration>
<GeneralCfg>
<ManagerPort>3234</ManagerPort>
<ServerPort>3233</ServerPort>
<MaxBlockSize>128000</MaxBlockSize>
<NetworkMask>255.255.255.0</NetworkMask>
<HttpRedirection>http://www.autodesk.com</HttpRedirection>
</GeneralCfg>
<TimerCfg>
<AckTimeout>20000</AckTimeout>
<AckRetries>6</AckRetries>
<FastTimeout>4000</FastTimeout>
</TimerCfg>
<LogCfg>
<LogError>1</LogError>
<LogWarning>1</LogWarning>
<LogInfo>1</LogInfo>
<LogDebug>0</LogDebug>
<LogDebugex>0</LogDebugex>
<LogMaxFileSize>10485760</LogMaxFileSize>
</LogCfg>
<AppDetails>
<ServerSettings>
<ManagerName>10.0.0.11</ManagerName>
<AutoSearch>0</AutoSearch>
<ServerName>SERVERHERE</ServerName>
<ServerMAC>MACHERE</ServerMAC>
<Description>DESCHERE</Description>
</ServerSettings>
</AppDetails>
</SystemConfiguration>
A couple of notes about the XML file. First, the ManagerName entry must reflect the IP address of your Backburner Manager instance. I always launch that instance into VPC using the 10.0.0.11 address. If you do the same, the file needn't be manually edited at all.

Secondly, the file is placed in a shared folder on the Manager that is then mapped as a drive on each of the nodes. I mentioned that in the original article, but it bears repeating. That's why the script looks for the file in 'p:\setup'.

That should do it. If you have any trouble, please don't hesitate to contact me. Good luck!

No comments:

Post a Comment