Bug 888737 - unable to get name of template from existing VM
Summary: unable to get name of template from existing VM
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Virtualization Manager
Classification: Red Hat
Component: ovirt-engine-sdk
Version: 3.0.3
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
: ---
Assignee: Michael Pasternak
QA Contact: Elena
URL:
Whiteboard:
Depends On:
Blocks: 1213937
TreeView+ depends on / blocked
 
Reported: 2012-12-19 11:25 UTC by Petr Spacek
Modified: 2015-04-21 15:19 UTC (History)
10 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-12-19 11:53:36 UTC
oVirt Team: ---
Target Upstream Version:


Attachments (Terms of Use)

Description Petr Spacek 2012-12-19 11:25:45 UTC
Description of problem:
Template name is returned as None in some cases, see steps to reproduce for exact description.


Version-Release number of selected component (if applicable):
ovirt-engine-sdk-1.3-1.el6.noarch

RHEV-M server version:
rhevm-3.0.3_0001-3.el6.x86_64


How reproducible:
100 %


Steps to Reproduce: Run following Python code:

from ovirtsdk.api import API as rhevm_api
api = rhevm_api("uri", "username", "password")
# replace 10 with randomly picked VM number
print api.vms.list()[10].get_template().get_id()
print api.vms.list()[10].get_template().get_name()

It will print templace ID and None in place of template name:
'1d9c2917-2bdc-4d83-8b64-26350343b703'
None

  
Actual results:
None is returned as template name.


Expected results:
String with real template name is returned.


Additional info:
Template IDs and names seem to be correct if I list all templates via api.templates.list().

Comment 1 Michael Pasternak 2012-12-19 11:53:36 UTC
Petr,

Mentioned above is a part of our RESTful api, i.e for api to be self descriptive,
it has to describe relations between the resources, and relation between
vm & template described by ID of the template vm was created from,

this why you can see in vm.template.id only, to get template's name,
you need to fetch it by the mention id first.

Comment 2 Petr Spacek 2012-12-19 12:30:19 UTC
I'm not expert in REST APIs, but IMHO SDK/libraries should hide details of protocol implementation.

IMHO library should do one of following:
- fetch the required data
- do not export methods where are inappropriate (and distinguish "full-featured" get_template() from "less featured" get_template_id())
- throw some exception like "unsupported blah blah blah" (please, don't do it :-))

Current behaviour makes impression of "fast-baked" API to me.

Comment 3 Michael Pasternak 2012-12-19 12:44:49 UTC
(In reply to comment #2)
> I'm not expert in REST APIs, but IMHO SDK/libraries should hide details of
> protocol implementation.

it do hides it.

> 
> IMHO library should do one of following:
> - fetch the required data
> - do not export methods where are inappropriate (and distinguish
> "full-featured" get_template() from "less featured" get_template_id())
> - throw some exception like "unsupported blah blah blah" (please, don't do
> it :-))
> 
> Current behaviour makes impression of "fast-baked" API to me.

i disagree:

1. relation between vm and template described by parameters holder (which is template in this case), and name of the template is not a part of this relation.
(you can't have template inside of vm)

2. in python is not common to throw exceptions in getters, rather than return
None.


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