Bug 1349857

Summary: <link> element is not parsed
Product: [oVirt] ovirt-engine-sdk-java Reporter: Petr Balogh <pbalogh>
Component: GeneralAssignee: Ondra Machacek <omachace>
Status: CLOSED CURRENTRELEASE QA Contact: movciari
Severity: medium Docs Contact:
Priority: unspecified    
Version: 4.0.0.Alpha10CC: bugs, juan.hernandez, lsvaty, mperina, oourfali, pbalogh
Target Milestone: ovirt-4.0.2Flags: rule-engine: ovirt-4.0.z+
rule-engine: planning_ack+
juan.hernandez: devel_ack+
lsvaty: testing_ack+
Target Release: 4.0.0.Alpha11   
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: 2016-08-17 14:44:48 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 Petr Balogh 2016-06-24 11:48:57 UTC
Description of problem:

If I get the object of the entity VM. It has disks attribute, but it contains empty list. 

We have the usecase, when we need to get for the specific entity like VM all its snapshots for example or for DC all its storagedomains.

We would like to use also method followLink which we cannot in this case.

How reproducible:
Get entity of VM and you have empty list of snapshots for example

Steps to Reproduce:
Vm vm = vms_service.list().send().vms().get(0)
vm.disks() returns empty list


So in this case, it's blocker for QA start to test this version of java SDK.

Comment 1 Juan Hernández 2016-06-24 13:32:56 UTC
I understand that following links would be easier, but listing the disks of the VM is still possible, using the "list" method of the corresponding service:

---8<---
// Get the reference to the "vms" service:
VmsService vmsService = connection.systemService().vmsService();

// Find the virtual machine:
Vm vm = vmsService.list().search("name=myvm").send().vms().get(0);

// Locate the service that manages the virtual machine, as that
// is where the action methods are defined:
VmService vmService = vmsService.vmService(vm.id());

// Locate the service that manages the disks of the virtual machine:
VmDisksService disksService = vmService.disksService();

// Retrieve the list of disks, and print them:
List<Disk> disks = disksService.list().send().disks();
for (Disk disk : disks) {
  System.out.println(disk.id());
}
--->8---

Can't you do this while we implement "followLinks"?

Comment 2 Juan Hernández 2016-06-24 13:54:44 UTC
There is a complete example of how to list the disks of a virtual machine here:

  https://github.com/oVirt/ovirt-engine-sdk-java/blob/master/sdk/src/test/java/org/ovirt/engine/sdk4/examples/ListVmDisks.java

Comment 3 Petr Balogh 2016-06-27 17:46:51 UTC
Hi,

problem is, that we have the method which takes as parameter only entity (e.g. vm), and link which could be for example "disks".  In this case we don't know from which service was the entity created.

In this way, it's not possible when we know only entity.  But what we can do I think is create some wrapper for this java entity which will store service from which was the element created?

Or do you know some better approach?

Thanks

Comment 4 Juan Hernández 2016-06-28 06:54:46 UTC
I'd suggest that you consider changing that method so that instead of receiving the entity as parameter it receives the service. That way you can use the service directly. You can also use the entity, if required, as it is a matter of calling the "get" method of the service. And you can also use the relationships, as the service has one method for each.

Comment 5 Red Hat Bugzilla Rules Engine 2016-06-29 11:56:21 UTC
This bug report has Keywords: Regression or TestBlocker.
Since no regressions or test blockers are allowed between releases, it is also being identified as a blocker for this release. Please resolve ASAP.

Comment 6 Oved Ourfali 2016-06-29 12:00:31 UTC
Juan - based on Comment #4, do we still have what to fix?
Anyhow, as a workaround was suggestion in that comment this isn't a test blocker as well, so removing that.

Comment 7 Juan Hernández 2016-06-29 12:57:31 UTC
Yes, we will add support to use the "followLinks" for sub-collections. That means that the user will be able to do something like this:

---8<---
// Get the reference to the "vms" service:
VmsService vmsService = connection.systemService().vmsService();

// Find the virtual machine:
Vm vm = vmsService.list().search("name=myvm").send().vms().get(0);

// Follow the link to the collection of disks:
List<Disk> disks = connection.followLink(vm.disks());
for (Disk disk : disks) {
  System.out.println(disk.id());
}
--->8---

However, this will be an alternative (and simpler) mechanism, the primary mechanism to access collections is still the one described in comment 1.

Comment 8 Red Hat Bugzilla Rules Engine 2016-07-01 10:21:44 UTC
Target release should be placed once a package build is known to fix a issue. Since this bug is not modified, the target version has been reset. Please use target milestone to plan a fix for a oVirt release.