added make_defaults to wwctl genconfig defaults
Signed-off-by: Christian Goll <cgoll@suse.de>
This commit is contained in:
@@ -19,7 +19,13 @@ var cachedConf ControllerConf
|
||||
|
||||
var ConfigFile string
|
||||
|
||||
/*
|
||||
Get the configFile location from the os.ev if set
|
||||
*/
|
||||
func init() {
|
||||
if ConfigFile == "" {
|
||||
ConfigFile = os.Getenv("WARWULFCONF")
|
||||
}
|
||||
if ConfigFile == "" {
|
||||
ConfigFile = path.Join(buildconfig.SYSCONFDIR(), "warewulf/warewulf.conf")
|
||||
}
|
||||
@@ -51,7 +57,7 @@ func New() (ControllerConf, error) {
|
||||
wwlog.Debug("Opening Warewulf configuration file: %s", ConfigFile)
|
||||
data, err := os.ReadFile(ConfigFile)
|
||||
if err != nil {
|
||||
wwlog.Warn("Error reading Warewulf configuration file")
|
||||
wwlog.Warn("Error reading Warewulf configuration file, falling back on defaults")
|
||||
}
|
||||
|
||||
wwlog.Debug("Unmarshaling the Warewulf configuration")
|
||||
@@ -71,12 +77,12 @@ func New() (ControllerConf, error) {
|
||||
localIp := conn.LocalAddr().(*net.UDPAddr)
|
||||
if ret.Ipaddr == "" {
|
||||
ret.Ipaddr = localIp.IP.String()
|
||||
wwlog.Warn("IP address is not configured in warewulfd.conf, using %s", ret.Ipaddr)
|
||||
wwlog.Verbose("IP address is not configured in warewulfd.conf, using %s", ret.Ipaddr)
|
||||
}
|
||||
if ret.Netmask == "" {
|
||||
mask := localIp.IP.DefaultMask()
|
||||
ret.Netmask = fmt.Sprintf("%d.%d.%d.%d", mask[0], mask[1], mask[2], mask[3])
|
||||
wwlog.Warn("Netmask address is not configured in warewulfd.conf, using %s", ret.Netmask)
|
||||
wwlog.Verbose("Netmask address is not configured in warewulfd.conf, using %s", ret.Netmask)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package warewulfconf
|
||||
|
||||
import (
|
||||
"github.com/creasty/defaults"
|
||||
"github.com/hpcng/warewulf/internal/pkg/util"
|
||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||
)
|
||||
|
||||
@@ -80,13 +79,9 @@ func (s *NfsConf) Unmarshal(unmarshal func(interface{}) error) error {
|
||||
}
|
||||
|
||||
func init() {
|
||||
if !util.IsFile(ConfigFile) {
|
||||
wwlog.Error("Configuration file not found: %s", ConfigFile)
|
||||
// fail silently as this also called by bash_completion
|
||||
}
|
||||
_, err := New()
|
||||
if err != nil {
|
||||
wwlog.Error("Could not read Warewulf configuration file: %s", err)
|
||||
wwlog.Warn("Could not get any Warewulf configuration: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user