Dell UPS & vSphere 5

Installed  a new vSphere 5 environment at a customer.
The customer had a Dell UPS and wanted to be able to shutdown everything after running 30 mins on battery.

I recon VMware should start to built some API’s for hardware suppliers to integrate this more easily.
Although the Dell Multi UPS management software has a plugin for VMware it only allows you to shutdown the hosts, or bring them into maintenace mode.
I haven’t found a way to shut down the virtual machines at the same time witht the plugin.

So I made a workaround.

Dell UPS Management software – vSphere 5

  1. Obtain the Dell Multi UPS Management Console (MUMC) software from http://www.dellups.com/soft-tech-doc.asp
  2. The file is called DELL_MULTI-DEVICE_A00_R318771.exe
  3. I’ve installed the software on the vCenter server since it’s a dedicated physical server.
  4. Once installed, you can access it trough:
    http://127.0.0.1:4679/default.html
    or through the start menu by clicking on the dell mgmt software icon.
  5. The default login is admin/admin
  6. A quick scan is automatically performed

  1. In my case, 2 ups devices have been discovered as well as the management server.
  2. Then go to System
  3. Enable the shutdown module:
  4. Next, we will configure the shutdown module

              

Powersource = the UPS powering the management server
The rest speaks for itself.

I’ve created a shutdownvms.bat script that will bring down everything. (read below)

  1. Shutdownvms.bat
    This is the content of the batchfile, I’ve copied everything in the c:\scripts folder (including powershell.exe en vim.psc1)
    It is important to change the Powershell Executionpolicy otherwise the script won’t run
    Do this once by running “Set-Executionpolicy Bypass”  in a powershell prompt

#———————————————-
# short log file creation
echo Shutdown of all VM’s and ESX hosts is launched at >> c:\scripts\alert.txt
echo %date% %time% >> c:\scripts\alert.txt
#Call the powershell script to shutdown everything
C:\scripts\powershell.exe -PSConsoleFile “C:\scripts\vim.psc1” “& “C:\Scripts\shutdownallvms.ps1” |Out-File C:\scripts\log.txt
# shutdown the server itself
shutdown.exe /s /t 10
exit
#—————————————————-

  1. Shutdownallvms.ps1

Connect-VIServer IPADDRESS

# Get All the ESX Hosts

$ESXSRV = Get-VMHost

# For each of the VMs on the ESX hosts

Foreach ($VM in ($ESXSRV | Get-VM)){

# Shutdown the guest cleanly

$VM | Shutdown-VMGuest -Confirm:$false

}

# Set the amount of time to wait before assuming the remaining powered on guests are stuck

$waittime = 200 #Seconds

$Time = (Get-Date).TimeofDay

do {

# Wait for the VMs to be Shutdown cleanly

sleep 1.0

$timeleft = $waittime – ($Newtime.seconds)

$numvms = ($ESXSRV | Get-VM | Where { $_.PowerState -eq “poweredOn” }).Count

Write “Waiting for shutdown of $numvms VMs or until $timeleft seconds”

$Newtime = (Get-Date).TimeofDay – $Time

} until ((@($ESXSRV | Get-VM | Where { $_.PowerState -eq “poweredOn” }).Count) -eq 0 -or ($Newtime).Seconds -ge $waittime)

# Shutdown the ESX Hosts

$ESXSRV | Foreach {Get-View $_.ID} | Foreach {$_.ShutdownHost_Task($TRUE)}

Write-Host “Shutdown Complete”

I did not wrote this script myself, I got it from the communities forum @ vmware, but I can’t recall from who.

You can do a test from the management menu, but be warned,it WILL shutdown everything.

Hope this helps you out

Patrick

