Powermanagement with VMs

We’re experimenting with VMs again… but run into a problem I had forgotten about, you can’t power manage with VMs. Is there a way to shut down a Hyper-V host when all of the render node VMs shut down? So like if no VMs are running after 3 minutes shut down? Could I just have a powershell script running on loop in the bg kind of like this:

wait 3600 while (true) do ( $VMs = collect-vms() $running = 0 for each $V in $VMs ( if $V.state != "off" ($running +=1) ) if $running == 0 ( shutdown -t 0 ) )

Hey Gavin! No idea to be honest as we haven’t played much with Hyper-V (only the APIs) here. I think your logic is pretty sound though.

Waking the machines will be kind of interesting. I guess you’d need to write a script that would map different VMs to their associated servers and then their VMs and run it via the custom wake up command? Pulse will keep issuing that command until the Slave is ‘online’, so it’ll handle the latency of host boot up just fine.

Kind of fun to think about.

Is this an area that Thinkbox is interested in collaborating on? A sort of “cloud-lite” manager that doesn’t use Openstack but just a couple scripts or even Deadline configuration to say “Slaves 0-2 are on hardware #######” for WOL requests? Or like a DeadlineLauncherHyperV that starts/stops VMs on hardware.

The scripting would be pretty easy too for a DeadlineVMLauncher application to keep track of which slaves are on which VMs on which hardware and then keep track of that in the repository.

Table:

HARDWARE (GUID, SystemName, MAC)

Slaves:

Slave 01 (VMName/SystemName, HARDWARE GUID)
Slave 02 (VMName/SystemName, HARDWARE GUID)

Then when Slave 02 starts Deadline would send the wake on lan to Slave02.HardwareGUID.MAC instead of Slave02.MAC.

Ok I have primitive Autoshutdown sort of working. Once Deadline stops the VM it should see that its slave VM isn’t running and shut itself down.

“C:\AutoShutdown.ps1”

start-sleep 120
while (1) {$vm = get-vm; if ($vm.state -ne "Running") {stop-computer} else {"Running..."; start-sleep 30}}
schtasks /CREATE /TN AutoShutdown /RU <DOMAIN\USER>  /RP <*******> /TR "Powershell \"C:\AutoShutdown.ps1\"" /SC ONSTART

The only problem I’m running into is that it’s not actually shutting down the computer. If I run the script from the shell it shuts down fine. But if I run it as a background process on /SC ONSTART it runs the script but the script apparently doesn’t shut down the machine. Any ideas?

EDIT: Needed to be stop-computer -force

Edwin is there a way to edit the Wake On Lan code in Deadline to wake a different MAC?

Yes indeedy!

The only thing we use ‘override mac address’ for in the Slave is Wake on LAN action, so if you modify the VM Slaves on a host to point at a specific VM host you should get it.

You can probably cook up something to automatically override the IP addresses via a Deadline Python script. I’ve got an example for IP address auto-assignment here you can modify:
github.com/ThinkboxSoftware/Dea … gureSlaves

Oh, override MAC. That’s the easy solution. Thanks!

VM Hosts starting up and shutting down now smoothy based on Deadline power management.

Sweet! If were weren’t using OpenStack here I would definitely try it. As it stands though everything is too elastic to safely power the hosts off. I think we currently have something like four farms running across 36 nodes?