#!/usr/bin/python
from pyVim import connect
__author__=”openwriteup”
if __name__==”__main__”:
”’test code for PyVmomi”’
print “Connect to esxi…”
si=connect.Connect(“10.14.21.14″,443,”root”,”password”)
searcher=si.content.searchIndex
vm=searcher.FindByInventoryPath(“ha-datacenter/vm/rhelvm”)
vmname=vm.GetName()
print “Amit’s” + vmname
print “diconnecting esxi…”
connect.Disconnect(si)
Help on function Connect in module pyVim.connect:
Connect(host=’localhost’, port=443, user=’root’, pwd=”, service=’hostd’, adapter=’SOAP’, namespace=None, path=’/sdk’, version=None, keyFile=None, certFile=None, thumbprint=None)
Connect to the specified server, login and return the service
instance object.
Throws any exception back to caller. The service instance object is
also saved in the library for easy access.
Clients should modify the service parameter only when connecting to
a VMOMI server other than hostd/vpxd. For both of the latter, the
default value is fine.
@param host: Which host to connect to.
@type host: string
@param port: Port
@type port: int
@param user: User
@type user: string
@param pwd: Password
@type pwd: string
@param service: Service
@type service: string
@param adapter: Adapter
@type adapter: string
@param namespace: Namespace *** Deprecated: Use version instead ***
@type namespace: string
@param path: Path
@type path: string
@param version: Version
@type version: string
@param keyFile: ssl key file path
@type keyFile: string
@param certFile: ssl cert file path
@type certFile: string
@param thumbprint: host cert thumbprint
@type thumbprint: string
(END)