7
from oslo_vmware import api
8
from oslo_vmware import vim_util
10
api_session = api.VMwareAPISession('10.1.2.3', 'administrator',
12
create_session=False, port=443)
13
result = api_session.invoke_api(vim_util, 'get_objects',
14
api_session.vim, 'HostSystem', 100)
5
Example usage of getting a handle to a vSphere session and retrieving all the
6
ESX hosts in a server::
8
from oslo_vmware import api
9
from oslo_vmware import vim_util
11
# Get a handle to a vSphere API session
12
session = api.VMwareAPISession(
13
'10.1.2.3', # vSphere host endpoint
14
'administrator', # vSphere username
15
'password', # vSphere password
16
10, # Number of retries for connection failures in tasks
17
0.1 # Poll interval for async tasks (in seconds)
20
# Example call to get all the managed objects of type "HostSystem"
22
result = session.invoke_api(
23
vim_util, # Handle to VIM utility module
24
'get_objects', # API method name to invoke
25
session.vim, 'HostSystem', 100) # Params to API method (*args)