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:
@@ -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
|
||||
|
||||
1
overlays/debug/internal/warewulf.conf
Normal file
1
overlays/debug/internal/warewulf.conf
Normal file
@@ -0,0 +1 @@
|
||||
ipaddr: 192.168.0.1/24
|
||||
@@ -29,6 +29,7 @@ data from other structures.
|
||||
### Network
|
||||
|
||||
- Ipaddr: {{ .Ipaddr }}
|
||||
- IpCIDR: {{ .IpCIDR }}
|
||||
- Ipaddr6: {{ .Ipaddr6 }}
|
||||
- Netmask: {{ .Netmask }}
|
||||
- Network: {{ .Network }}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{{- if .Nfs.Enabled }}
|
||||
{{ if .Nfs.Enabled -}}
|
||||
# This file is autogenerated by warewulf
|
||||
{{- $network := .Network }}
|
||||
{{- $netmask := .Netmask }}
|
||||
|
||||
Reference in New Issue
Block a user