Hi!
We've a problem with the ESXi 4 during the test with our APC SUA-2200 UPS. We have only 1 ESXi server. The vMA doesn't want to shut the ESXi down when receive the shutdown signal, so when the UPS battery. So when the battery dies the machine just powers off without graceful shutdown of the VMs. The UPS has an installed network management card. We deployed a vMA to our ESXi and installed the APC's PowerChute Software (PCNS). So the status is the following:
1. The network management in the UPS card is working correctly (we can access the webUI from any computer)
2. The vMA has a correct Powerchute software. We opened all require ports with the iptables. So we can reach the PowerChute's webUI.
3. We configured the ESXi with the vSphere to automaticaly startup/shutdown with the system. If we reboots the ESXi with the vShere the system shuts the Virtual Machines down correctly.
4. The PowerChute can communicate with the UPS Network card correctly. And the vMA receives the shutdown signal correctly. But the vMA only shuts down itself and leaves the ESXi on, that is our problem.
How can we force the vMA to shutdown our ESXi?
Have you experienced a problem like this before with the PowerChute, or do you have any idea what causes this error?
Thank you for your help!
Regards,
Robert
<!Session data>
That is not good I haven't seen anything about this. Is this restriction also available on ESXi 4.0? Could you give me a command which I can test this write protection on our (free licensed) server?
Thank you!
This read-only change took effect with ESXi 3.5 U4, so ESXi 4 is affected.
1. Install PowerShell on a laptop
2. Install PowerCLI on the laptop: http://communities.vmware.com/community/vmtn/vsphere/automationtools/windows_toolkit?view=overview
3. Open PowerCLI or get PowerGUI to run your scripts
## run these two lines if you're running your script from PowerGUI $VMCore = Get-PSSnapin VMware.VimAutomation.Core -EA 0 if ( -not $VMCore ) { Add-PSSnapin VMware.VimAutomation.Core }; Connect-VIServer -Server xxx.xxx.xxx.xxx -User username -Password myPassword; if ( $DefaultVIServer -eq $null) { Write-Host "Connection Failed!"; return $false } else { Write-Host "Connected : " $DefaultVIServer.IsConnected; ## Lets assign some views to variables $global:moServiceInstance = (get-view ServiceInstance); $global:moHostSystem = Get-View -VIObject (Get-VMHost); $global:DefaultVIServer = $DefaultVIServer; }; ## This is a write op, setting the VM start policies; should fail Get-VMHostStartPolicy -VMHost (Get-VMHost -Server $DefaultVIServer) | Set-VMHostStartPolicy -Enabled $true -WaitForHeartbeat $true -StopDelay 120 -StopAction "GuestShutDown"; ## this is a write op too, shut down a vm Stop-VM "myVM"; ## another write op, shut down the entire HOST $global:moHostSystem.ShutdownHost_Task($true); Disconnect-VIServer -Server $DefaultVIServer -Confirm:$false -EA 0;
Ref: http://www.vmware.com/support/developer/windowstoolkit/wintk40u1/html/index.html
Another possible solution is to use VMRUN included in VIX API. Once the battery is dying the PCNS would run a batch file.
vmrun.exe -h https://192.168.1.1:443/sdk -T esx -u username -p password stop "|datastore1| myvm/myvm.vmx" soft vmrun.exe -h https://192.168.1.1:443/sdk -T esx -u username -p password stop "|datastore1| myvm2/myvm2.vmx" soft
You also might be able to shutdown the host via SSH, but I'm not sure.
> ## another write op, shut down the entire HOST > $global:moHostSystem.ShutdownHost_Task($true); >
Don't mean to threadjack but we have a Stop-VMHost in PowerCLI as of U1. A lot more readable than the ShudownHost_Task stuff.
Back to the topic, ESX 3.5 and 4.0 are locked down, even the vmrun command above. Might be possible to enable SSH and shut down via sshing in and running a shutdown command within the ESXi console.
=====
Carter Shanklin
Read the PowerCLI Blog
[Follow me on Twitter|http://twitter.com/cshanklin]
I have just tested a solution to this problem - will be posting a blog about it in the next couple of days!
And it works with free licensed ESXi
Super! It would be great! Thank you! :smileygrin: <!Session data><!Session data>
The two scripts posted earlier do work.
Hi DSTAVERT - which two scripts do you mean? As from everything I have read, free-licensed (specifically) ESXi is locked down for this kind of thing since 3.5U3,
ESX 3.5 and 4.0 are locked down, even the vmrun command above
This one does work on 3.5 and 4 although it requires SSH enabled. I forgot that lamw's script was perl and required a licensed version.
OK that's good to know.
Here's what I've been working on - this doesn't need SSH and will work from Windows:
Please award points to any useful answer.
Very clever approach!
Very interesting indeed, it sounds like this can even be re-integrated with my ghettoShutdown.pl script and instead of relying on the APIs, do exactly what's been discovered by sending this soap call to shutdown the host.
=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at:
VMware Code Central - Scripts/Sample code for Developers and Administrators
If you find this information useful, please award points for "correct" or "helpful".
Superb job. Someone at APC should be watching you.
Thanks for the positive feedback on this
Re APC - it occured to me this morning, it would be very simple for the APC management card itself to fire off the shutdown command when needed, completely bypassing the need for installed agents or any work on the part of vmware. I wonder how easy it is to reverse engineer the management card firmware!?
Please award points to any useful answer.
Now I'm interested in the messages to shutdown the guests 😛
here's your new avatar jimbo:
Lol...Thanks!
That I can help you with, because I used suspend etc to develop it. Would have been a bit time consuming waiting for the host to power cycle each time.
Burp is your friend - everything in the client is just this soap stuff, which incidentally I know nothing about. I figured for the shutdown, a dos script would be fine but can immediately see there is great potential to develop a kind of "esxi command line" using these captures, that would be if I knew anything about programming (my skills on which ended at Turbo Pascal for DOS in 1994).
Here for example is a suspend request:
This is why it's going to be hard to script this, as we need to pick up the VM GUIDs (and friendly names) before hand to pick. In a DOS script that will be horrid, it was bad enough checking for connectivity and working out the length of the username and password! That said I suppose it is doable, I might give it a whirl later.
Cheers
Is the serverGuid basically the moref ID for the VM via the APIs? If so, then it's a piece of cake to extract via the vSphere API (remember the APIs are full read access, just can't perform any write operation)
It sounds like we're just constructing the SOAP messages to send to ESX(i), so long as its constructed correctly with the right credentials, all of this is pretty simple .. if I understand what you're doing, though you're right, wouldn't recommend doing this in windows .bat file (probably PowerCLI or Perl) would be a better fit
=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at:
VMware Code Central - Scripts/Sample code for Developers and Administrators
If you find this information useful, please award points for "correct" or "helpful".
I started exploring and it would be fairly simple to construct various XML requests:
https://192.168.1.1/mob/?moid=ha-sessionmgr
https://192.168.1.1/mob/?moid=ha-host
for above suspend example: https://192.168.1.1/mob/?moid=400
Yep, I already got some working samples already
=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at:
VMware Code Central - Scripts/Sample code for Developers and Administrators
If you find this information useful, please award points for "correct" or "helpful".