Fix handling of CIDR values in warewulf.conf

- Fixes: #1541
- Fixes: #1594

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
Jonathon Anderson
2025-02-03 17:01:57 -07:00
parent 8088112c30
commit 2e1466fc7e
11 changed files with 520 additions and 192 deletions

View File

@@ -19,8 +19,10 @@ func Test_debugOverlay(t *testing.T) {
env := testenv.New(t)
defer env.RemoveAll()
env.ImportFile("etc/warewulf/warewulf.conf", "warewulf.conf")
env.ImportFile("etc/warewulf/nodes.conf", "nodes.conf")
env.ImportFile("var/lib/warewulf/overlays/debug/rootfs/tstruct.md.ww", "../rootfs/tstruct.md.ww")
env.Configure()
tests := []struct {
name string
@@ -86,11 +88,12 @@ data from other structures.
### Network
- Ipaddr:
- Ipaddr: 192.168.0.1
- IpCIDR: 192.168.0.1/24
- Ipaddr6:
- Netmask:
- Network:
- NetworkCIDR:
- Netmask: 255.255.255.0
- Network: 192.168.0.0
- NetworkCIDR: 192.168.0.0/24
- Ipv6: false
### DHCP

View File

@@ -0,0 +1 @@
ipaddr: 192.168.0.1/24

View File

@@ -29,6 +29,7 @@ data from other structures.
### Network
- Ipaddr: {{ .Ipaddr }}
- IpCIDR: {{ .IpCIDR }}
- Ipaddr6: {{ .Ipaddr6 }}
- Netmask: {{ .Netmask }}
- Network: {{ .Network }}

View File

@@ -152,7 +152,6 @@ option architecture-type code 93 = unsigned integer 16;
if exists user-class and option user-class = "iPXE" {
filename "http://192.168.0.1:9873/ipxe/${mac:hexhyp}?assetkey=${asset}&uuid=${uuid}";
} else {
if option architecture-type = 00:00 {
filename "/warewulf/undionly.kpxe";
}
@@ -166,7 +165,6 @@ if exists user-class and option user-class = "iPXE" {
filename "/warewulf/snponly.efi";
}
}
subnet 192.168.0.0 netmask 255.255.255.0 {
max-lease-time 120;
range 192.168.0.100 192.168.0.199;
@@ -201,7 +199,6 @@ option architecture-type code 93 = unsigned integer 16;
if exists user-class and option user-class = "iPXE" {
filename "http://192.168.0.1:9873/ipxe/${mac:hexhyp}?assetkey=${asset}&uuid=${uuid}";
} else {
if option architecture-type = 00:00 {
filename "/warewulf/undionly.kpxe";
}
@@ -215,7 +212,6 @@ if exists user-class and option user-class = "iPXE" {
filename "/warewulf/snponly.efi";
}
}
subnet 192.168.0.0 netmask 255.255.255.0 {
max-lease-time 120;
range 192.168.0.100 192.168.0.199;
@@ -278,7 +274,6 @@ dhcp-host=e6:92:39:49:7b:04,set:warewulf,node2,192.168.3.23,infinite
const host_exports string = `backupFile: true
writeFile: true
Filename: etc/exports
# This file is autogenerated by warewulf
/home 192.168.0.0/255.255.255.0(rw,sync)
/opt 192.168.0.0/255.255.255.0(ro,sync,no_root_squash)

View File

@@ -1,4 +1,4 @@
{{if $.Dhcp.Enabled -}}
{{ if $.Dhcp.Enabled -}}
# This file is autogenerated by warewulf
allow booting;
@@ -38,19 +38,21 @@ if substring (option vendor-class-identifier, 0, 9) = "PXEClient" {
if exists user-class and option user-class = "iPXE" {
filename "http://{{$.Ipaddr}}:{{$.Warewulf.Port}}/ipxe/${mac:hexhyp}?assetkey=${asset}&uuid=${uuid}";
} else {
{{range $type,$name := $.Tftp.IpxeBinaries }}
{{- range $type, $name := $.Tftp.IpxeBinaries }}
if option architecture-type = {{ $type }} {
filename "/warewulf/{{ basename $name }}";
}
{{- end }}{{/* range IpxeBinaries */}}
{{- end }}
}
{{- end }}{{/* BootMethod */}}
{{- end }}
subnet {{$.Network}} netmask {{$.Netmask}} {
{{- if and .Network .Netmask .Dhcp.RangeStart .Dhcp.RangeEnd }}
subnet {{.Network}} netmask {{.Netmask}} {
max-lease-time 120;
range {{$.Dhcp.RangeStart}} {{$.Dhcp.RangeEnd}};
range {{.Dhcp.RangeStart}} {{.Dhcp.RangeEnd}};
next-server {{.Ipaddr}};
}
{{- end }}
{{- if eq .Dhcp.Template "static" }}
{{- range $nodes := $.AllNodes}}

View File

@@ -1,4 +1,4 @@
{{- if .Nfs.Enabled }}
{{ if .Nfs.Enabled -}}
# This file is autogenerated by warewulf
{{- $network := .Network }}
{{- $netmask := .Netmask }}