[ovirt-users] Python-SDK: ovirtsdk4.Connection object autologout?

nicolas at devels.es nicolas at devels.es
Wed Mar 22 12:10:21 UTC 2017


Hi,

We've recently upgraded from oVirt 4.0.x to 4.1.0 and it seems that the 
behavior of a script we wrote in Python-SDK has changed slightly. We 
have a script that needs to be executed forever (daemon mode). This 
daemon creates an ovirtsdk4.Connection object and uses the same 
Connection object all the time.

conn = sdk.Connection(
   url=URI,
   username=USERNAME,
   password=PASSWORD,
   ca_file=CAFILE
)

Between iterations we have ~5 minutes delays which we accomplish with a 
time.sleep(...) call.

After some of these iterations (5 or 6), when trying to perform an 
operation on the Connection object (in this case, listing all SDs):

     try:
         sys_serv = conn.system_service()
         sd_serv = sys_serv.storage_domains_service()
         storages = sd_serv.list(search=sd_search_query)
     except Error, e:
         log('ERR: Error getting storage domains: %s' % (e))

We start getting exceptions (i.e., the sd_serv.list() call throwing an 
Error exception) with this message:

     ERR: Error getting storage domains: HTTP response code is 401.

I believe this has something to do with the Connection object expiring 
(even if it's not idle more than 5 minutes at any time). Is there a way 
to "refresh" the Connection object so it doesn't auto-logout (assuming 
this is the actual problem)?

As I said, this started happening as of oVirt 4.1.0. 
ovirt-engine-sdk-python version is 4.1.1.

Any ideas?

Thanks.


More information about the Users mailing list