theforeman / foreman_fog_proxmox

Foreman plugin to add Proxmox compute resource based on fog-proxmox gem
GNU General Public License v3.0
106 stars 31 forks source link

Create Container no valid ipv4 network confguration #97

Closed jacac closed 4 years ago

jacac commented 5 years ago

Create host as a LXC container fails with invalid format - value does not look like a valid ipv4 network configuration. When adding the network prefix like 192.168.1.100/24 it works.

To Reproduce Steps to reproduce the behavior:

  1. Create subnet with GW and and network prefix
  2. Go to 'Host -> Create Host.'
  3. Click on 'Virtual Machine' -> Select Type LXC container
  4. Under interface edit the default one
  5. Select the subnet created before
  6. Add IPv4 adress in the form off 192.168.10.100

Expected behavior If subnet is selected it should grap the information from the subnet to set GW and network prefix. If no subnet is selected an option needs to be available to add GW and network prefix. This network prefix should not be added to the host IP field in the foreman DB. Otherwise it breaks the endpoint for Cloud-Init userdata endpoint (https://github.com/theforeman/foreman_userdata ) which request userdata by host IP without the prefix.

Screenshots image

tedkozma commented 5 years ago

Confirmed, observed the same behaviour.

tristanrobert commented 4 years ago

Look at PVE API specification at path: /nodes/{node}/lxc/{vmid}/config and PUT verb: net[n]: (IPv4/CIDR|dhcp|manual). In your case only IPv4/CIDR is valid.

jacac commented 4 years ago

@tristanrobert You are correct on the IP spec for Proxmox. This is not the issue. The issue is that Foreman does not expect you to store the IP this way. If you look at the Nic table in the Foreman DB, the IP field only allows 15 characters to be stored. Which would not work for IPs like xxx.xxx.xxx.xxx/xx. The Nic table has other columns like attrs or compute_attributes which could allow to store the prefix. If we could add another field for the LXC container to enter the prefix and store this separately, But combine those attributes when talking to Proxmox to create or update the container.

Apologize for the late reply...

tristanrobert commented 4 years ago

Thank you @jacac for your detailed issue. I understand now. You are right. It needs a fix. I suggest not to set Ipv4 foreman field with CIDR format. I suggest to add fields in NIC proxmox part of the form: DHCP (default) or static and when it is static you can spécify the CIDR suffix and the IP gateway.

jacac commented 4 years ago

@tristanrobert Could you give me a short introduction how the process is from the the form post to DB insert to Proxmox post. I'm not a Ruby programmer but maybe could figure it out based on your code.

tristanrobert commented 4 years ago

Fixed in 0.9.4