Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1490
  • Last Modified:

vSphere 4.1 guest vm shutdown script

I have a stand-alone ESX host running vSphere 4.1, without Virtual Center. The hosts have APC Powerchute configured to shutdown if the UPS runs low. One of the guests is on a subnet that cannot talk to the APC Network Management Card, so I cannot use PCNS. I need a script that will gracefully shut down one guest before the host shuts down. I have not done any scripting with vmware. Please indicate how to create the script and where it should be located. Should I have the APC network management card activate the script, or will the host automatically do it prior to shutting itself down?

Thanks in advance for your help.
0
fisher_king
Asked:
fisher_king
2 Solutions
 
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
Why don't you use the Auto Shutdown Guests before Host Shutdown?

So when the ESX server gets the request to shutdown, it will delay and shutdown the Guests, before it turns off.

http://www.vmadmin.co.uk/vmware/35-esxserver/111-esxautostartstop


Otherwise scripts Have a look here

http://blog.peacon.co.uk/wiki/Esxi-control.pl

this perl script could be used

http://www.virtu-al.net/2010/01/06/powercli-shutdown-your-virtual-infrastructure/

You will need a few additionals

I would recommend using the following, also VMware recommends the use of PowerCLI, which is PowerShell interface with vSphere-specific additions.

http://communities.vmware.com/community/vmtn/server/vsphere/automationtools/powercli

One of the simplest PowerCLI examples, and something which is actually extremely useful on its own, is the Get-VM cmdlet. Which lists VMs.

PowerCLI can be a bit overwhelming to use,  But it can be enhanced with a nice toolset and a library of preconfigured scripts to jump-start your mass changes, which is possible with PowerGUI

http://powergui.org/index.jspa
0
 
coolsport00Commented:
I believe the Auto shutdown feature in ESX should do what you need without the need for a script, as suggested by "hanccocka". Just log into vCenter, click on the host, then click the Configuration tab. In the 'Software' box, click the Virtual Machine Startup/Shutdown link. In the upper right click Properties. Follow the remaining steps from "hanccocka's" 1st link above.

If you do want a script, LucD (1 of *the* premier PowerCLI gurus; literally co-wrote the book on PowerCLI :) ) provides a script in the following link:
http://communities.vmware.com/thread/271097?tstart=780

He gives you a script for a VM, or all VMs in a cluster.

Regards,
~coolsport00
0
 
Danny McDanielClinical Systems AnalystCommented:
Do you have the software(scripts) from APC that installs into the vma?

The vma is a vm appliance that runs on your host and would get the signal from the ups, then it would communicate with the host/VC to shutdown the guests.

I will post the link to the s/w if you can't find it.
0
 
fisher_kingAuthor Commented:
Thanks for the replies. I thought that the auto shutdown was only available through Virtual Center. But I prefer this to a script.
0
 
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
much easier than a script.
0

Featured Post

Get quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now