Skip to content

Instantly share code, notes, and snippets.

@pathcl
Created June 12, 2015 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pathcl/bcfc43b6b228936bed68 to your computer and use it in GitHub Desktop.
Save pathcl/bcfc43b6b228936bed68 to your computer and use it in GitHub Desktop.
connect.py
#!/usr/bin/env python
"""
vSphere Python SDK program for connecting a Vmware host
"""
import atexit
from pyVim import connect
service_instance = connect.SmartConnect(host='host',
user='user',
pwd='password',
port=int(443))
atexit.register(connect.Disconnect, service_instance)
content = service_instance.RetrieveContent()
objview = content.viewManager.CreateContainerView(content.rootFolder,
[],
True)
esxi_hosts = objview.view
print esxi_hosts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment