Get error with using API

a_user

New Member
Oct 20, 2020
5
0
1
When using the REST API to control VMs, how would I get the status and error message associated with the task that gets spawned? For example, if I call "start" the response is immediate (success) but I can see in the web portal that the task errored out.
 
Hey,

when you start a task you get the id of that started task in the response(it looks something like this UPID:<node>:000026BC:0001AE8B:5F8FD634:vzdump:<vmid>:root@pam:), with that id you can now get
the log with: /api2/json/nodes/<nodename>/tasks/<id_from_earlier>/log
and
the current status with: /api2/json/nodes/<nodename>/tasks/<id_from_earlier>/status
 
  • Like
Reactions: a_user
I get the following for the current status: {"data":{"node":"...","status":"stopped","upid":"...","pstart":227925323,"exitstatus":"start failed: QEMU exited with code 1","user":"root@pam","type":"qmstart","id":"101","pid":52013,"starttime":1603262483}}
What would be the best way to check for error?
Seems like I would do 'exitstatus' != OK?

Also, what is the "status" field referring to?
 
status is whether the task is (still) running, and exitstatus indicates whether it ran successfully. if you look at the task index, exitstatus is unfortunately named 'status' there..
 
  • Like
Reactions: a_user