Bug 1368826 - Docs: Python v4 SDK documentation does not mention the correct import statement - for the v4 SDK.
Summary: Docs: Python v4 SDK documentation does not mention the correct import stateme...
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Virtualization Manager
Classification: Red Hat
Component: Documentation
Version: 4.0.0
Hardware: Unspecified
OS: Unspecified
unspecified
low
Target Milestone: ovirt-4.0.3
: ---
Assignee: rhev-docs@redhat.com
QA Contact: rhev-docs@redhat.com
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-08-21 17:05 UTC by Pavel Zhukov
Modified: 2016-08-25 02:07 UTC (History)
11 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-08-25 02:07:45 UTC
oVirt Team: Docs
Target Upstream Version:


Attachments (Terms of Use)
test script (1.45 KB, text/x-python)
2016-08-21 17:05 UTC, Pavel Zhukov
no flags Details
engine log (52.09 KB, text/plain)
2016-08-22 08:43 UTC, Pavel Zhukov
no flags Details

Description Pavel Zhukov 2016-08-21 17:05:46 UTC
Created attachment 1192626 [details]
test script

Description of problem:
Tried this code:
https://access.redhat.com/documentation/en/red-hat-virtualization/4.0/single/python-sdk-guide/#Example_Creating_a_Virtual_Machine_Storage_Disk_using_Python

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


How reproducible:
100%

Steps to Reproduce:
1. Try to add new disk to existing VM


Actual results:
Traceback (most recent call last):
  File "./createvm.py", line 62, in <module>
    d = sd.disks.add(disk_params)
  File "/usr/lib/python2.7/site-packages/ovirtsdk/infrastructure/brokers.py", line 25726, in add
    headers={"Correlation-Id":correlation_id, "Expect":expect}
  File "/usr/lib/python2.7/site-packages/ovirtsdk/infrastructure/proxy.py", line 79, in add
    return self.request('POST', url, body, headers, cls=cls)
  File "/usr/lib/python2.7/site-packages/ovirtsdk/infrastructure/proxy.py", line 122, in request
    persistent_auth=self.__persistent_auth
  File "/usr/lib/python2.7/site-packages/ovirtsdk/infrastructure/connectionspool.py", line 79, in do_request
    persistent_auth)
  File "/usr/lib/python2.7/site-packages/ovirtsdk/infrastructure/connectionspool.py", line 156, in __do_request
    raise errors.RequestError(response_code, response_reason, response_body)
ovirtsdk.infrastructure.errors.RequestError: 
status: 400
reason: Bad Request
detail: 
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<usage_message>
    <message>Request syntactically incorrect. See the description below for the correct usage:</message>
    <detailedLink href="/ovirt-engine/api/storagedomains/{storagedomain:id}/disks" rel="add">
        <description>add a new disk to the storage domain</description>
...


Expected results:


Additional info:

Comment 1 Allon Mureinik 2016-08-22 02:38:50 UTC
Engine logs please?

Comment 2 Allon Mureinik 2016-08-22 02:39:42 UTC
Ondre, should someone from Storage look at it, or is this an issue with the SDK itself?

Comment 3 Allon Mureinik 2016-08-22 02:41:28 UTC
(In reply to Allon Mureinik from comment #2)
> Ondre, should someone from Storage look at it, or is this an issue with the
> SDK itself?

Ondra, of course. My apologies for misspelling your name.

Comment 4 Yaniv Kaul 2016-08-22 07:11:44 UTC
The import is not importing the v4 SDK:
should be:
import ovirtsdk4 as sdk

while the snippet @ https://access.redhat.com/documentation/en/red-hat-virtualization/4.0/single/python-sdk-guide/#Example_Creating_a_Virtual_Machine_Storage_Disk_using_Python shows:

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

So I assume it's using the v3 SDK.

(if that's correct, then this should be moved to a Docs bug).

Comment 5 Pavel Zhukov 2016-08-22 08:37:29 UTC
(In reply to Yaniv Kaul from comment #4)
> The import is not importing the v4 SDK:
> should be:
> import ovirtsdk4 as sdk
> 
> while the snippet @
> https://access.redhat.com/documentation/en/red-hat-virtualization/4.0/single/
> python-sdk-guide/
> #Example_Creating_a_Virtual_Machine_Storage_Disk_using_Python shows:
> 
> from ovirtsdk.api import API
> from ovirtsdk.xml import params 
> 
> So I assume it's using the v3 SDK.
> 
> (if that's correct, then this should be moved to a Docs bug).

It's correct. That's why I've opened this BZ against docs component

Comment 6 Pavel Zhukov 2016-08-22 08:43:47 UTC
Created attachment 1192834 [details]
engine log

Comment 7 Yaniv Kaul 2016-08-22 09:06:42 UTC
Changing title accordingly...

Comment 8 Ondra Machacek 2016-08-22 10:36:30 UTC
This is Python SDK v3. The script in attachment is not what you have in traceback
in bug description. I can see there :

  d = sd.disks.add(disk_params)

Didn't you want to write something like `vm.disks.add(..)` ?

Comment 9 Pavel Zhukov 2016-08-22 12:42:28 UTC
(In reply to Ondra Machacek from comment #8)
> This is Python SDK v3. The script in attachment is not what you have in
> traceback
> in bug description. I can see there :
> 
>   d = sd.disks.add(disk_params)
> 
> Didn't you want to write something like `vm.disks.add(..)` ?

Right.Thanks. I messed up things during copy-pasting. Sorry about that. 
Closing

Comment 10 Yaniv Kaul 2016-08-22 12:43:52 UTC
(In reply to Ondra Machacek from comment #8)
> This is Python SDK v3. The script in attachment is not what you have in

The docs link in comment 1 is for v4 API and does not contain the correct import statement, as indicated in comment 4 .
Please fix.

Comment 11 Ondra Machacek 2016-08-22 12:53:44 UTC
As far as I know we don't have SDK v4 doc, yet. The link is for v3.

Comment 12 Yaniv Lavi 2016-08-25 02:07:45 UTC
We don't have any v4 docs yet. This is planned for the first z stream.


Note You need to log in before you can comment on or make changes to this bug.