Exploring VMware VCenter REST API using python – part II

By | 29th January 2018

While the first article describes how to get started with the vmware API using python,
this article I am trying to do some use cases of the API such as starting a service.

One of the requirement for performing any operations on the ESX/VC is to get it autheticated first and
then try for the operations. In this case, I am trying to create a session first and once the session is
created we can try the required operations.

The way API is explored remains the same.
We are taking an example of starting the Image Builder Service in the vcenter.

API Explorer: https://code.vmware.com/apis/62/vcenter-management
https://code.vmware.com/web/dp/explorer-apis

Example:
Connecting to the VC
Authentication against the username password
Starting/Stopping of the service
Checking if the service started without any issues

Code:
https://github.com/rajeevrn/myscripts/blob/master/vmware/vcenterapi_vmon.py