Bug 1360779

Summary: [sdk-v4] calls to engine are failing when connection was made specifying v4 in engine url
Product: [oVirt] ovirt-engine-sdk-python Reporter: sefi litmanovich <slitmano>
Component: CoreAssignee: Ondra Machacek <omachace>
Status: CLOSED CURRENTRELEASE QA Contact: Petr Matyáš <pmatyas>
Severity: low Docs Contact:
Priority: low    
Version: 4.0.0aCC: bugs, juan.hernandez, mgoldboi, mperina, pmatyas
Target Milestone: ovirt-4.0.4Flags: rule-engine: ovirt-4.0.z+
mgoldboi: planning_ack+
omachace: devel_ack+
pstehlik: testing_ack+
Target Release: 4.0.0.a6   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-09-26 12:33:43 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Infra RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description sefi litmanovich 2016-07-27 13:08:02 UTC
Description of problem:
Failed to initiate a connection to the engine with the new v4 sdk if specified the version number in url:

import ovirtsdk4 as sdk
import ovirtsdk4.types as types
api = sdk.Connection(url="https://{engine_url}/ovirt-engine/api/v4", username='{user@domain}', password='{pass}', insecure=True)
vm_pool_service = api.system_service().vm_pools_service()
vm_pool_service.list()
Traceback (most recent call last):
  File "<input>", line 1, in <module>
    vm_pool_service.list()
  File "/usr/lib64/python2.7/site-packages/ovirtsdk4/services.py", line 20254, in list
    response = self._connection.send(request)
  File "/usr/lib64/python2.7/site-packages/ovirtsdk4/__init__.py", line 281, in send
    return self.__send(request)
  File "/usr/lib64/python2.7/site-packages/ovirtsdk4/__init__.py", line 292, in __send
    self._sso_token = self._get_access_token()
  File "/usr/lib64/python2.7/site-packages/ovirtsdk4/__init__.py", line 450, in _get_access_token
    sso_response = self._get_sso_response(self._sso_url)
  File "/usr/lib64/python2.7/site-packages/ovirtsdk4/__init__.py", line 488, in _get_sso_response
    return json.loads(body_buf.getvalue().decode('utf-8'))
  File "/usr/lib64/python2.7/json/__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "/usr/lib64/python2.7/json/decoder.py", line 366, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib64/python2.7/json/decoder.py", line 384, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

Works fine when connecting with url without the v4 flag in the url.


Version-Release number of selected component (if applicable):
python-ovirt-engine-sdk4-4.0.0-0.5.a5.el7ev.x86_64

How reproducible:
seems to happen always.

Steps to Reproduce:
as mentioned above.

Actual results:
couldn't get the list of vm pools in this specific case (happens with all entities).

Expected results:
succeed to get list of all entities as normal.

Comment 1 Red Hat Bugzilla Rules Engine 2016-07-27 14:48:06 UTC
Bug tickets must have version flags set prior to targeting them to a release. Please ask maintainer to set the correct version flags and only then set the target milestone.

Comment 2 Juan Hernández 2016-07-27 14:59:06 UTC
I am setting severity to "low" because the issue can be avoided just removing the "/v4" suffix, the SDK always sends the "Version: 4" header anyhow.

Comment 3 Petr Matyáš 2016-09-13 08:16:22 UTC
Verified on 4.0.4-3