Tuesday, August 3, 2010

Easy ESXi 4.1 with serial or USB UPS control

In the past, there has always been a problem with setting up USB uninterruptible power supply to VMware ESXi servers. 

Here is the method of enabling a VMware ESXi 4.1 bare-metal server to communicate with an inexpensive serial or USB-only UPS system.

APC uninterruptible power supply

Install a Guest Windows System

You will need to install a Windows virtual machine to run the power management software, and connect to the UPS system.


I have used APC Powerchute software on a Windows 2008 server with this installation method, and encountered no problems.

Most Windows OS guests with USB management software should work in the same way.


Enabling the USB Pass-through  

Now that ESXi 4.1 has been released, it is possible to use a USB data cable on any UPS and communicate with Windows control software.  

ESXi 4.1 has the ability to make a USB connection from the server hardware, directly through to a virtual machine hosted on the same server.

USB cable

This allows UPS monitoring software to run on a windows virtual machine on the server and talk to the UPS on the ESXi server USB hardware.

You will need to make sure the USB adapter is attached to only the power controller guest OS, to minimise other guest OS conflicts. 

The management and attachment of the USB hardware is done in the virtual machine hardware configuration screen.

When adding USB hardware to the hardware of the virtual machine, a new option is now available for direct USB hardware access.


Enabling the SSH Service for Root Access

The next step is to enable the SSH service on the ESXi server, so a root remote console is present via SSH.

You will need physical access to the ESXi server, so you can login to its console as the root user.

Edit the configuration file for SSH with the following command:

nano /etc/ssh/sshd_config

Find the line that starts with PermitRootLogin and change the "no" to "yes".
 

Restart the sshd service with the command:

service sshd restart


The SSH service will now accept root logins to the console for running scripts. 



Windows Guest Script File  

On the Windows virtual machine running the Powerchute software, a small .bat file needs to be created, pointing to a free SSH client called Putty.

You can download Putty from their website. http://www.chiark.greenend.org.uk/~sgtatham/putty/ 

After getting Putty and setting up the .bat script, log into the same directory on the Windows guest. 

You will be able to point your UPS control software directly to the shut-down script on the local host.

Windows .bat file:
-------------------------------------------------
putty "server-address" -l root -pw "password" -m Unix_Commands
-------------------------------------------------


Unix_Commands file:
-------------------------------------------------
poweroff
exit
-------------------------------------------------


Final Notes

This new feature for USB connections in ESXi 4.1 makes it very easy to implement UPS systems into the VMware environment.

I have only tried this with Windows 2008, running APC Powerchute software and uninterruptible power supply with USB control.

But I believe any configuration of Windows and power control software should work.

APC UPS Battery

9 comments:

  1. Thanks so much for sharing! A couple of questions before I attempt to do the same thing:
    - Where does the file Unix_Comands reside? On the windows box, where it's being referenced by Putty?
    - How does one access the console on ESXi 4.1? When I press CTRL+ALT+F1, all I see is "Tech support mode has been disabled by the administrator"

    ReplyDelete
  2. Hi, are you sure you have /etc/ssh/sshd_config in ESXi version 4.1?

    ReplyDelete
  3. On second thought, isn't poweroff a hard shutdown that doesn't shutdown the guests properly? I think you would need to shutdown the VMs first and at the end of the script do "poweroff". My 2c

    ReplyDelete
  4. Ok last comment.. your post works perfectly, but you must configure the virtual machines to shutdown the guest OS, not Power off in the Startup/Shutdown configuration on the host server.

    ReplyDelete
  5. Benjamin, thanks for this, exactly what I am looking for. I have an issue though - my Windows 7 VM sees my pass'd thru UPS as a Microsoft HID and therefore Powerchute won't install. Ive tried deinstalling etc but can't get this to fire up with the APC driver. Any ideas?

    Jon

    ReplyDelete
  6. Hell ya! Thank you for this. I was beginning to worry that I would have to let my ESXi die with the UPS.

    I will try it out in a few hours.

    ReplyDelete
  7. Will the USB pass through be automatically reconnected to the VM after the host reboots?

    ReplyDelete
  8. Once put in, the lighting system will simply integrate with numerous alternative systems within the workplace. It will keep a track of all the lighting within the workplace and it conjointly keeps a track of assorted alternative devices like- TV sets, info show panels, speakers, projectors, printers, and computers within the workplace.

    UPS Control Software

    ReplyDelete

Thanks for commenting on the Burning the Midnight Blog. Your post will show up shortly after a quick look from one of our moderators.