Hello,
I have created a client area to automatically create a vm when a client order one. The code is written in php and I am using the zzantares proxmox php library.
Here is the code of the creation in the proxmox side of my vm :
And my problem is in the 3rd part of the vm creation when it is updatting the vm. I don't why it isn't working ; the cloning of the vm then the resizing it's also working but the updat it's not working.
If you could find the error I will be very happy.
Thank you very much.
Jean B.
I have created a client area to automatically create a vm when a client order one. The code is written in php and I am using the zzantares proxmox php library.
Here is the code of the creation in the proxmox side of my vm :
PHP:
public function createVM(string $id_service, int $userid, int $image, string $cores, string $ram, string $space, string $address_ip, int $server_id){
$this->ConnectProxmox($server_id);
$this->password = $this->RootVPS();
$vm_id = $this->proxmox->get('/cluster/nextid');
$vm_id = $vm_id['data'];
$this->user->userInfo($userid);
if($image == '8000'){
$this->template = '8000';
} else if($image =='9000'){
$this->template == '9000';
} else {
$this->template = '8000';
}
if($vm_id != 'null'){
$this->deleteVM($vm_id, $server_id);
}
$this->PVEIPs->getIPs($id_service, $address_ip);
$this->nextId($server_id);
$info = [
'newid' => $this->vmid,
'full' => '1',
'storage' => 'local-lvm',
'description' => 'Client : '.$this->user->mail,
'vmid' => $this->template
];
$this->createInstance = $this->proxmox->create('/nodes/'.$this->proxmoxkey->name_api.'/qemu/'.$this->template.'/clone', $info);
$resize = [
'vmid' => $this->vmid,
'disk' => 'scsi0',
'size' => $space.'G'
];
$this->update = $this->proxmox->set('/nodes/'.$this->proxmoxkey->name_api.'/qemu/'.$this->vmid.'/resize', $resize);
sleep(10);
$update = [
'node' => $server_id,
'vmid' => $this->vmid,
'cipassword' => '123456',
'ciuser' => 'root',
'sockets' => '1',
'cores' => $cores,
'memory' => $ram,
'agent' => '1',
'nameserver' => $this->PVEIPs->dns,
'name' => $id_service,
'ipconfig0' => 'ip='.$this->PVEIPs->address_ip.'/'.$this->PVEIPs->subnet_mask.',gw='.$this->PVEIPs->gateway.'',
'net0' => 'virtio,bridge=vmbr0,firewall=0,macaddr='.$this->PVEIPs->mac.',tag='.$this->PVEIPs->vlan_tag.''
];
$this->update = $this->proxmox->create('/nodes/'.$this->proxmoxkey->name_api.'/qemu/'.$this->vmid.'/config', $update);
$this->cloudTable->updateInstall($id_service, $this->vmid, $userid, $this->template, $this->PVEIPs->address_ip, $this->password);
}
And my problem is in the 3rd part of the vm creation when it is updatting the vm. I don't why it isn't working ; the cloning of the vm then the resizing it's also working but the updat it's not working.
If you could find the error I will be very happy.
Thank you very much.
Jean B.