Proxmox API - Create VMs

fran_lub25

New Member
Jun 5, 2020
4
0
1
23
Thanks in advance for the help and sorry for my English .
I am working on my final year project and I have decided to use Proxmox VE as a virtualization environment. I have the need to create a virtual machine from my own web application but I don't know where to start very well. Could someone help me with the Proxmox API to create the virtual machine?
If possible I would like to use Node JS to create this machine
 
He's creating a web application, I doubt he wants to abandon npm.

Do you actually need to create the VM or do you just need to be able to start/stop it? If it's just being able to start/stop it, then the Proxmox API should be fine.

One of the things that's always bothered me about Proxmox is the lack of libvirt. You may be able to shoehorn it in and get it to work, but I think I would suggest going with another hypervisor that supports libvirt. I think you'll have an easier time.
 
https://www.npmjs.com/package/proxmox

https://pve.proxmox.com/wiki/Proxmox_VE_API

The npm package seems dead, i would go with something else.

Its also missing a lot of functions.

But you can implement the http request yourself of course.

https://pve.proxmox.com/pve-docs/api-viewer

POST /api2/json/nodes/{node}/qemu/{vmid}/status/start



Thank you very much for your answer and I will keep it in mind. I have reviewed the API documentation before but I am not able to find or understand how to create a virtual machine with it. on the other hand in the npm package there doesn't seem to be anything related to creating machines either
 
He's creating a web application, I doubt he wants to abandon npm.

Do you actually need to create the VM or do you just need to be able to start/stop it? If it's just being able to start/stop it, then the Proxmox API should be fine.

One of the things that's always bothered me about Proxmox is the lack of libvirt. You may be able to shoehorn it in and get it to work, but I think I would suggest going with another hypervisor that supports libvirt. I think you'll have an easier time.



Thanks for your answer.
I need to create machines, it is not just for me to turn them on and off. If you switch to another hypervisor, which one do you recommend?
 
There is litterly a step by step manual for lxc container creation, it can be applied for kvm with some small changes.

The proxmox gui uses the same api, so everything proxmox gui does can be done by api.

Just install tcpdump on the hypervisor and filter the gui api calls. You can then play around with the gui to see how its done.
 
There is litterly a step by step manual for lxc container creation, it can be applied for kvm with some small changes.

The proxmox gui uses the same api, so everything proxmox gui does can be done by api.

Just install tcpdump on the hypervisor and filter the gui api calls. You can then play around with the gui to see how its done.

This comment does help me, thank you very much.
I hope I understand you well, you mean that using tcpdump I can see the calls made by the proxmox interface to the API?
 
There is litterly a step by step manual for lxc container creation, it can be applied for kvm with some small changes.

The proxmox gui uses the same api, so everything proxmox gui does can be done by api.

Just install tcpdump on the hypervisor and filter the gui api calls. You can then play around with the gui to see how its done.

I take it back, the API shows some nice POST parameters that I hadn't noticed before:

https://pve.proxmox.com/pve-docs/api-viewer/index.html#/nodes/{node}/qemu

Combined with your LXC wiki link demoing curl encoding the POST body: https://pve.proxmox.com/wiki/Proxmox_VE_API, he should be able to pull it off.

I hope I understand you well, you mean that using tcpdump I can see the calls made by the proxmox interface to the API?

Yes, but that's probably an unnecessary step. Between the wiki link above (specifically the curl section) and playing with the parameters in my qemu API link, you should be able to trial-and-error your way through it.

FYI, be sure to click "POST" at the top. I've somehow never noticed that and always thought the API only supported GET requests. :oops:

1591314796630.png

Whoops! That's embarrasing!
 
This comment does help me, thank you very much.
I hope I understand you well, you mean that using tcpdump I can see the calls made by the proxmox interface to the API?

Yes you could also use the chrome developer tools, all api request are logged in the network window.
 
One of the things that's always bothered me about Proxmox is the lack of libvirt.

lol. Proxmox VE is a full libvirt replacement and can actually do much much more, as it's a fully integrated distribution, not a simple VM runner wrapper.

In general, it should be somewhat obvious that any projects' backend can at least do as much as their GUI provides...
Some proprietary Projects may try to lock their API down, i.e., no documentation, frequent changes and some client profiling but even that can always be circumvented depending on how much work you put in - it's just bits after all.

But, we are fully open source, and document the whole API as linked above and if that still is missing something you got the whole source code here: https://git.proxmox.com/
For example the VM create wizard: https://git.proxmox.com/?p=pve-mana...bf3cccbfb48a934e4de86f28a4ae01e3;hb=HEAD#l234
 

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!