Bug 1109709

Summary: Python SDK is not able to reconnect to the RHEV-M API
Product: Red Hat Enterprise Virtualization Manager Reporter: Roman Hodain <rhodain>
Component: ovirt-engine-sdkAssignee: Juan Hernández <juan.hernandez>
Status: CLOSED DUPLICATE QA Contact: Shai Revivo <srevivo>
Severity: medium Docs Contact:
Priority: medium    
Version: 3.4.0CC: acathrow, gklein, iheim, oramraz, Rhev-m-bugs, yeylon
Target Milestone: ---   
Target Release: 3.5.0   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-06-16 11:00:41 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Roman Hodain 2014-06-16 08:02:46 UTC
Description of problem:
	python SDK is not able to reconnect after a connection failure.

Version-Release number of selected component (if applicable):
	rhevm-sdk-python-3.4.1.0-2.el6ev.noarch

How reproducible:
	100%

Steps to Reproduce:
	Run the following script on the RHEV-M and restart the engine. Or
shutdown the manger and then start the script.

=======================================
#!/usr/bin/python
import sys
import time
from ovirtsdk.api import API

USERNAME="admin@internal"
PASSWORD="password"
TAG='AlwaysUp'
CA_FILE="/etc/pki/ovirt-engine/ca.pem"
URL="https://FQDN/api"

while True:
        try:
                api_instance = API(url=URL,
                        username=USERNAME,
                        password=PASSWORD,
                        ca_file=CA_FILE)
                print "Connection Ok..."
        except Exception as e:
                print "Connection failure: %s" % str(e)
        time.sleep(5)

======================================

Actual results:
	[ERROR]::oVirt sdk is disconnected from the server.

Expected results:
	SDK is able to reconnect

Comment 1 Juan Hernández 2014-06-16 11:00:41 UTC
The constructor of the SDK has a "renew_session" parameter that enables automatic re-connection. The default values is False, so you need to include it explicitly in the call to the constructor:

  api_instance = API(url=URL,
          username=USERNAME,
          password=PASSWORD,
          ca_file=CA_FILE,
          renew_session=True)

*** This bug has been marked as a duplicate of bug 1018559 ***