Vanit Posted October 26, 2010 Posted October 26, 2010 Hi All, I installed UPS monitoring application on one guest vm and now I want to shutdown all virtual machines and then host when power goes off or any specific event occurs. I installed VMware ESXi 4.0 server as host and different guest VM(Linux,Windows,Unix) on host.Now I want to shutdown all virtual machines which are running on server and then ESXi host. So how can I do it. Thanks in advance.
somabc Posted October 26, 2010 Posted October 26, 2010 (edited) You can probably use vSphere Command-Line Interface and VMware APIs and SDKs Documentation to script this. Not tried it myself though so sorry I can't be of further help. Edited October 26, 2010 by somabc
jamesb Posted October 26, 2010 Posted October 26, 2010 PowerCLI: Shutdown your Virtual Infrastructure | Virtu-Al might have the answer you're looking for.
Vanit Posted October 26, 2010 Author Posted October 26, 2010 I am newbie in VMware and we need not to use vSphere Command-Line Interface or vMA. Is there any way that I can fire it from ESXi server?
jamesb Posted October 26, 2010 Posted October 26, 2010 I am newbie in VMware and we need not to use vSphere Command-Line Interface or vMA. Is there any way that I can fire it from ESXi server? I wouldn't have thought so, no. At least not any supported way I can think of since the Tech Support console isn't meant to be used. Can I ask why you're not meant to use the management tools which VMWare recommend?
Vanit Posted October 26, 2010 Author Posted October 26, 2010 Thanks for reply. I have developed it with vMA and able to shutdown as required but now I want to do the same with other option.So please provide me other options which can perform the same task. I will appreciate if you can provide me the script also.
jamesb Posted October 26, 2010 Posted October 26, 2010 You could use PowerShell, or just about anything else, to directly access the vCenter API if you're using vCenter I suppose.
somabc Posted October 26, 2010 Posted October 26, 2010 You could turn on the tech support console, turn on SSH, use a script to SSH in and issue a shutdown command? VMware KB: ESX 4.0 and ESXi 4.0 shutdown and reboot commands
Vanit Posted October 27, 2010 Author Posted October 27, 2010 OK.. Now If I want to monitor the UPS via ESXi server and when power goes off or any event occers then it should do the following things- i) shutdown all vm running on ESXi server. ii) shutdown ESXi host also. How can I achieve it.
jamesb Posted October 27, 2010 Posted October 27, 2010 OK.. Now If I want to monitor the UPS via ESXi server and when power goes off or any event occers then it should do the following things- i) shutdown all vm running on ESXi server. ii) shutdown ESXi host also. How can I achieve it. You can't - you need a separate box (or VM) monitoring the UPS and ready to send the commands to ESXi. Remember, ESXi doesn't have a kernel, or even an OS, other than a very, very limited tech support console with a scattering of commands which isn't intended to be used to manage the server.
Vanit Posted October 27, 2010 Author Posted October 27, 2010 (edited) I installed vmware vSphare CLI on guest VM(Windows7) and when I am trying to run-- vicfg-hostops.pl -a poweroff -o shutdown -d Name of your ESXi server -f getting the following error-- 'vicfg-hostops.pl' is not recognized as is not recognized as an internal or external command,operable program or batch file. Edited October 27, 2010 by Vanit
somabc Posted October 27, 2010 Posted October 27, 2010 You need to install PERL and make sure perl.exe is in your path and associated with .pl ActivePerl is Perl for Windows, Mac, Linux, AIX, HP-UX & Solaris | ActiveState
Vanit Posted October 28, 2010 Author Posted October 28, 2010 (edited) vSphere CLI installer installs both the vSphere CLI and vSphere SDK for Perl. So I dont think to install active perl externally. When I am typing the following command- C:\Program Files\VMware\VMware vSphere CLI\Perl\apps>perl -v This is perl, v5.8.8 built for MSWin32-x86-multi-thread (with 50 registered patches, see perl -V for more detail) Copyright 1987-2006, Larry Wall and when I am trying to execute other commands like- C:\Program Files\VMware\VMware vSphere CLI\bin>esxcfg-nas.pl --server ESXi server address here --list it is working fine and I am also able to see this file in bin directory but I didn't found vicfg-hostops.pl file anywhere in the directory. Please let me know what is going wrong here and how to resolve it. Edited October 28, 2010 by Vanit
jamesb Posted October 28, 2010 Posted October 28, 2010 Might be worth reinstalling, or just doing a search to try and make sure the perl script is in the right path.
Vanit Posted October 28, 2010 Author Posted October 28, 2010 (edited) Thanks a lot for support....As per your suggestion, I reinstall it and now I am able to execute most of the scripts. but this is useful for shutting down ESXi server from guest VM which is not my requirement. My requirement is to shutdown all guest from ESXi server and then server itself.so how can I make it? Edited October 29, 2010 by Vanit
pccbryan Posted May 3, 2011 Posted May 3, 2011 Vanit, I have used this to first shutdown my vm guests, then ESXi hosts. You must have the -f or --force to enable shutdown of a host not in maintenance mode. vicfg-hostops.pl -o shutdown -f -a poweroff --server --username --password I know this is an older post but this may help others in the future. I also have one unanswered piece of this puzzle that someone maybe can help with. Does the "-a poweroff" gracefully shutdown the vm guests or does it "cut the power" to the vm guests? -if anyone can answer that it would be an added bonus. Thanks!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now