Add network as part of the warewulfconf (figure it out if undef)
This commit is contained in:
@@ -2,9 +2,11 @@ package warewulfconf
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/brotherpowers/ipsubnet"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
"gopkg.in/yaml.v2"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
)
|
||||
|
||||
func New() (ControllerConf, error) {
|
||||
@@ -23,6 +25,22 @@ func New() (ControllerConf, error) {
|
||||
return ret, err
|
||||
}
|
||||
|
||||
if ret.Ipaddr == "" {
|
||||
wwlog.Printf(wwlog.WARN, "IP address is not configured in warewulfd.conf\n")
|
||||
}
|
||||
if ret.Netmask == "" {
|
||||
wwlog.Printf(wwlog.WARN, "Netmask is not configured in warewulfd.conf\n")
|
||||
}
|
||||
|
||||
if ret.Network == "" {
|
||||
mask := net.IPMask(net.ParseIP(ret.Netmask).To4())
|
||||
size, _ := mask.Size()
|
||||
|
||||
sub := ipsubnet.SubnetCalculator(ret.Ipaddr, size)
|
||||
|
||||
ret.Network = sub.GetNetworkPortion()
|
||||
}
|
||||
|
||||
if ret.Warewulf.Port == 0 {
|
||||
ret.Warewulf.Port = 9873
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ type ControllerConf struct {
|
||||
Comment string `yaml:"comment"`
|
||||
Ipaddr string `yaml:"ipaddr"`
|
||||
Netmask string `yaml:"netmask"`
|
||||
Network string `yaml:"network,omitempty"`
|
||||
Fqdn string `yaml:"fqdn,omitempty"`
|
||||
Warewulf *WarewulfConf `yaml:"warewulf"`
|
||||
Dhcp *DhcpConf `yaml:"dhcp"`
|
||||
|
||||
Reference in New Issue
Block a user