Ask a questionAsk a question
 

AnswerHyper-V core and UPS

  • Monday, January 12, 2009 7:56 AMDrWhoIs007 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    hi,
    how can i manage the UPS i have on my Hyper-V server?
    when it runs out of power it should also power down the Hyper-V server and its hosted VM's...
    or does the management of the UPS has to be run on another machine and then what?

    tia,
    marc

Answers

  • Tuesday, November 03, 2009 3:20 AMRWDoyle Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     AnswerHas Code
    Mark,

    I don't take credit for creating this solution, but I can tell you I've tested it and now use it on my Hyper-V Server.  It works quite well.  I got this solution from the following thread:
    http://social.technet.microsoft.com/Forums/en/winservergen/thread/10fd4f4a-eba5-4577-8f81-28c1558eb2e7

    I put the following VBScript into local policy as a "machine startup" script on my Hyper-V Server.  The shutdown is graceful.  That is, the hypervisor gets its opportunity to save the states of the VMs prior to powering off.

    set wmi = GetObject("winmgmts:{impersonationLevel=impersonate,(Shutdown)}!\\.\root\cimv2")
    set batteryColl = wmi.ExecQuery("select * from Win32_Battery")
    set osColl = wmi.ExecQuery("select * from Win32_OperatingSystem")
    
    while true
     for each battery in batteryColl
      battery.Refresh_
      if battery.batteryStatus = 1 and battery.EstimatedChargeRemaining <= 25 then
       for each os in osColl
        os.Win32Shutdown 5
       next
      end if
     next
     wscript.Sleep 15000
    wend
    
    Ryan
    • Marked As Answer byDrWhoIs007 Tuesday, November 03, 2009 2:06 PM
    •  
  • Monday, January 12, 2009 8:27 AMSander BerkouwerMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Microsoft Windows Server 2008  and Microsoft Hyper-V Server do not offer a built-in tool to manage an Uninterruptible Power Supply (UPS) it is connected to, compared to Windows Server 2003.
      
    To manage an UPS, install the software for the UPS.
    You should ask the vendor or manufacturer of the UPS:
         
    • Whether the company supports Server Core installations of Windows Server 2008;
    • How the UPS is to be managed on a Server Core installation, when it's not manageable from the commandline.

     

  • Wednesday, January 14, 2009 7:06 AMVincent HuMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi,

     

    As far as I know, SCVMM does not have the UPS management feature.

     

    If you have any further SCVMM related questions, you may post to the following System Center Virtual Machine Manger forum:

     

    System Center Virtual Machine Manager

    http://social.technet.microsoft.com/Forums/en-US/category/virtualmachinemanager/

     

     

    Best Regards,

    Vincent Hu

  • Thursday, January 15, 2009 9:04 AMSander BerkouwerMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Uninterruptible Power Supplies (UPSs) can be configured using network connections, USB connections and some solder models through serial connections. When the server running System Center Virtual Machine Manager (SCVMM) is running virtually you can connect to, and manage network connected UPSs. When it's a physical box you can connect to and manage network, USB- and serial connected UPS's (as long as the box offers the right physical connectors and right amount of them) 

    Since HP Uninterruptible Power Supplies (UPSs) are rebranded APC units, you can use the HP or APC software to remotely shutdown the virtual host. When you shutdown a single host running Hyper-V it will pause all guests and shutdown. The APC PowerChute software is especially powerful when you're running a geographically dispersed failover cluster ('geocluster') of Hyper-V servers: You can create Powershell scripts in System Center Virtual Machine Manager (SCVMM) to migrate the virtual guests to the other location (where there's no power outage?) and shut down the guest remotely with the script, triggered by the APC Powerchute software.

    When looking at the PCBE8 compat chart.pdf I noticed APC Powerchute Business Edition software is available for Server Core installations of Windows Server 2008. (both x86 and x64).

    Note:
    When using network connected UPSs, also connect your network components to the UPS. When using a geocluster to perform migrations, make sure every component used in these scenarios are UPS protected. Contact your ISP for information on the protection of components between your locations.

    • Marked As Answer byDrWhoIs007 Thursday, January 15, 2009 9:08 AM
    •  

All Replies

  • Monday, January 12, 2009 8:27 AMSander BerkouwerMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Microsoft Windows Server 2008  and Microsoft Hyper-V Server do not offer a built-in tool to manage an Uninterruptible Power Supply (UPS) it is connected to, compared to Windows Server 2003.
      
    To manage an UPS, install the software for the UPS.
    You should ask the vendor or manufacturer of the UPS:
         
    • Whether the company supports Server Core installations of Windows Server 2008;
    • How the UPS is to be managed on a Server Core installation, when it's not manageable from the commandline.

     

  • Monday, January 12, 2009 8:31 AMDrWhoIs007 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    hi,
    could this be handled by the machine which is running SC-VMM08?
    thx
    marc
  • Wednesday, January 14, 2009 7:06 AMVincent HuMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi,

     

    As far as I know, SCVMM does not have the UPS management feature.

     

    If you have any further SCVMM related questions, you may post to the following System Center Virtual Machine Manger forum:

     

    System Center Virtual Machine Manager

    http://social.technet.microsoft.com/Forums/en-US/category/virtualmachinemanager/

     

     

    Best Regards,

    Vincent Hu

  • Wednesday, January 14, 2009 7:36 AMDrWhoIs007 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    hi vincent,
    i find this very odd...
    i should have expected that support for ups systems is included in a hypervisor.
    after all, how do you stop your VM's gracefully if one can't detect that power will be switched off....
    cu marc
  • Thursday, January 15, 2009 5:33 AMVincent HuMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi, DrWhoIs007


    I am not very familiar with UPS. But based on my research, you can administrater the UPS on every computer, not the specific one.

    You may contact the UPS vendor to get more information.

    I am sorry that I don't have a UPS here. 


    Best Regards,

    Vincent Hu

  • Thursday, January 15, 2009 7:44 AMDrWhoIs007 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    hi vincent,
    indeed one can administer an ups on every 'normal' OS
    but that doesn't shutdown the hyper-v itself, keep in mind that i'm talking about the bare metal version here, so no gui to run HP programs in...
    the vendor, HP in this case doesn't mention anywhere if this is possible, a shutdown of the hyper-v (which in his turn shuts down every single VM running on this host), it is a classic case of playing ball...
    and i don't seem to get in touch with someone within HP who can help me further with this...
    so the only option i see is that sc-vmm has some tools to detect this and then shuts down the host connected to the ups in question...
    cu
    marc
  • Thursday, January 15, 2009 8:48 AMVincent HuMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi, DrWhoIs007

    According to your description, you want to let the UPS tools to shutdown the VMs and the Hyper-V host automatically if there is a power failure, right?


    In Server Core, I don't think this can be achieve. 
     

    If I misunderstand you concern, please feel free to let me know.

     

     

    Best Regards,

    Vincent Hu

  • Thursday, January 15, 2009 8:55 AMDrWhoIs007 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    hi Vincent,
    yes that's the idea...
    Hyper-V (if the properties of the VM are set right) will shutdown its hosted VM's when the Hyper-V itself is shut down.
    but this shut down should be triggered by the Ups when it is running out of juice...
    i don't mind if the hyper-v itself can't do it but it should defenately be possible to do it with Sc-VMM ...
    i can't imagine that datacenters can't shutdown their hyper-v hosts in case of power failure...
    cu
    marc
  • Thursday, January 15, 2009 9:04 AMSander BerkouwerMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Uninterruptible Power Supplies (UPSs) can be configured using network connections, USB connections and some solder models through serial connections. When the server running System Center Virtual Machine Manager (SCVMM) is running virtually you can connect to, and manage network connected UPSs. When it's a physical box you can connect to and manage network, USB- and serial connected UPS's (as long as the box offers the right physical connectors and right amount of them) 

    Since HP Uninterruptible Power Supplies (UPSs) are rebranded APC units, you can use the HP or APC software to remotely shutdown the virtual host. When you shutdown a single host running Hyper-V it will pause all guests and shutdown. The APC PowerChute software is especially powerful when you're running a geographically dispersed failover cluster ('geocluster') of Hyper-V servers: You can create Powershell scripts in System Center Virtual Machine Manager (SCVMM) to migrate the virtual guests to the other location (where there's no power outage?) and shut down the guest remotely with the script, triggered by the APC Powerchute software.

    When looking at the PCBE8 compat chart.pdf I noticed APC Powerchute Business Edition software is available for Server Core installations of Windows Server 2008. (both x86 and x64).

    Note:
    When using network connected UPSs, also connect your network components to the UPS. When using a geocluster to perform migrations, make sure every component used in these scenarios are UPS protected. Contact your ISP for information on the protection of components between your locations.

    • Marked As Answer byDrWhoIs007 Thursday, January 15, 2009 9:08 AM
    •  
  • Thursday, January 15, 2009 9:08 AMDrWhoIs007 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi Sander,
    duh didn't realize that HP bought in by APC
    so probably the APC soft will recognise the ups
    i'll try that, thanks
    this is the best shot so far
    thx
    marc
  • Friday, March 20, 2009 3:22 PMBob Hawkey Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    UPS stuff is probably the most frustrating thing I've run across... EVER! We just installed HyperV server and have 4 or 5 VMs running. I can shut down the host manually and all the snapshots are taken and when it starts up again the VMs just start where they left off. How very, very, very sweet is that?!

    Now, if I want to hook up my APC UPS and have it signal the host that the power is off, apparently I can't do that?  All I want is software to monitor the com port, detect the code for 'power is down' and then start a countdown to power off the host. If the com port reports 'power is back' I want another loop that gives it 30 seconds before cancelling the power down. If the UPS goes back to 'power is down' then continue the countdown to power off.

    I could write all this stuff in VB in 30 minutes and I'm beginning to think that's exactly what I will have to do.

    Whatever happened to simple?
  • Saturday, March 21, 2009 9:35 AMSander BerkouwerMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Bob Hawkey said:

    Now, if I want to hook up my APC UPS and have it signal the host that the power is off, apparently I can't do that?
      

    Apparently you misread the information above.
    You can't achive this with Built-in tools, since Microsoft removed the UPS Management feature from Windows Server 2008. You can install the software that came with your APC UPS on Server Core without problems and manage your UPS using that piece of software. You can download the PowerChute software from the APC website as well.

    Bob Hawkey said:

    All I want is software to monitor the com port, detect the code for 'power is down' and then start a countdown to power off the host. If the com port reports 'power is back' I want another loop that gives it 30 seconds before cancelling the power down. If the UPS goes back to 'power is down' then continue the countdown to power off.
      

    The APC sPowerchute oftware that came with your UPS can do that.

  • Tuesday, May 05, 2009 8:45 PMMarek Zamarski Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi Bob,
    have you solved the problem with shutting down of Hyper-V Server 2008 by signal from APC UPS?

    Please let me know the software you have used. I´m unsuccessful witn PowerChute Business :(

    BR, Marek
  • Thursday, May 07, 2009 5:47 PMMatevz GacnikMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I suppose Hyper-V will be shutdown during normal system shutdown on our setup. We have an APC UPS connected to IBM BladeServer chasis full of blades. Everything is ok when using nonclustered Hyper-V setups, ie. single nodes.

    The problem I see is the following: how can we shutdown an active-active Hyper-V cluster with a couple of HA VMs on each node. When system shutdown is initiated, Hyper-V saves the VMs. Since VMs are in HA, Cluster service immediatly turns them on and then the system is shutdown, resulting in turned off machines and migration nightmare.

    This all becomes even more unmanagable when we need to shutdown all cluster nodes due to power failure being imminent. Any guidelines on this scenario?

    Is there a way to script a 'special shutdown', meaning save state and shutdown the node, in a clustered environment?
  • Thursday, May 07, 2009 5:52 PMBob Hawkey Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Regrettably, no, the APC software does not support Server 2008. Insane, I know.
  • Thursday, May 07, 2009 5:56 PMBob Hawkey Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Well, I don't really know if I found a solution or not. In the Power settings somewhere it actually sort of seems to behave like a laptop. It shows 'battery power' or something. I have the UPS plugged in but I really haven't had the guts to unplug it to see it the 'battery' level starts to drop. ANyway - there are settings like you'd have on a laptop that will supposedly shut the server down at a certain threshold.

    This may be complete idiocy on my part but why on earth would a big rackmount server have such settings? Very goofy if it isn't what I think it is!
  • Wednesday, August 19, 2009 10:10 PMEnobllams Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Bob - it's not idiocy - I investigated this and everything seemed so promising, but there's a problem (which I'll get to)! 

    I'm running W2k8 Standard x64 full server, which runs Hyper-V and several VMs.  By correct use of Integration Services the VMs gracefully shut down or snapshot when the host OS shuts down.  I recently added a small APC 350 and then became very frustrated with what seems to be lack of support for a pretty basic need - that the host OS shuts down gracefully when the battery runs flat!  Otherwise, why did I buy the thing?

    I noticed that connecting the UPS comm USB cable turns the server into a laptop!  No software, no config - just plug the USB cable and watch the laptop power management icon appear in the systray.  The battery indicator correctly displays the UPS battery charge - just like a laptop.  removing the mains supply obviously switches everything over to battery power and the systray icon correctly reflects this, showing the battery life remaining.

    You can create a new laptop type power plan - with different settings for battery and mains use.  You can set warning and critical battery levels (I chose 50% and 25% respectively in the test), and you can set warning and critical actions - pop-up for warning level - shutdown for critical.  Everything works like a dream.

    The big failure - when the power plan reaches the point of shut down, it should gracefully shut down the host OS, which should wait for the guest VMs to shut down first (as it does if you shut the host manually).  Sadly, what actually happens is not shut down, but 'turn off'.  The host and VMs just die like you pulled the plug.

    This could be really great - just a small spanner in the works and I assume, not by design?  Just give the power plan a graceful shutdown option, and everyone here will be happy I suspect!



  • Sunday, October 04, 2009 7:13 PMdigitalmarx Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Proposed Answer
    I've arrived at the same stalemate, running Hyper-V R2 (core) on an HP ML150 G6 box, currently with SBS2008 on one VM. An APC BX1300G UPS provides about 30 minutes runtime and is connected via USB to my host server. PNP worked flawlessly, detecting the UPS, treating it as a battery.  There's no GUI, but powercfg handily provides access to the same power plan parameters mentioned above. 

     

    Powercfg -setdcvalueindex scheme_balanced sub_battery batlevelcrit  28 (40%)
    Powercfg -setdcvalueindex scheme_balanced sub_battery batactioncrit 3 (shutdown)

    And from powershell, it's possible to monitor UPS state and battery levels...
    PS$ get-wmiobject -class CIM_Battery -namespace "root\CIMV2"


    So when the UPS reaches the critical-battery watermark, the host OS (hyper-V) initiates what seems like a forced shutdown, ("The kernel power manager has initiated a shutdown transition.") and the host powers down within 4-5 seconds. The hypervisor isn't signaled or has time to save VM states, so they're effectively just turned off. Not good.

    Question, is there a way to modifiy the kernel power manager policy to initiate a normal, graceful shutdown instead? 
    Any other ideas?

    I've looked at APC Powerchute Business Edition and don't see my APC model in the support matrix. Not obvious that it would support Hyper-V either.

    Thanks, Mark
    • Proposed As Answer byBrian Borg Sunday, October 04, 2009 10:08 PM
    •  
  • Tuesday, November 03, 2009 3:20 AMRWDoyle Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     AnswerHas Code
    Mark,

    I don't take credit for creating this solution, but I can tell you I've tested it and now use it on my Hyper-V Server.  It works quite well.  I got this solution from the following thread:
    http://social.technet.microsoft.com/Forums/en/winservergen/thread/10fd4f4a-eba5-4577-8f81-28c1558eb2e7

    I put the following VBScript into local policy as a "machine startup" script on my Hyper-V Server.  The shutdown is graceful.  That is, the hypervisor gets its opportunity to save the states of the VMs prior to powering off.

    set wmi = GetObject("winmgmts:{impersonationLevel=impersonate,(Shutdown)}!\\.\root\cimv2")
    set batteryColl = wmi.ExecQuery("select * from Win32_Battery")
    set osColl = wmi.ExecQuery("select * from Win32_OperatingSystem")
    
    while true
     for each battery in batteryColl
      battery.Refresh_
      if battery.batteryStatus = 1 and battery.EstimatedChargeRemaining <= 25 then
       for each os in osColl
        os.Win32Shutdown 5
       next
      end if
     next
     wscript.Sleep 15000
    wend
    
    Ryan
    • Marked As Answer byDrWhoIs007 Tuesday, November 03, 2009 2:06 PM
    •  
  • Tuesday, November 03, 2009 2:06 PMDrWhoIs007 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    @rwdoyle,
    thx!!!

    gonna try that
  • Monday, November 23, 2009 12:25 AMdigitalmarx Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Excellent! Will give it a shot. Thanks Ryan.