From 6d267d38e6cdd57e76851e1c5ea7d29b7e5ba846 Mon Sep 17 00:00:00 2001 From: Christian Goll Date: Thu, 29 Jul 2021 09:24:58 +0200 Subject: [PATCH 1/2] added IpCIDR entry for the nodes --- internal/pkg/node/datastructure.go | 4 ++++ internal/pkg/overlay/overlay.go | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/internal/pkg/node/datastructure.go b/internal/pkg/node/datastructure.go index 406c656d..a04102ea 100644 --- a/internal/pkg/node/datastructure.go +++ b/internal/pkg/node/datastructure.go @@ -44,6 +44,8 @@ type NetDevs struct { Default bool `yaml:"default"` Hwaddr string Ipaddr string + IpCIDR string + Prefix string Netmask string Gateway string `yaml:"gateway,omitempty"` } @@ -91,6 +93,8 @@ type NetDevEntry struct { Default Entry `yaml:"default"` Hwaddr Entry Ipaddr Entry + IpCIDR Entry + Prefix Entry Netmask Entry Gateway Entry `yaml:"gateway,omitempty"` } diff --git a/internal/pkg/overlay/overlay.go b/internal/pkg/overlay/overlay.go index 7936e534..fc9c64a5 100644 --- a/internal/pkg/overlay/overlay.go +++ b/internal/pkg/overlay/overlay.go @@ -3,11 +3,13 @@ package overlay import ( "fmt" "io/ioutil" + "net" "os" "os/exec" "path" "path/filepath" "regexp" + "strconv" "strings" "text/template" @@ -160,6 +162,13 @@ func buildOverlay(nodeList []node.NodeInfo, overlayType string) error { t.NetDevs[devname].Gateway = netdev.Gateway.Get() t.NetDevs[devname].Type = netdev.Type.Get() t.NetDevs[devname].Default = netdev.Default.GetB() + mask := net.IPMask(net.ParseIP(netdev.Netmask.Get()).To4()) + ipaddr := net.ParseIP(netdev.Ipaddr.Get()).To4() + netaddr := net.IPNet{IP: ipaddr,Mask: mask} + netPrefix, _ := net.IPMask(net.ParseIP(netdev.Netmask.Get()).To4()).Size() + t.NetDevs[devname].Prefix = strconv.Itoa(netPrefix) + t.NetDevs[devname].IpCIDR = netaddr.String() + } for keyname, key := range n.Keys { t.Keys[keyname] = key.Get() From 49300a513d5957be5dd247771093b4494ee54587 Mon Sep 17 00:00:00 2001 From: Christian Goll Date: Thu, 29 Jul 2021 09:27:37 +0200 Subject: [PATCH 2/2] added wicked xml configuration --- .../etc/wicked/ifconfig/ifcfg-eth0.xml.ww | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 overlays/system/default/etc/wicked/ifconfig/ifcfg-eth0.xml.ww diff --git a/overlays/system/default/etc/wicked/ifconfig/ifcfg-eth0.xml.ww b/overlays/system/default/etc/wicked/ifconfig/ifcfg-eth0.xml.ww new file mode 100644 index 00000000..6e7f7600 --- /dev/null +++ b/overlays/system/default/etc/wicked/ifconfig/ifcfg-eth0.xml.ww @@ -0,0 +1,27 @@ + + eth0 + + boot + + + + + true + true + + +
+ {{$.NetDevs.eth0.IpCIDR}} +
+ + + {{$.NetDevs.eth0.Gateway}} + + +
+ + true + prefer-public + false + +