API Issues when using cloudinit

pascalku

Member
Mar 5, 2020
33
0
11
24
Hey there,

I am using the api to create and manage my virtual machines. Whenever I am going to update the given cloud-init settings, username and password are working well as expected.

Now I want to set IPv4 Settings. So I am going to set put it to .../qemu/<id>/config as a parameter "ipconfig0" with the value "ip=192.168.25.32/32,gw=192.168.0.1".

I expect that the given setup will change the ipv4 address of cloud-inits "net0" like it is whenever I am going to change it trough the webinterface but using the api, it won't change anything.

Hopefully you are able to help me.
 
Please post the output of pveversion -v.
 
Code:
Linux pve 5.3.10-1-pve #1 SMP PVE 5.3.10-1 (Thu, 14 Nov 2019 10:43:13 +0100) x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
root@pve:~# pveversion -v
proxmox-ve: 6.1-2 (running kernel: 5.3.10-1-pve)
pve-manager: 6.1-3 (running version: 6.1-3/37248ce6)
pve-kernel-5.3: 6.0-12
pve-kernel-helper: 6.0-12
pve-kernel-5.3.10-1-pve: 5.3.10-1
ceph-fuse: 12.2.11+dfsg1-2.1+b1
corosync: 3.0.2-pve4
criu: 3.11-3
glusterfs-client: 5.5-3
ifupdown: 0.8.35+pve1
ksm-control-daemon: 1.3-1
libjs-extjs: 6.0.1-10
libknet1: 1.13-pve1
libpve-access-control: 6.0-5
libpve-apiclient-perl: 3.0-2
libpve-common-perl: 6.0-9
libpve-guest-common-perl: 3.0-3
libpve-http-server-perl: 3.0-3
libpve-storage-perl: 6.1-2
libqb0: 1.0.5-1
libspice-server1: 0.14.2-4~pve6+1
lvm2: 2.03.02-pve3
lxc-pve: 3.2.1-1
lxcfs: 3.0.3-pve60
novnc-pve: 1.1.0-1
proxmox-mini-journalreader: 1.1-1
proxmox-widget-toolkit: 2.1-1
pve-cluster: 6.1-2
pve-container: 3.0-14
pve-docs: 6.1-3
pve-edk2-firmware: 2.20191002-1
pve-firewall: 4.0-9
pve-firmware: 3.0-4
pve-ha-manager: 3.0-8
pve-i18n: 2.0-3
pve-qemu-kvm: 4.1.1-2
pve-xtermjs: 3.13.2-1
qemu-server: 6.1-2
smartmontools: 7.0-pve2
spiceterm: 3.1-1
vncterm: 1.6-1
zfsutils-linux: 0.8.2-pve2
root@pve:~#
 
Do you use pvesh to set the value or something else? What's the return value?
 
I am accessing the proxmox api using a thrid party java implementation. It is a put request like described in your actual api documentations.

Could you tell me how to do this using pvesh?
 
pvesh set nodes/<node>/qemu/<vmid>/config --ipconfig <value>
 
So as a value I cloud by example use this?

--ipconfig ip=192.168.125.25/32,gw=192.168.0.1
 
Exactly. Does this work?
 
So, if I am using the command below, everything seems to be okay.

Code:
pvesh set nodes/pve/qemu/101/config --ipconfig0 ip=192.168.125.12/32,gw=192.168.0.1

But I don't do anything other not equivalent to this? I also do a PUT Request to the given path with the body param "ipconfig0" and the given value?
 
Do you pass the ticket as well? As asked previosuly, what's the return value you get when it does not work?
 
I think I found the problem. Is it possible to send a json request body? My current api uses "ipconfig0=ip=192.168.125.12/32,gw-192.168.0.1&..." as the request body :D
 
Set the content type accordingly and it should work. So application/json and pass the data as json.
 
Please post the output of qm cloudinit dump <vmid> network
 
Code:
root@pve:~# qm cloudinit dump 101 network
version: 1
config:
    - type: physical
      name: eth0
      mac_address: '2a:92:8a:9f:25:ae'
      subnets:
      - type: static
        address: '192.168.25.13'
        netmask: '255.255.0.0'
        gateway: '192.168.0.1'
    - type: nameserver
      address:
      - '192.168.0.1'
      search:
      - '<my-domain>.de'
 
The config looks ok, so it must be something in the VM. What OS is running in the VM?
 
The config looks ok, so it must be something in the VM. What OS is running in the VM?

I gave the following settings from outside:Bildschirmfoto 2020-04-13 um 01.00.51.png
and provided the following configuration (etc/cloud/cloud.cfg.d/custom-networking.cfg):
Bildschirmfoto 2020-04-13 um 01.03.23.png


now after a new cloud-init, the following happened:

Bildschirmfoto 2020-04-13 um 01.01.08.png
 

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!