pysphere
pysphere copied to clipboard
Intermittent VIException: [Object Not Found] - probably because underlying sessions expired
What steps will reproduce the problem?
I believe that these steps will reproduce the problem:
1. Initiate a connection with VI Host
2. Verify that get_vm_by_name can find a vm
3. Sleep for an hour or so
4. Call get_vm_by_name again to see the following stack.
What is the expected output? What do you see instead?
Expected output is that a virtual machine object be returned
Traceback (most recent call last):
...
parentVM = viHost.get_vm_by_name(vmName)
File "MYVIRTUAL_ENV//local/lib/python2.7/site-packages/dig_common/vihelper.py", line 67, in get_vm_by_name
vm = VIServer.get_vm_by_name(self, name, datacenter)
File "MYVIRTUAL_ENV/local/lib/python2.7/site-packages/pysphere/vi_server.py", line 323, in get_vm_by_name
FaultTypes.OBJECT_NOT_FOUND)
VIException: [Object Not Found]: Could not find a VM named 'my vm'
What version of the product are you using? On what operating system?
Latest pysphere on ubuntu
Please provide any additional information below.
Shigehiro Hattori has documented that reconnecting works and I can attest to
that.
http://lost-and-found-narihiro.blogspot.com/2013/02/pysphere-vsphere-sdk-for-pyt
hon.html
Before calling get_vm_by_name, I do verify that connection is_connected status
is True. However I guess is_connected() call doesn't verify if the connection
is alive.
Original issue reported on code.google.com by [email protected]
on 16 Jun 2014 at 10:30
Try to use keep_session_alive() instead of is_connected(). Its docstring says
"""Asks sever time, usefull for keeping alive a session. Returns
False if the session expired"""
Original comment by [email protected]
on 21 Jun 2014 at 9:16