PROXMOX API

ValentinR

New Member
May 3, 2019
2
0
1
22
Bonjour,

Je cherche actuellement un moyen de créer des KVM sur proxmox en php.

Exemple : Un client commande un VPS un fois qu'il a payer son serveur s'installe sur nos machines avec la méthode KVM et non VZ.

Avez-vous moyen de m'expliquer comment je pourrais faire.

Cordialement,
 
please write in english, so that all can help and understand you.

i posted it in google translate:
Hello,

I am currently looking for a way to create KVM on proxmox in php.

Example: A customer orders a VPS once he has to pay his server settles on our machines with the KVM method and not VZ.

Can you explain to me how I could do it?

Regards,

see https://pve.proxmox.com/wiki/Proxmox_VE_API for information about the api
 
Hello,

I have already done some research on the doc, but when I create the KVM (qemu) I do not know how I can do to finish the installation of Debian KVM.

Regards.
 
I have already done some research on the doc, but when I create the KVM (qemu) I do not know how I can do to finish the installation of Debian KVM.

At least two methods come to my mind:
- use a template and just clone this. Best would be to use cloudinit to customize network settings (easiest method)
- use Debian Preseed to install via netboot (most control)

You can find articles in the PVE-wiki for cloning, the preseed stuff is plain debian and has nothing do to with PVE, so you can find it in the Debian Wiki.
 
I simply have a template of the OS then clone it via the API.
Then configure via API eg network disk size memory etc. all set cloud-int via API and start it

It all works great
 
Here is an working Example for PHP:
PHP:
        $vmConfigArray = array('vmid' => $next_id,
                      'agent' => $data['general']['qemu_guest_agent'],
                      'onboot' => $data['general']['start_on_boot'],
                      'cores' => $data['cpu']['cores'],
                      'cpu' => $data['cpu']['type'],
                      'kvm' => $data['cpu']['kvm'],
                      'numa' => $data['cpu']['numa'],
                      'sockets' => $data['cpu']['sockets'],
                      'cpulimit' => $data['cpu']['limit'],
                      'cpuunits' => $data['cpu']['units'],
                      'memory' => $memory_size,
                      'pool' => $data['general']['pool'],
                      'vga' => std,
                      'name' => $pendingTask['domain'],
                      'scsihw' => $data['disk']['controller_type'],
                      'storage' => $data['disk']['storage'],
                      $data['net']['controller_port'] => 'model='.$data['net']['type'].',bridge='.$data['net']['bridge'].',firewall=1,link_down=0,rate='.$rate_limit.$net_vlan,
                      $data['disk']['controller_port'] => 'file='.$data['disk']['storage'].':vm-'.$next_id.'-disk-1,backup=1,cache=writeback,discard=on,format='.$data['disk']['image'].',size='.$disk_size.'G');

        $createVM = $proxmox->create('/nodes/'.$serverDetails[hostname].'/qemu', $vmConfigArray);
 

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!