anurag2189
Enthusiast
Enthusiast

Is there any API in python to reboot/shutdown the standalone ESXi host (Without using any vCenter) ?

I have looked into few Python APIs and its very tough to find any host related operations which doesn't need vCenter.

Is there any API in python to reboot/shutdown the standalone ESXi host ?

0 Kudos
4 Replies
sk84
Expert
Expert

Unfortunately I don't know how to do this natively in Python without vCenter, but there is the vCLI (also for Linux) with which you can send commands to the ESXi host and shut it down. But first you should shutdown your running VMs and put the host into maintenance mode.

So, one way would be to install vCLI and invoke the command "vicfg-hostops" within your Python script.

See: Online Documentation - vSphere Command-Line Interface Reference - VMware {code}

With "--server" you can specify an ESXi or vCenter hostname or IP. That's not really clear in the documentation, imho.

--- Regards, Sebastian VCP6.5-DCV // VCP7-CMA // vSAN 2017 Specialist Please mark this answer as 'helpful' or 'correct' if you think your question has been answered correctly.
0 Kudos

It might be worth adding that if the reason for there being no vCenter is because the hosts are running with the free ESXi license, then even if the API existed then it most likely wouldn't work. One of the limitations of the free ESXi license is that all the APIs like vCLI, PowerCLI only provide read-only access to the host. So you can't turn the host off that way anyway.

0 Kudos
anurag2189
Enthusiast
Enthusiast

Thanks for the response.

I had an option for vicfg-hostops but its throwing an error,

vicfg-hostops --server=XXXXXXX --username=root --password=xxx --operation info

Hiding the command line arguments: symbol lookup error: /usr/lib64/perl5/auto/Crypt/SSLeay/SSLeay.so: undefined symbol: Perl_Gthr_key_ptr

OS - RHEL7.3

and it has been a nightmare to solve above issue after trying all the solutions. That's why i was looking for similar toolkit in python (Not involving vCLI or vCenter).

0 Kudos

0 Kudos