1

I'm trying to write a script that ssh's to an ESXi 6.7 and shuts down the host and also shuts down the VMs according to the current system shutdown policy.

I'm running Dell customized image ESXi 6.7 in a Dell R710 with a dual Xeon X5650 and 144GB RAM.

In fact what I want is the same that I can get with:

Shutdown via GUI

Shutdown via console

I have ssh enabled in the server.

I already tryed:

1) host_shutdown.sh (it just gets there indefinitely).

2) /bin/host_shutdown.sh (it to gets there indefinitely).

3) halt (shutdowns the server but it does not shuts down the VMs)

I also tried:

esxcli system shutdown poweroff --reason I_want_IT

but the system must be in maintenance mode and I want to do it without entering maintenance mode

I then discovered this thread here in Server Fault, but it does not work in my environment as it is PowerCLI and I'm want to run the script from a Raspberry Pi:

How do I shutdown the Host over ssh on ESXi 5 so it shuts down the guests properly?

I think I'm too dumb to discover on my own how to do it, because I presume it must be a simple thing to do.

2 Answers 2

4

I think I finally found the solution to this problem. After digging a lot I found that: /sbin/shutdown.sh && /sbin/poweroff will do the trick !!!

It shuts all VMs according to the current system startup policy and then it shuts the host down.

0

Despite not being clear to me why the procedure VMware suggests isn't doing it for you or why you would want this in a VSphere setting, you do seem to have found a solution.

As .NET, Powershell and PowerCLI are available on Linux ARM, why not use the script you found? Or have a look at Govmomi?

update: added VMware's docs on how they think it should be done

4
  • This is something that should have a way to work from within ESXi's own commands with no additional scripts necessary.
    – Overmind
    Jun 25, 2019 at 7:39
  • Did you follow the procedure I linked to? I can't gather from your question that you did.
    – fuero
    Jul 8, 2019 at 19:47
  • @Overmind Exactly. Thats what I was expecting and thats why I asked it here.
    – ppsilva
    Jul 8, 2019 at 19:47
  • @fuero. The procedure you mention is to shutdown the VMs. What I am searching is for a command the shutsdown the host and shutsdown the VMs orderly. Both the servers in my cluster are configured as you mention. To clarify a little more, I'm writing a script in Python in the Raspberry, that receives a mail and shutsdown my storage (via a PDU) and then shutsdown both my hosts in which the ESXi runs.
    – ppsilva
    Jul 8, 2019 at 19:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .