Proxmox VPE API - IP Configuration Failed

itsgitz

New Member
Dec 20, 2019
8
1
3
25
Hello everyone,

I need help please. So, today I've been wrote script for update ip configuration using Proxmox VPE APi. I've read this the documentation https://pve.proxmox.com/pve-docs/api-viewer/index.html. From the parameter explanation, we can add the ip configuration with ipconfig[n]. It seems that script successfully hit the API (HTTP 200 OK) but this return null and the configuration is doesn't apply on cloud-init. I'm using PHP, so here the example of script:


PHP:
Array
(
    [ipconfig0] => Array
        (
            [gw] => 123.123.123.1
            [ip] => 123.123.123.250/24
        )

)


METHOD - PUT

return null


HTTP/1.1 200 OK
Cache-Control: max-age=0
Connection: Keep-Alive
Connection: Keep-Alive
Date: Fri, 20 Dec 2019 08:38:42 GMT
Pragma: no-cache
Server: pve-api
Content-Length: 13
Content-Type: application/json;charset=UTF-8
Expires: Fri, 20 Dec 2019 08:38:42 GMT

{"data":null}
 
Yes, you can do that when using CloudInit.

This is a format string, so it mustn't be an array but a comma separated string:

In your example the payload you post is:
Code:
Array
(
    [ipconfig0] => "ip=123.123.123.250/24,gw=123.123.123.1"
)

Further you could want to also post the config digest along (which you get from a reading GET call to the config), this avoids that you overwrite changes from other (API) user modifying the config between you reading it and writing it again. I mean, if this API is the real source of truth you may not care about that you possibly overwrite some others changes to ipconfig0 in between, so just an FYI.
 
  • Like
Reactions: itsgitz
Yes, you can do that when using CloudInit.

This is a format string, so it mustn't be an array but a comma separated string:

In your example the payload you post is:
Code:
Array
(
    [ipconfig0] => "ip=123.123.123.250/24,gw=123.123.123.1"
)

Further you could want to also post the config digest along (which you get from a reading GET call to the config), this avoids that you overwrite changes from other (API) user modifying the config between you reading it and writing it again. I mean, if this API is the real source of truth you may not care about that you possibly overwrite some others changes to ipconfig0 in between, so just an FYI.


Oh, I thought ip and gw are array. Well, I'll try to use comma separated.
 
OK, naturally the PHP apiclient library abstracts the path slightly (internally those are prefixed with "/api2/{format-type}/", where {format-type} can be json, or extjs, or the like, and behavior differs slightly between those types, thus I ask).

Can you tell me which PHP PVE-API client implementation you're using?
 
Oh, I thought ip and gw are array. Well, I'll try to use comma separated.

Yeah, the [] brackets could understandably lead one to think that, but in those context they denote if something is optional.
 
OK, naturally the PHP apiclient library abstracts the path slightly (internally those are prefixed with "/api2/{format-type}/", where {format-type} can be json, or extjs, or the like, and behavior differs slightly between those types, thus I ask).

Can you tell me which PHP PVE-API client implementation you're using?


I'm using ProxmoxAddon from WHMCS. For now, I can configure ip with comma separated to Proxmox API.
Thank you Thomas.
 
  • Like
Reactions: t.lamprecht

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!