Created attachment 1235529 [details] logs Description of problem: When trying to import a VM from an export domain, the attached snippet[1] failes with following stacktrace: Traceback (most recent call last): File "engine.py", line 38, in <module> cluster=import_cluster) File "build/bdist.linux-x86_64/egg/ovirtsdk4/services.py", line 21143, in import_ File "build/bdist.linux-x86_64/egg/ovirtsdk4/service.py", line 118, in _check_action File "build/bdist.linux-x86_64/egg/ovirtsdk4/reader.py", line 283, in read KeyError: u'html' shell returned 1 Version-Release number of selected component (if applicable): How reproducible: Steps to Reproduce: 1. Export a VM 2. Remove the VM 3. Attempt to import it using the attached snippet[1] Please note that the snippet will use the first export domain returned and first VM exported to it, the snippet also attempts to import the VM to an SD named 'slow_domain' Actual results: Fails with the following stacktrace: Traceback (most recent call last): File "engine.py", line 38, in <module> cluster=import_cluster) File "build/bdist.linux-x86_64/egg/ovirtsdk4/services.py", line 21143, in import_ File "build/bdist.linux-x86_64/egg/ovirtsdk4/service.py", line 118, in _check_action File "build/bdist.linux-x86_64/egg/ovirtsdk4/reader.py", line 283, in read KeyError: u'html' shell returned 1 Expected results: VM should be imported Additional info: [1] - the attached import_vm.py
Created attachment 1235530 [details] snippet
Adding relevant exceptions from log: Server.log: 2016-12-27 16:57:30,191+02 ERROR [io.undertow.request] (default task-30) UT005023: Exception handling request to /ovirt-engine/api/v4/storagedomains/448c56e0-486d-45b8-be5d-55170c2281fd/vms/b3b6add4-c331-4e5f-a145-47609c3bd24b/import: java.lang.RuntimeException: javax.ws.rs.WebApplicationException: HTTP 500 Internal Server Error at io.undertow.servlet.spec.RequestDispatcherImpl.forwardImpl(RequestDispatcherImpl.java:245) [undertow-servlet-1.4.0.Final.jar:1.4.0.Final] ... Caused by: java.lang.NullPointerException at org.ovirt.engine.api.restapi.resource.validation.UsageFinder.processNodeName(UsageFinder.java:82) [restapi-jaxrs.jar:] at org.ovirt.engine.api.restapi.resource.validation.UsageFinder.getLinkPrefix(UsageFinder.java:77) [restapi-jaxrs.jar:] engine.log: 2016-12-27 17:01:24,905+02 ERROR [org.ovirt.engine.api.restapi.resource.validation.IOExceptionMapper] (default task-62) [] Exception: java.io.IOException: javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"id"). Expected elements are (none) at org.ovirt.engine.api.restapi.xml.JAXBProvider.readFrom(JAXBProvider.java:199) [restapi-jaxrs.jar:] at org.ovirt.engine.api.restapi.xml.JAXBProvider.readFrom(JAXBProvider.java:161) [restapi-jaxrs.jar:] .. Caused by: javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"id"). Expected elements are (none) at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:740)
Note that this can be avoided using a slightly different script. Currently this is what the script is doing: vm_service.import_(storage_domain=slow_domain, vm=export_vm, cluster=import_cluster) The 'slow_domain', 'export_vm' and 'import_cluster' variables contain the complete representation of the storage domain, the virtual machine and the cluster. That means that the SDK will send to the server the complete representations of those objects. But the server only needs the identifier of the storage domain, the name of the virtual machine, and the identifier of the cluster. So it would be better, for performance, to send only what it is required: vm_service.import_( storage_domain=types.StorageDomain( id=slow_domain.id ), vm=types.Vm( name=export_vm.name ), cluster=types.Cluster( id=import_cluster.id ) ) That results in a simplified request: POST /ovirt-engine/api/storagedomains/122/import <action> <storage_domain id="..."/> <cluster id="..."/> <vm> <name>myvm</name> </vm> </action> That is 173 bytes, versus the approx 8 KiB that the current approach. Benny already tried this alternative. It works correctly. Anyhow, the server shouldn't fail to parse that request, so this needs to be fixed anyhow.
Benny, what version of the engine were you using for this test exactly? I guess it was a development environment. What git commit?
(In reply to Juan Hernández from comment #4) > Benny, what version of the engine were you using for this test exactly? I > guess it was a development environment. What git commit? I believe it was this commit: 818841777e4547a1b0a4c7771a192b843bf282df
The problem is related to the representation of the 'sso' attribute of the virtual machine. The SDK sends it as follows: <sso> <methods> <method> <id>guest_agent</id> </method> </methods> </sso> But the engine expects it as follows: <sso> <methods> <method id="guest_agent"/> </methods> </sso> I am not sure yet if this is a problem in the SDK or in the engine, I am checking it.
The bug is in the SDK, the right syntax is the one accepted by the server. I am moving the bug to the SDK product.
4.0.6 has been the last oVirt 4.0 release, please re-target this bug.
Verified on ovirt-engine-sdk-python (4.1.0)