VMware Cloud Community
mudkips
Contributor
Contributor

ESXi 4 (Free) Host Shutdown via UPS-triggered Script?

I posted this to an existing discussion on the same subject. Though the topic was about ESXi 4, it was actually in the 3.5 section.

I've been looking at options for shutting down an ESXi 4 (Update 1, free) host after power failure. APC does have a version for ESXi 4 now, but APC 's compatibility chart notes that it does NOT support the free version of ESXi.

I've got a UPS with a network management card, and it's currently configured to power off all the VMs. But there's nothing set up to power down the ESXi 4 (Update 1, free) host.

As far as I can tell, there is no officially-supported way of shutting down the ESXi 4 (Update 1, free) host via anything other than direct access to the console.

I've read through the documentation for the remote CLI here ( ) and there is no mention of any commands related to controlling the host's power state.

-


I'm currently looking at this page .

At the bottom, there's a block thatrefers to shutting down an ESXi 4.0 host via the vMA or vCLI.

To shut down ESX 4.0 or ESXi 4.0 hosts, run the following command from vMA or vCLI console screen:
/usr/lib/vmware-vicli/apps/host/hostops.pl --target_host <ESX-Host> --operation shutdown --url /<vCenter-Host>/sdk/vimService.wsdl

I've installed the VMware vSphere CLI 4.0 U1, which does in fact include a hostops.pl (in .....\VMware vSphere CLI\Perl\apps\host\ ).

A quicklook through hostops.pl shows that issuing a shutdown command through hostops.pl appears to attempt to suspend all VMs on the host and then shutdown the host itself. I can plop in the IP for the ESXi 4 host into the URL listed in the --url parameter, and there is a vimService.wsdl file accessible there. It looks like it's just a small (~12 lines total) XML file that defines a few things.

What I need to know is whether or not the VMware vSphere CLI 4.0 U1 can in fact use the hostops.pl file that it comes with in order to shutdown

a ESXi 4.0 (Update 1, free) host. I see that hostops.pl doesn't provide any of thst standard connection options. If hostops.pl is indeed supported in VMware vSphere CLI 4.0 U1, then I assume it must be necessary to include them (otherwise anyone could shut down your hosts!). Is the example given assuming the command is being run from vMA (and thus doesn't need the --user and --password parameters)? Would I need to specify --server as well, or is it made redundant by --target_host?

-


According to the documentation I've read, I should be able to open up a command prompt and fire off

hosts.pl --server IP --user user --password pw --target_host IP --operation shutdown --url https://IP/sdk/vimservice.dll

I've seen nothing obvious in the documentation stating that the above would not work with ESXi 4 (Update 1, free) and VMware vSphere CLI 4.0 U1.

If this works, then I can simply use any one of the existing APC PowerChute Network Shutdown installations to run the above command.

Though given all the questions about ESXi and UPS-triggered shutdowns, I simply can't believe the solution would be so simple.

If there is a licensing or configuration restriction that would prevent this from working, it certainly isn't clearly or obviously stated in any of the documentation.

So, after all that, will it work?

I'm not willing to blindly test it on our production boxes if it's not supported, if the hosts.pl I have is differet, etc.

Thanks

Reply
0 Kudos
6 Replies
J1mbo
Virtuoso
Virtuoso

Hi, the issue is that the ESXi vMA interfaces are read-only if it's free licensed.

However you can use SOAP to do it, which is exactly how the vSphere client works. I blogged about this, with a pretty clunky proof of concept, here, and vmware communities member lamw then took this to the next level and developed it into a more robust pearl script, here.

HTH

Please award points to any useful answer.

mudkips
Contributor
Contributor

Thanks, I'll look into it later.

But the bottom line is that the "official" methods are completely undoable with the free version of ESXi?

That seems like a major sticking point that should be noted up front!

Power management is a fundamental aspect of any server setup.

Reply
0 Kudos
J1mbo
Virtuoso
Virtuoso

That's one way of putting it. It's a shame that APC don't build the SOAP work right into their UPS management boards as that would side-step the issue. I sent it to them - they didn't even reply Smiley Sad

Please award points to any useful answer.

Reply
0 Kudos
lamw
Community Manager
Community Manager

As James noted, you can use the unsupported 'SOAP' calls to ESXi host OR you also have the option of unlocking the unsupported Busybox console and setup paired SSH keys to issue a shutdown sequence. In either case, this will be something you'll need to customize yourself.

That seems like a major sticking point that should be noted up front!

Power management is a fundamental aspect of any server setup.

As much as I would love to have the APIs be both r/w ... you pay for what you get and that's what VMware's licensing policy is, so you either live with it or pay for a valid license. It's not super difficult to set something up to have your UPS utility make few SSH calls to ESXi host to shutdown all VMs and then the host, it's actually trivial if you know vimsh (vim-cmd)

If you do go down the route of using a licensed version of ESXi, you can also take a look at this latest version of my UP shutdown script:

Good luck

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

Twitter: @lamw

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Comuunity

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

Reply
0 Kudos
lamw
Community Manager
Community Manager

Probably because the direct SOAP calls by-passes the licensing ... and I doubt APC wants to get into any legal issues Smiley Wink

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

Twitter: @lamw

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Comuunity

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

Reply
0 Kudos
ninv
Contributor
Contributor

Hi, the issue is that the ESXi vMA interfaces are read-only if it's free licensed.

</div>

:smileyangry: They could have let this enabled. It wouldn't hurt that much letting the enthusiasts do something properly / safely. :smileyangry:

Pretty disappointing. At least it seems there is a (hopefully working) workaround

Reply
0 Kudos