VMware

This Question is Answered

12 Replies Last post: Nov 11, 2009 11:26 AM by DSTAVERT  

ESXi 4.0 APC UPS - using lamw and j.holland documents - VIMA issue posted: Nov 4, 2009 3:06 PM

Click to view cierech's profile Novice 9 posts since
Aug 20, 2009
Hi guys,

I have set up our UPS with our ESXi server according to document (revision 4)

http://viops.vmware.com/home/docs/DOC-1341/version/4

Note
that revision 4 of the document is not the one using lamw's scripts,
but using the ssh hack. Everything works beautifully when I invoke the
script ups_shutdown manually from the ESXi unsupported console:

#!/bin/bash
VMID=$(/usr/bin/vim-cmd vmsvc/getallvms | grep -v Vmid | awk '{print $1}')

for i in $VMID
do
  STATE=$(/usr/bin/vim-cmd vmsvc/power.getstate $i | tail -1 | awk '{print $2}')
 
  if [ $STATE == on ]
  then
  
    /usr/bin/vim-cmd vmsvc/power.shutdown $i

  fi

done

sleep 30

/sbin/shutdown.sh
/sbin/poweroff


First of all, right of the bat the first line of the script throws and error (-ash file not found error). So I had to remove that (any idea why??).

When I run this script from the ESXi console (unsupported), everything is fine, all the VMs shut down and at the end, so does the ESXi.
When I run this script from VIMA (ssh to the console, remote script execution), only the VIMA machine shuts down. If I modify the above script to not shut down VIMA, all the VMs (except for VIMA of course) shut down, and so does the ESXi...

VIMA is the first machine that gets shutdown - it has the lowest Vmid. It seems as though this causes the rest of the script to stop executing... How is this possible when in fact it is being executed on the ESXi server?

I'm pulling my hair out on this one (or what's left of them). Does anyone have any idea why this doesn't work...? lamw? :)

Thanks in advance guys,

Andrzej
Click to view lamw's profile Champion 2,803 posts since
Nov 27, 2007
The reason you need to remove /bin/bash because ESXi 4.0 unsupported Busybox console no longer has a symlink to bash from /bin/ash which is similar to bash environment, so it would error if you try to specify the path that does not exists.

Regarding the ordering of the output of vmsvc/getallvms, you can always do a grep -v on VIMA VM so it's not part of the list and have a separate conditional that'll shut that down at the very end.

=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/
vGhetto Script Repository
VMware Code Central - Scripts/Sample code for Developers and Administrators
VMware Developer Comuunity
Getting Started with the vMA (tips/tricks)
Getting Started with the vSphere SDK for Perl
Twitter: @lamw

http://engineering.ucsb.edu/~duonglt/vmware/vexpert_silver_icon.jpg

If you find this information useful, please award points for "correct" or "helpful".

Click to view DSTAVERT's profile Virtuoso 2,418 posts since
Nov 30, 2003
Use a launch script to run the ups_shutdown script. Bypass the VIMA appliance with the ups_shutdown script. Add the last two lines to a second script inside the launch script.
Click to view DSTAVERT's profile Virtuoso 2,418 posts since
Nov 30, 2003
The SSH session is killed.

The last two lines are removed from the first script. Try putting the two lines together separated with a semicolon

/sbin/shutdown.sh ; /sbin/poweroff
Click to view DSTAVERT's profile Virtuoso 2,418 posts since
Nov 30, 2003
Don't shutdown the VIMA appliance. Just let it be shutdown as the HOST goes down.
Click to view DSTAVERT's profile Virtuoso 2,418 posts since
Nov 30, 2003
Absolutely possible. You can change SSH server ports
/etc/ssh/sshd_config

port 22 is usually commented out just un-comment the line and change ports. Restart the SSH server and add that port number to the firewall script and restart the firewall.

Where is everything running?
Click to view DSTAVERT's profile Virtuoso 2,418 posts since
Nov 30, 2003
Remember that ESXi uses UTC time.

VMware Developer

SDKs, APIs, Videos, Learn and much more in the Developer community.

Learn More

Developer Sample Code

Increase your developer productivity with VMware API sample code.

Learn More

VMworld Sessions & Labs

Online access to the latest VMworld Sessions & Labs and online services.

Learn more

Purchase PSO Credits Online

Purchase credits to redeem training and consulting services online.

Buy Now

Community Hardware Software

View reported configurations or report your own.

Learn More

VMware vSphere

Come witness the next giant leap in virtualization.

Register Today

Communities