How to ensure that virtual machine was created?

Egor

New Member
Nov 21, 2016
28
1
3
32
In my code, right after I send POST request to create virtual machine, I am trying to get its configuration (or status): "pvesh get /nodes/pve/qemu/101/config"

This command results in InternalServerError:
upload_2017-3-9_19-42-25.png

If I do a 2 second sleep before making a request for this config, then I don't get this error.
What is the right way to check that virtual machine was created and I can perform operations on it?
 
In my code, right after I send POST request to create virtual machine, I am trying to get its configuration (or status): "pvesh get /nodes/pve/qemu/101/config"

This command results in InternalServerError:
View attachment 4889

If I do a 2 second sleep before making a request for this config, then I don't get this error.
What is the right way to check that virtual machine was created and I can perform operations on it?

long running jobs (like creating guests) return a "UPID", which represents the task worker that was spawned for that job. you can query the status (and output) using the API (just like the web interface does when it displays those log / status dialogues):

Code:
pvesh create /nodes/NODENAME/qemu -vmid 123456
200 OK
UPID:NODENAME:0000537D:00060745:58C2590F:qmcreate:123456:root@pam:

Code:
pvesh get /nodes/NODENAME/tasks/UPID:NODENAME:0000537D:00060745:58C2590F:qmcreate:123456:root@pam:/status
200 OK
{
   "exitstatus" : "OK",
   "id" : "123456",
   "node" : "NODENAME",
   "pid" : 21373,
   "pstart" : 395077,
   "starttime" : 1489131791,
   "status" : "stopped",
   "type" : "qmcreate",
   "upid" : "UPID:NODENAME:0000537D:00060745:58C2590F:qmcreate:123456:root@pam:",
   "user" : "root@pam"
}
 
  • Like
Reactions: Egor

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!