Problem with following host link for vm list using Java SDK.

When trying to do VM list using the 4.2.4 Java SDK against a 4.2.4 engine, I am getting an error while trying to follow the host link to get host info. Any suggestions on fixing this? List<Vm> vms = vmsService.list() .follow("host") .send().vms(); Exception in thread "main" org.ovirt.engine.sdk4.Error: Failed to send request at org.ovirt.engine.sdk4.internal.HttpConnection.send(HttpConnection.java:255) at org.ovirt.engine.sdk4.internal.HttpConnection.send(HttpConnection.java:229) at org.ovirt.engine.sdk4.internal.services.VmsServiceImpl$ListRequestImpl.send(VmsServiceImpl.java:563) at org.ovirt.engine.sdk4.internal.services.VmsServiceImpl$ListRequestImpl.send(VmsServiceImpl.java:477) at com.foo.ovirt.test.VMList.main(VMList.java:59) Caused by: org.ovirt.engine.sdk4.Error: The response content type 'text/html;charset=UTF-8' isn't the expected XML at org.ovirt.engine.sdk4.internal.HttpConnection.checkContentType(HttpConnection.java:287) at org.ovirt.engine.sdk4.internal.HttpConnection.send(HttpConnection.java:251) ... 4 more

On 07/12/2018 11:25 PM, dchambers@bugfixer.net wrote:
When trying to do VM list using the 4.2.4 Java SDK against a 4.2.4 engine, I am getting an error while trying to follow the host link to get host info. Any suggestions on fixing this?
List<Vm> vms = vmsService.list() .follow("host") .send().vms();
Check the following example: https://github.com/oVirt/ovirt-engine-sdk-java/blob/master/sdk/src/test/java... If you need host you just need to do: Host host = connection.followLink(vm.host());
Exception in thread "main" org.ovirt.engine.sdk4.Error: Failed to send request at org.ovirt.engine.sdk4.internal.HttpConnection.send(HttpConnection.java:255) at org.ovirt.engine.sdk4.internal.HttpConnection.send(HttpConnection.java:229) at org.ovirt.engine.sdk4.internal.services.VmsServiceImpl$ListRequestImpl.send(VmsServiceImpl.java:563) at org.ovirt.engine.sdk4.internal.services.VmsServiceImpl$ListRequestImpl.send(VmsServiceImpl.java:477) at com.foo.ovirt.test.VMList.main(VMList.java:59) Caused by: org.ovirt.engine.sdk4.Error: The response content type 'text/html;charset=UTF-8' isn't the expected XML at org.ovirt.engine.sdk4.internal.HttpConnection.checkContentType(HttpConnection.java:287) at org.ovirt.engine.sdk4.internal.HttpConnection.send(HttpConnection.java:251) ... 4 more _______________________________________________ Users mailing list -- users@ovirt.org To unsubscribe send an email to users-leave@ovirt.org Privacy Statement: https://www.ovirt.org/site/privacy-policy/ oVirt Code of Conduct: https://www.ovirt.org/community/about/community-guidelines/ List Archives: https://lists.ovirt.org/archives/list/users@ovirt.org/message/IGLEJESNPJRX3P...

That is the way I have been doing it. In fact I did separate follow calls for a lot of the objects I needed, but once you get to several hundred VMs, those multiple calls become very time consuming. By using the: List<Vm> vms = vmsService.list() .follow("host") .send().vms(); for several objects like disk_attachements.disk,cluster,nics, I was able to pull the data I needed for a few hundred VM's in a fraction of the time that is was taking to do each one separately. It went form about 4 minutes to pul all tghe data to around 30 seconds. I just can't seem to get Host to work. Also i have noticed that if I use the follow command like the example above, I can not use it on individual objects later. Example: If i call: List<Vm> vms = vmsService.list() .follow("disk_attachments.disk,cluster,nics.vnic_profile").send().vms(); then later in my code I try to call connection.followLink(vm.host()); I get the error: Host: Exception in thread "main" java.lang.IllegalArgumentException: wrong number of arguments at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.ovirt.engine.sdk4.internal.HttpConnection.followLink(HttpConnection.java:200) at com.maxta.ovirt.test.MaxtaVMList.main(MaxtaVMList.java:74)
participants (2)
-
dchambers@bugfixer.net
-
Ondra Machacek