Merge pull request #573 from anderbubble/issues/571

Correct host overlay processing during configure
This commit is contained in:
Christian Goll
2022-11-11 19:26:28 +01:00
committed by GitHub
2 changed files with 10 additions and 11 deletions

View File

@@ -15,22 +15,24 @@ import (
Creates '/etc/hosts' from the host template.
*/
func Hostfile() error {
if !(util.IsFile(path.Join(overlay.OverlaySourceDir("host"), "/host/etc/hosts.ww"))) {
hostTemplate := path.Join(overlay.OverlaySourceDir("host"), "/etc/hosts.ww")
if !(util.IsFile(hostTemplate)) {
wwlog.Error("'the overlay template '/etc/hosts.ww' does not exists in 'host' overlay")
os.Exit(1)
}
var nodeInfo node.NodeInfo
tstruct := overlay.InitStruct(nodeInfo)
nodeInfo := node.NewInfo()
hostname, _ := os.Hostname()
nodeInfo.Id.Set(hostname)
tstruct := overlay.InitStruct(nodeInfo)
buffer, backupFile, writeFile, err := overlay.RenderTemplateFile(
path.Join(overlay.OverlaySourceDir("host"), "/host/etc/hosts.ww"),
hostTemplate,
tstruct)
if err != nil {
wwlog.Error("%s", err)
os.Exit(1)
}
info, err := os.Stat(path.Join(overlay.OverlaySourceDir("host"), "/host/etc/hosts.ww"))
info, err := os.Stat(hostTemplate)
if err != nil {
wwlog.Error("%s", err)
os.Exit(1)

View File

@@ -81,14 +81,11 @@ func BuildSpecificOverlays(nodes []node.NodeInfo, overlayNames []string) error {
Build overlay for the host, so no argument needs to be given
*/
func BuildHostOverlay() error {
var host node.NodeInfo
host.Kernel = new(node.KernelEntry)
host.Ipmi = new(node.IpmiEntry)
var idEntry node.Entry
host := node.NewInfo()
hostname, _ := os.Hostname()
host.Id.Set(hostname)
wwlog.Info("Building overlay for %s: host", hostname)
idEntry.Set(hostname)
host.Id = idEntry
hostdir := OverlaySourceDir("host")
stats, err := os.Stat(hostdir)
if err != nil {