add CIDR format to warewulf.conf parse
Signed-off-by: Xu Yang <xyang@ciq.com>
This commit is contained in:
committed by
Jonathon Anderson
parent
a9b226b3dd
commit
b3d8f9ccc5
@@ -101,6 +101,19 @@ func (conf *RootConf) Parse(data []byte) error {
|
||||
if len(conf.TFTP.IpxeBinaries) == 0 {
|
||||
conf.TFTP.IpxeBinaries = defIpxe
|
||||
}
|
||||
|
||||
// check whether ip addr is CIDR type and configure related fields as required
|
||||
if ip, network, err := net.ParseCIDR(conf.Ipaddr); err == nil {
|
||||
conf.Ipaddr = ip.String()
|
||||
if conf.Network == "" {
|
||||
conf.Network = network.IP.String()
|
||||
}
|
||||
if conf.Netmask == "" {
|
||||
mask := network.Mask
|
||||
conf.Netmask = fmt.Sprintf("%d.%d.%d.%d", mask[0], mask[1], mask[2], mask[3])
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user