Bug 1658156

Summary: tags property of Vm object returns empty list even though tags are assigned to the VM
Product: [oVirt] ovirt-engine-sdk-python Reporter: Jan Zmeskal <jzmeskal>
Component: CoreAssignee: Ondra Machacek <omachace>
Status: CLOSED NOTABUG QA Contact: Lukas Svaty <lsvaty>
Severity: low Docs Contact:
Priority: unspecified    
Version: 4.2.8CC: bugs, juan.hernandez
Target Milestone: ---   
Target Release: ---   
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: 2018-12-11 12:19:26 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 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]