WMware ESXI – suspend all guests
I have an VMware ESXI 5 which I used for testing things, but I don’t want it to run all the time, and using the vSphere Client to stop all the VM’s and then stop the ESXI server is a bit too much effort.
So I figured out how to do it from the commandline using ‘vim-cmd’.
#/bin/sh
VMS=`vim-cmd vmsvc/getallvms | grep -v Vmid | awk '{print $1}'`
for VM in $VMS ; do
PWR=`vim-cmd vmsvc/power.getstate $VM | grep -v "Retrieved runtime info"`
if [ "$PWR" == "Powered on" ] ; then
name=`vim-cmd vmsvc/get.config $VM | grep -i "name =" | awk '{print $3}' | head -1 | cut -d "\"" -f2`
echo "Powered on: $name"
echo "Suspending: $name"
vim-cmd vmsvc/power.suspend $VM > /dev/null &
fi
done
while true ; do
RUNNING=0
for VM in $VMS ; do
PWR=`vim-cmd vmsvc/power.getstate $VM | grep -v "Retrieved runtime info"`
if [ "$PWR" == "Powered on" ] ; then
echo "Waiting..."
RUNNING=1
fi
done
if [ $RUNNING -eq 0 ] ; then
echo "Gone..."
break
fi
sleep 1
done
echo "Now we suspend the Host..."
vim-cmd hostsvc/standby_mode_enter
This is working just fine, until one discovers the there is no where to store files on the ESXI servers file system without having to restore them after a reboot.
A bit of googing gave me an answer, create a directory in one of the datastores and save it there.
Like in ‘/vmfs/volumes/datastore1/scripts/’, where vanish from after a reboot.
Now to wake the host again, requires that one enable wake-on-lan (wake on PCI and PCIe normally should do it), and then use the wakelan / wol utility;
# wol <mac addr>
This it’s possible to hide ones noisy computers somewhere far far away.
recent books
- Simon R. Green
- A Hard Day's Knight
- Jack Campbell
- The Lost Fleet: Beyond the Frontier: Dreadnaught
- Hannu Rajaniemi
- The Quantum Thief
- Gary Gibson
- Nova War
- Adrian Tchaikovsky
- Heirs of the Blade
- Brian Herbert,Kevin J. Anderson
- Sisterhood of Dune
- Michael Cobley
- The Ascendant Stars
- Michael Cobley
- The Orphaned Worlds
- Markus Heitz
- The Revenge Of The Dwarves
- Christopher Paolini
- Inheritance
charities
recent comments
- VMware ESXi 5 – VNC to a guest | Casper's Life on VMware ESXi 5 – ssh key authentication
- Balkan 2011 – Part 6 | Casper's Life on Balkan 2011 – Part 5
- Balkan 2011 – Part 5 | Casper's Life on Balkan 2011 – Part 2
- Balkan 2011 – Part 4 | Casper's Life on Balkan 2011 – Part 2
- Balkan 2011 – Part 3 | Casper's Life on Balkan 2011 – Part 1
categories
- apple (62)
- books (5)
- chat (1)
- computers (32)
- driving (11)
- gps (7)
- graphics (1)
- hardware (18)
- howto (7)
- idm (6)
- internet (5)
- iphone (8)
- kvm (1)
- life in it's simplest form… (29)
- linux (11)
- motorbikes (20)
- music (3)
- networking (1)
- opinion (11)
- os (5)
- osx (26)
- photography (13)
- politics (8)
- programming (3)
- rant (18)
- rhel6 (1)
- science fiction (1)
- software (44)
- technology (7)
- trash (2)
- travel (20)
- tv (3)
- uncategorized (3)
- video (1)
- vmware (3)
- widget (1)
- wireless (1)
- wordpress (1)
- xen (1)