Advertisements
  1. It was good article. The only issue I am facing is when i run C:\scripts\shutdownvms.bat manually it works but when I run it through UPS system it doesnt. Any idea what script path we need to provide?

      • Mobileboy36
      • November 13th, 2012

      I ran into exacly the same issue as explorelinux is complaining about.
      The MUMC node (a web interface) is asking for a path. My batchfile is running as expected manually, but not from the shutdown node in MUMC. Any ideas?

      • I’ve the exact same problem. When I run the script manually it works. But when I try to run it from MUMC it doesnt work. Somebody any idea?

  2. If I run C:\scripts\shutdownvms.bat manually it runs but not when I run it through UPS system shutdown script.Any idea?

    • patrickvanbeek
    • March 26th, 2012

    it shoud reside on the same server as the ups software.
    In my case, it’s on the vcenter server.
    I just put the absolute path as you can see in my screenshot.
    Did you change the execution policy for the powershell?

    • Marek
    • March 26th, 2012

    The better way is turning on Virtualization module.. next you have to is adding vcenter server IP and ESXi hosts managed by vcenter will be added automatically..
    Next step is set shutdown timer for each host in “Nodes Settings”.
    The last thing you have to do is setting automatic shutdown for each OS Guest on each host (Configuration, Virtual machine startup / shutdown”). It really works !! 🙂

      • yggdrasil42
      • April 24th, 2012

      Marek, in my test the ESXi hosts were simply powered off by MUMC. There was no graceful shutdown, even though I have enabled automatic shutdown of each VM in the ESXi settings. The connection between MUMC and vCenter appears to be correct. How did you manage to get this working?

      • Install Vmware-tools on all the VMs. That should work.

        • yggdrasil42
        • April 24th, 2012

        linuxfreaker :
        Install Vmware-tools on all the VMs. That should work.

        VMware-tools are installed on each VM. That’s not the issue. After all, if I shut down a ESXi host manually, the VM’s shut down nicely. With MUMC it appears to just power off the host, without any graceful shutdown of either the hypervisor or the VM’s. Just… low-battery signal -> click.

    • aurelien
    • March 27th, 2012

    it’s a great article.

    For me it is not needed to have this kind of scripts.

    – The configuration that you do in the shutdown panel is for the protection of the physical machine itself.

    – In the virtualization panel you can add connection/link to the vCenter that would retrieve the hypervisors list.

    – Once the protection of the hypervisor (ESXi) is done, you need to configured the virtual machines shutdown settings.
    => http://pubs.vmware.com/vsphere-50/topic/com.vmware.vsphere.vm_admin.doc_50/GUID-6CA3CCF8-71A7-4167-AA5D-86BB67CF060D.html

      • yggdrasil42
      • May 10th, 2012

      Aurelien, did you actually test your method? I would really appreciate some help because I was unable to get the graceful shutdown working.

      I’ve configured the connection to vCenter and the hypervisors are correctly listed. In ESXi I’ve configured the virtual machine shutdown settings. However during a test, when the battery ran low the ESXi hosts were just powered off without giving the VM’s time to shutdown. As far as I could tell, not even the hypervisor software was shut down, but it happened too fast to be sure.

      My Dell rep is unsure if graceful shutdown is even supported so I guess I’m on my own. Any advice is welcome.

        • aurelien
        • May 10th, 2012

        Hi yggdrasil42,
        Once you have the ESXi listed in the node list, it should work after a small configuration on this node.

        Have you configured the right powersource in the node configuration panel and enable the “Remote Shutdown”?

    • patrickvanbeek
    • March 27th, 2012

    Marek & Aurelien, I’ve come across that aswell.
    There is a big however!

    From my experience, setting automatic startup & shutdown policies works for VM’s residing on the host.
    What happens if you vmotion those machines to another host?
    As far as I know, these settings are host based.

    In fact, these settings don’t seem to work if the host is part of a High Availability (HA) Cluster.

    In that case, your suggestion does not work, unless I’m doing something completely wrong.

    • aurelien
    • March 29th, 2012

    Patrick,
    You are right, with the vMotion you lost the Startup order, but if the shutdown of the virtual machine is enable on each Hypervisor it’s ok. (No shutdown order)

    I agree with the HA that it disable this functionnality.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: