[Nut-upsuser] early shutdown of VMware VMs

Arnaud Quette aquette.dev at gmail.com
Tue Feb 17 13:26:32 UTC 2009


I've appended a script excerpt I've once made to address the guest shutdown
from the host.
it was for ESX, and at that time, I was really surprised to not see anything
to address automagically an ordered shutdown (of the VMs)... hope this
helps.

Arnaud
-- 
Linux / Unix Expert R&D - Eaton - http://www.eaton.com/mgeops
Network UPS Tools (NUT) Project Leader - http://www.networkupstools.org/
Debian Developer - http://people.debian.org/~aquette/
Free Software Developer - http://arnaud.quette.free.fr/

2009/2/14 Doug Parsons <doug at parsonsemail.com>

> >Thanks, Doug. I'm newly on VMWare Server 2, which has different tools
> >than the 1.x ones I'm familiar with. AFAIK the 1.x tools did not have
> >any sort of UPS or shutdown awareness capability; I'll need to check
> >whether that's true with 2.x.
> >
> >dn
>
>
> Unfortunately Server is the only version that I don't have running anymore.
> But as Arjen noted most versions can handle the guest shutdown natively.
> One
> catch is that this extends the shutdown and startup times quite a bit and
> so
> the battery level at which you start the shutdown would need to be higher.
> Another catch I believe is that the guest must be running the VMWare tools.
> If VMWare Server can't do it (check under the advanced tab) then you may
> want to consider VMWare 3i as it can and is also free. Hit the VMWare
> forums
> as they should be able to fill in all the details.
>
> Doug
>
>

# Customisable Vmware ESX shutdown
stopVMWare()
{
  # Test if we have a Vmware ESX v3 setup
  if [ -x /usr/bin/vmware ]
  then
    ESXV3=`/usr/bin/vmware -v | grep "ESX Server 3"`
    if [ -n "$ESXV3" ]
    then
        # Get the VM list
      VMLIST=`/usr/bin/vmware-cmd -l`

        for VM in $VMLIST
        do
          # Get the VM state
              VMSTATE=`/usr/bin/vmware-cmd "$VM" getstate -q`

        # Guest OS shutdown if VMSTATE is equal to "on"
        if [ "$VMSTATE" == "on" ]
        then
          /usr/bin/vmware-cmd "$VM" stop trysoft

          # delay a bit the next sequence
          sleep 2
        fi
      done
      # Delay for 1 minute to give the VMs more time
      # to cleanly shutdown
      sleep 60
    fi
  fi
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.alioth.debian.org/pipermail/nut-upsuser/attachments/20090217/afa29f6a/attachment.htm 


More information about the Nut-upsuser mailing list