Fix IpCIDR for templates

This commit is contained in:
Christian Goll
2022-08-12 10:17:28 +02:00
parent b2dc31e20b
commit bc647f0bf3

View File

@@ -84,6 +84,14 @@ func InitStruct(nodeInfo node.NodeInfo) TemplateStruct {
tstruct.BuildTime = dt.Format("01-02-2006 15:04:05 MST")
tstruct.BuildTimeUnix = strconv.FormatInt(dt.Unix(), 10)
tstruct.NodeConf.GetFrom(nodeInfo)
// FIXME: Set ipCIDR address at this point, will fail with
// invalid ipv4 addr
for _, network := range tstruct.NetDevs {
ipCIDR := net.IPNet{
IP: net.ParseIP(network.Ipaddr),
Mask: net.IPMask(net.ParseIP(network.Netmask))}
network.IpCIDR = ipCIDR.String()
}
// backward compatibilty
tstruct.Container = tstruct.ContainerName