Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1148773

Summary: NPE when adding QoS object without type_ to datacenter
Product: Red Hat Enterprise Virtualization Manager Reporter: Meni Yakove <myakove>
Component: ovirt-engine-restapiAssignee: Juan Hernández <juan.hernandez>
Status: CLOSED CURRENTRELEASE QA Contact: Ilanit Stein <istein>
Severity: high Docs Contact:
Priority: unspecified    
Version: 3.5.0CC: bazulay, dfediuck, ecohen, gklein, iheim, istein, lsurette, mavital, myakove, rbalakri, Rhev-m-bugs, sherold, yeylon
Target Milestone: ---   
Target Release: 3.5.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: sla
Fixed In Version: org.ovirt.engine-root-3.5.0-14 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-02-17 17:11:06 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: SLA RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Engine and server logs none

Description Meni Yakove 2014-10-02 10:23:09 UTC
Created attachment 943343 [details]
Engine and server logs

Description of problem:
Get NPE when adding QoS object without type_ to datacenter.
When creating QoS object the type_ parameter should be forced.

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

How reproducible:
100%

Steps to Reproduce:
1.
2.
3.

Actual results:
NPE

Expected results:
Error: type_ must be specified

Additional info:
>>> from ovirtsdk.api import API
>>> from ovirtsdk.xml import params
>>> API = API(url=URL, username=USERNAME, password=PASSWORD, insecure=True)
>>> 
>>> DC = API.datacenters.get(DC_NAME)
>>> qos_obj = params.QoS(name="qqqq")
>>> DC.qoss.add(qos_obj)
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/usr/lib/python2.6/site-packages/ovirtsdk/infrastructure/brokers.py", line 7835, in add
    headers={"Expect":expect, "Correlation-Id":correlation_id}
  File "/usr/lib/python2.6/site-packages/ovirtsdk/infrastructure/proxy.py", line 88, in add
    return self.request('POST', url, body, headers)
  File "/usr/lib/python2.6/site-packages/ovirtsdk/infrastructure/proxy.py", line 118, in request
    persistent_auth=self._persistent_auth)
  File "/usr/lib/python2.6/site-packages/ovirtsdk/infrastructure/proxy.py", line 146, in __doRequest
    persistent_auth=persistent_auth
  File "/usr/lib/python2.6/site-packages/ovirtsdk/web/connection.py", line 134, in doRequest
    raise RequestError, response
RequestError: 
status: 500
reason: Internal Server Error
detail: JBWEB000065: HTTP Status 500 - java.lang.NullPointerException

Comment 1 Juan Hernández 2014-10-02 14:15:57 UTC
This happens because the presence of the mandatory "type" parameter isn't validated by the server, but the value is validated thus triggering a NPE.

To fix the issue we need to validate the presence of the parameter and also make sure that the validation of the value takes into account that it can be null.

Comment 2 Eyal Edri 2014-10-07 07:13:02 UTC
this bug status was moved to MODIFIED before engine vt5 was built,
hence moving to on_qa, if this was mistake and the fix isn't in,
please contact rhev-integ

Comment 3 Nikolai Sednev 2014-11-02 14:27:23 UTC
Hi,
Please provide exact steps for bug reproduction.

Comment 4 Juan Hernández 2014-11-03 09:06:17 UTC
In order to reproduce create and execute a Python script like this (copied from the description of the bug):

#!/usr/bin/python

from ovirtsdk.api import API
from ovirtsdk.xml import params

api = API(
  url="https://ovirt.example.com/ovirt-engine/api",
  username="admin@internal",
  password="******",
  insecure=True
)

dc = api.datacenters.get("mydc")
qos = params.QoS(name="myquos")
dc.qoss.add(qos)

The result of this should be an error message indicating that the "type" attribute is mandatory:

status: 400
reason: Bad
detail: QoS [type] required for add

Modify the Python script so that it includes the type:

qos = params.QoS(name="myquos", type_="storage")

Then run it again. This time it should add the new QoS without errors.

Comment 5 Ilanit Stein 2014-11-05 11:41:52 UTC
Tested on vt8 (rhevm-sdk-python-3.5.0.7-3.el6ev.noarch.rpm),
using the script from comment #4.
Looks as if fix is not included yet in this version.
Got the same error, as in bug description:

Traceback (most recent call last):
  File "bug_1148773.py", line 15, in <module>
    dc.qoss.add(qos)
  File "/usr/lib/python2.6/site-packages/ovirtsdk/infrastructure/brokers.py", line 7835, in add
    headers={"Expect":expect, "Correlation-Id":correlation_id}
  File "/usr/lib/python2.6/site-packages/ovirtsdk/infrastructure/proxy.py", line 88, in add
    return self.request('POST', url, body, headers)
  File "/usr/lib/python2.6/site-packages/ovirtsdk/infrastructure/proxy.py", line 118, in request
    persistent_auth=self._persistent_auth)
  File "/usr/lib/python2.6/site-packages/ovirtsdk/infrastructure/proxy.py", line 146, in __doRequest
    persistent_auth=persistent_auth
  File "/usr/lib/python2.6/site-packages/ovirtsdk/web/connection.py", line 134, in doRequest
    raise RequestError, response
ovirtsdk.infrastructure.errors.RequestError: 
status: 400
reason: Bad Request
detail: QoS [type] required for add

Comment 6 Juan Hernández 2014-11-05 11:45:53 UTC
Ilanit, did you add the "type_" parameter to the script? Should be like this:

qos = params.QoS(name="myquos", type_="storage")
    Note the type_ parameter -> ^^^^^^^^^^^^^^

Comment 7 Ilanit Stein 2014-11-05 11:58:47 UTC
In case of type provided, like in comment #6,
the qos object is added to the dataCenter, and there is no error.

Moving to verified, as I now understand the output for not providing the mandatory type parameter, is as expected.

Comment 8 Eyal Edri 2015-02-17 17:11:06 UTC
rhev 3.5.0 was released. closing.