First steps with pyvmomi

The first thing is you need to do is connect to ESXi MoB by providing the username, password, and host IP, and start to navigate to the MoB to get the required data. This can be done by using the SmartConnectNoSSL() method:

from pyVim.connect import SmartConnect, Disconnect,SmartConnectNoSSLESXi_connection = SmartConnectNoSSL(host="10.10.10.115", user="root", pwd='access123')

Note that there's another method called SmartConnect() and you must provide the SSL context to it when establishing a connection, otherwise the connection will fail. However, you can use the following code snippet to request that the SSL does not verify the certificate and to pass this context to SmartConnect() in the sslCContext argument:

Get Hands-On Enterprise Automation with Python. now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.