
Hi everybody, I'm trying to start a VM (using python sdk) asynchronously, but I obtain synchronous behaviour. The engine is RHEV-M version 3.4.1-0.31.el6ev. Here a snippet of code: --------------------------------------------------------- myvm = api.vms.get(name="VMNAME") retval = myvm.start(params.Action(async=True)) print ParseHelper.toXml(retval) --------------------------------------------------------- and this is what I get (retval): --------------------------------------------------------- <action> <async>true</async> <vm href="/api/vms/5aa66e96-5fdd-4562-9c7d-ae6f88e6805d" id="5aa66e96-5fdd-4562-9c7d-ae6f88e6805d"> [...cut..] </vm> <job href="/api/jobs/5c2326c7-f25c-432f-8848-c94e80dd173b" id="5c2326c7-f25c-432f-8848-c94e80dd173b"/> <status> <state>complete</state> </status> </action> --------------------------------------------------------- status of task is always "complete" and the operation take some time, few seconds to some tens of seconds (sync behaviour). Any ideas? Thanks in advance, Giulio

On 10/14/2014 01:04 PM, Giulio Casella wrote:
Hi everybody, I'm trying to start a VM (using python sdk) asynchronously, but I obtain synchronous behaviour. The engine is RHEV-M version 3.4.1-0.31.el6ev. Here a snippet of code:
--------------------------------------------------------- myvm = api.vms.get(name="VMNAME") retval = myvm.start(params.Action(async=True)) print ParseHelper.toXml(retval) ---------------------------------------------------------
and this is what I get (retval):
--------------------------------------------------------- <action> <async>true</async> <vm href="/api/vms/5aa66e96-5fdd-4562-9c7d-ae6f88e6805d" id="5aa66e96-5fdd-4562-9c7d-ae6f88e6805d"> [...cut..] </vm> <job href="/api/jobs/5c2326c7-f25c-432f-8848-c94e80dd173b" id="5c2326c7-f25c-432f-8848-c94e80dd173b"/> <status> <state>complete</state> </status> </action> ---------------------------------------------------------
status of task is always "complete" and the operation take some time, few seconds to some tens of seconds (sync behaviour).
Any ideas?
Thanks in advance, Giulio
The "async" parameter that you are passing to the REST API is only a hint. It means that *if* the action performed by the backend has associated async tasks then the REST API will not wait for them to finish. In this particular case, the action performed by the backend doesn't have async tasks, so the parameter is just ignored. -- Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta 3ºD, 28016 Madrid, Spain Inscrita en el Reg. Mercantil de Madrid – C.I.F. B82657941 - Red Hat S.L.

Thanks Juan, this clearify a lot of things. So starting a VM is always a synchronous task in the backend, isn't it? But in some condition (heavy load of hypervisors) this task takes long time (up to 20/30 seconds), not really suitable for sync tasks. Maybe I should submit a feature request... Ciao, gc Il 14/10/2014 16:53, Juan Hernandez ha scritto:
On 10/14/2014 01:04 PM, Giulio Casella wrote:
Hi everybody, I'm trying to start a VM (using python sdk) asynchronously, but I obtain synchronous behaviour. The engine is RHEV-M version 3.4.1-0.31.el6ev. Here a snippet of code:
--------------------------------------------------------- myvm = api.vms.get(name="VMNAME") retval = myvm.start(params.Action(async=True)) print ParseHelper.toXml(retval) ---------------------------------------------------------
and this is what I get (retval):
--------------------------------------------------------- <action> <async>true</async> <vm href="/api/vms/5aa66e96-5fdd-4562-9c7d-ae6f88e6805d" id="5aa66e96-5fdd-4562-9c7d-ae6f88e6805d"> [...cut..] </vm> <job href="/api/jobs/5c2326c7-f25c-432f-8848-c94e80dd173b" id="5c2326c7-f25c-432f-8848-c94e80dd173b"/> <status> <state>complete</state> </status> </action> ---------------------------------------------------------
status of task is always "complete" and the operation take some time, few seconds to some tens of seconds (sync behaviour).
Any ideas?
Thanks in advance, Giulio
The "async" parameter that you are passing to the REST API is only a hint. It means that *if* the action performed by the backend has associated async tasks then the REST API will not wait for them to finish. In this particular case, the action performed by the backend doesn't have async tasks, so the parameter is just ignored.
-- Giulio Casella giulio at di.unimi.it System and network manager Computer Science Dept. - University of Milano

On 10/15/2014 10:35 AM, Giulio Casella wrote:
Thanks Juan, this clearify a lot of things. So starting a VM is always a synchronous task in the backend, isn't it?
The REST API doesn't know if the action is sync or async before it is executed, only once it has been executed. In this particular case it looks like it is always sync, but I can't tell you for sure. Actually, it could be sync in some situations and async in others, and this can change from version to version.
But in some condition (heavy load of hypervisors) this task takes long time (up to 20/30 seconds), not really suitable for sync tasks. Maybe I should submit a feature request...
Yes, a RFE makes sense, please open it.
Il 14/10/2014 16:53, Juan Hernandez ha scritto:
On 10/14/2014 01:04 PM, Giulio Casella wrote:
Hi everybody, I'm trying to start a VM (using python sdk) asynchronously, but I obtain synchronous behaviour. The engine is RHEV-M version 3.4.1-0.31.el6ev. Here a snippet of code:
--------------------------------------------------------- myvm = api.vms.get(name="VMNAME") retval = myvm.start(params.Action(async=True)) print ParseHelper.toXml(retval) ---------------------------------------------------------
and this is what I get (retval):
--------------------------------------------------------- <action> <async>true</async> <vm href="/api/vms/5aa66e96-5fdd-4562-9c7d-ae6f88e6805d" id="5aa66e96-5fdd-4562-9c7d-ae6f88e6805d"> [...cut..] </vm> <job href="/api/jobs/5c2326c7-f25c-432f-8848-c94e80dd173b" id="5c2326c7-f25c-432f-8848-c94e80dd173b"/> <status> <state>complete</state> </status> </action> ---------------------------------------------------------
status of task is always "complete" and the operation take some time, few seconds to some tens of seconds (sync behaviour).
Any ideas?
Thanks in advance, Giulio
The "async" parameter that you are passing to the REST API is only a hint. It means that *if* the action performed by the backend has associated async tasks then the REST API will not wait for them to finish. In this particular case, the action performed by the backend doesn't have async tasks, so the parameter is just ignored.
-- Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta 3ºD, 28016 Madrid, Spain Inscrita en el Reg. Mercantil de Madrid – C.I.F. B82657941 - Red Hat S.L.
participants (2)
-
Giulio Casella
-
Juan Hernandez