MrKampf / proxmoxVE

The is a PHP 8 ProxmoxVe API client. With it you can easily and quickly retrieve information from your Proxmox server or cluster.
GNU General Public License v3.0
51 stars 26 forks source link

start()->post() is required to start a VM #17

Closed jcheron closed 2 years ago

jcheron commented 2 years ago

Describe the bug Calling the start or shutdown methods has no effect on the VM. No POST request is executed to https://pve.proxmox.com/pve-docs/api-viewer/#/nodes/{node}/qemu/{vmid}/status/start.

To Reproduce

        $proxmox = new PVE($serverUrl, $rootUser, $rootPwd, $port,'pam',true);
        $proxmox->nodes()->node($parNodeName)->qemu()->vmId($vmId)->status()->start();

Expected behavior A request is sent to https://pve.proxmox.com/pve-docs/api-viewer/#/nodes/{node}/qemu/{vmid}/status/start The VM starts.

Screenshots

*   Trying xx.xxx.xxx.xx:8006...
* Connected to serverURL (xx.xxx.xxx.xx) port 8006 (#0)
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*  CAfile: C:\xampp8.012\apache\bin\curl-ca-bundle.crt
*  CApath: none
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* ALPN, server did not agree to a protocol
* Server certificate:
*  subject: OU=PVE Cluster Node; O=Proxmox Virtual Environment; CN=PAR-XXXXX.xxxxx.xx
*  start date: Nov 19 14:50:42 2020 GMT
*  expire date: Nov 19 14:50:42 2022 GMT
*  issuer: CN=Proxmox Virtual Environment; OU=3038d24c-7779-41d5-9e4d-6ca31f302472; O=PVE Cluster Manager CA
*  SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway.
> POST /api2/json/access/ticket HTTP/1.1
Host: serverURL:8006
User-Agent: GuzzleHttp/7
Content-Type: application/x-www-form-urlencoded
Accept: application/json
Accept-Encoding: gzip
Content-Length: 41

* old SSL session ID is stale, removing
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Cache-Control: max-age=0
< Connection: close
< Connection: Keep-Alive
< Date: Thu, 13 Jan 2022 11:20:12 GMT
< Pragma: no-cache
< Server: pve-api-daemon/3.0
< Content-Encoding: gzip
< Content-Length: 697
< Content-Type: application/json;charset=UTF-8
< Expires: Thu, 13 Jan 2022 11:20:12 GMT
<
* Closing connection 0

Desktop :

Server (Proxmox server):

MrKampf commented 2 years ago

Hi,

$proxmox = new PVE($serverUrl, $rootUser, $rootPwd, $port,'pam',true);
$proxmox->nodes()->node($parNodeName)->qemu()->vmId($vmId)->status()->start()->post();

I have tested this on my test code, and it's work, use post or other function behind. In next updates i intergrade default method's when only one is available.

jcheron commented 2 years ago

Indeed, if I don't call the post, it doesn't post... I expected the start method to send a post request directly to the api.

MrKampf commented 2 years ago

Currently it is not in yet because there are functions that have e.g. get, post and put. Then the question is how to solve it there. For functions where there is only one, I will add this. With the others I must still think of something clever how I do that so that one recognizes approximately what is needed / required.