Bug 1658156 - tags property of Vm object returns empty list even though tags are assigned to the VM
Summary: tags property of Vm object returns empty list even though tags are assigned t...
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: ovirt-engine-sdk-python
Classification: oVirt
Component: Core
Version: 4.2.8
Hardware: Unspecified
OS: Unspecified
unspecified
low
Target Milestone: ---
: ---
Assignee: Ondra Machacek
QA Contact: Lukas Svaty
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-12-11 12:10 UTC by Jan Zmeskal
Modified: 2018-12-11 12:19 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-12-11 12:19:26 UTC
oVirt Team: Infra
Embargoed:


Attachments (Terms of Use)

Description Jan Zmeskal 2018-12-11 12:10:41 UTC
Description of problem:
If you instantiate ovirtsdk4.types.Vm object using python SDK and query its tags, empty list is returned even though that are tags assigned to that VM.

Version-Release number of selected component (if applicable):
ovirt-engine-sdk-python==4.2.9 (could not choose 4.2.9 in Version field, but this is the actual version I used and the most recent one released as of time of writing this)

How reproducible:
100 %

Steps to Reproduce:
1. Have a RHV engine with one VM. Create a tag and assign that tag to your VM in webadmin UI. Make sure that the tag is assigned by activating it in search and then checking that your VM has been matched.
2. Create a python script using ovirtsdk4. Initialize connection to your engine (let's call it "con") and instantiate VM object like this:
my_vm = con.system_service().vms_service().list(search='name=<vm_name>', max=1)[0]

3. Make sure that you actually instantiated the correct Vm object by these two commands:
my_vm.name
my_vm.id

4. List tags assigned to your VM:
my_vm.tags


Actual results:
Empty list is returned.

Expected results:
I'd expect a list of tags assigned to my VM.

Additional info:
I can get a list of tags assigned to a VM like this:
vms_service = con.system_service().vms_service()
vm_service = vms_service.vm_service(<my_vm_id>)
tags_service = vm_service.tags_service()
tags_service.list()

Comment 1 Ondra Machacek 2018-12-11 12:19:26 UTC
As you stated this is correct way to get it:

vms_service = con.system_service().vms_service()
vm_service = vms_service.vm_service(<my_vm_id>)
tags_service = vm_service.tags_service()
tags_service.list()

The reason you see vm.tags as empty list is because it's a link
and we don't fetch link by default, if you would like to fetch them in single
API call, you can use follow_link feature as follows:

my_vm = con.system_service().vms_service().list(search='name=<vm_name>', max=1, follow='tags')[0]


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