From 7ce286ac3edef8652a9c33feeffa120fef87c90e Mon Sep 17 00:00:00 2001 From: Christian Goll Date: Tue, 3 May 2022 14:24:50 +0200 Subject: [PATCH 1/3] updated overlay includes mire vars and split func --- internal/pkg/overlay/datastructure.go | 4 ++++ internal/pkg/overlay/overlay.go | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/internal/pkg/overlay/datastructure.go b/internal/pkg/overlay/datastructure.go index 70e5f79b..0c4c35d7 100644 --- a/internal/pkg/overlay/datastructure.go +++ b/internal/pkg/overlay/datastructure.go @@ -37,4 +37,8 @@ type TemplateStruct struct { Dhcp warewulfconf.DhcpConf Nfs warewulfconf.NfsConf Warewulf warewulfconf.WarewulfConf + Overlays []string + Containers []string + Kernels []string + Profiles []string } diff --git a/internal/pkg/overlay/overlay.go b/internal/pkg/overlay/overlay.go index 06272a48..00329e9a 100644 --- a/internal/pkg/overlay/overlay.go +++ b/internal/pkg/overlay/overlay.go @@ -17,6 +17,8 @@ import ( "text/template" "time" + "github.com/hpcng/warewulf/internal/pkg/container" + "github.com/hpcng/warewulf/internal/pkg/kernel" "github.com/hpcng/warewulf/internal/pkg/node" "github.com/hpcng/warewulf/internal/pkg/util" "github.com/hpcng/warewulf/internal/pkg/warewulfconf" @@ -301,6 +303,15 @@ func BuildOverlayIndir(nodeInfo node.NodeInfo, overlayNames []string, outputDir dt := time.Now() tstruct.BuildTime = dt.Format("01-02-2006 15:04:05 MST") tstruct.BuildTimeUnix = strconv.FormatInt(dt.Unix(), 10) + tstruct.Containers, _ = container.ListSources() + profiles, _ := nodeDB.FindAllProfiles() + var profileList []string + for _, profile := range profiles { + profileList = append(profileList, profile.Id.Get()) + } + tstruct.Profiles = profileList + tstruct.Overlays, _ = FindOverlays() + tstruct.Kernels, _ = kernel.ListKernels() for _, overlayName := range overlayNames { wwlog.Printf(wwlog.VERBOSE, "Building overlay %s for node %s in %s\n", overlayName, nodeInfo.Id.Get(), outputDir) overlaySourceDir := OverlaySourceDir(overlayName) @@ -360,6 +371,9 @@ func BuildOverlayIndir(nodeInfo node.NodeInfo, overlayNames []string, outputDir backupFile = false return "" }, + "split": func(s string, d string) []string { + return strings.Split(s, d) + }, // }).ParseGlob(path.Join(OverlayDir, destFile+".ww*")) }).ParseGlob(location) if err != nil { From de819b55834c9c4b96edff3ababb302f4c001180 Mon Sep 17 00:00:00 2001 From: Christian Goll Date: Thu, 5 May 2022 16:13:01 +0200 Subject: [PATCH 2/3] only add split function in templates --- internal/pkg/overlay/datastructure.go | 5 ----- internal/pkg/overlay/overlay.go | 12 ------------ 2 files changed, 17 deletions(-) diff --git a/internal/pkg/overlay/datastructure.go b/internal/pkg/overlay/datastructure.go index 0c4c35d7..289106ab 100644 --- a/internal/pkg/overlay/datastructure.go +++ b/internal/pkg/overlay/datastructure.go @@ -26,7 +26,6 @@ type TemplateStruct struct { AllNodes []node.NodeInfo BuildHost string BuildTime string - BuildTimeUnix string BuildSource string Ipaddr string Ipaddr6 string @@ -37,8 +36,4 @@ type TemplateStruct struct { Dhcp warewulfconf.DhcpConf Nfs warewulfconf.NfsConf Warewulf warewulfconf.WarewulfConf - Overlays []string - Containers []string - Kernels []string - Profiles []string } diff --git a/internal/pkg/overlay/overlay.go b/internal/pkg/overlay/overlay.go index 00329e9a..1524d8a3 100644 --- a/internal/pkg/overlay/overlay.go +++ b/internal/pkg/overlay/overlay.go @@ -17,8 +17,6 @@ import ( "text/template" "time" - "github.com/hpcng/warewulf/internal/pkg/container" - "github.com/hpcng/warewulf/internal/pkg/kernel" "github.com/hpcng/warewulf/internal/pkg/node" "github.com/hpcng/warewulf/internal/pkg/util" "github.com/hpcng/warewulf/internal/pkg/warewulfconf" @@ -302,16 +300,6 @@ func BuildOverlayIndir(nodeInfo node.NodeInfo, overlayNames []string, outputDir tstruct.BuildHost = hostname dt := time.Now() tstruct.BuildTime = dt.Format("01-02-2006 15:04:05 MST") - tstruct.BuildTimeUnix = strconv.FormatInt(dt.Unix(), 10) - tstruct.Containers, _ = container.ListSources() - profiles, _ := nodeDB.FindAllProfiles() - var profileList []string - for _, profile := range profiles { - profileList = append(profileList, profile.Id.Get()) - } - tstruct.Profiles = profileList - tstruct.Overlays, _ = FindOverlays() - tstruct.Kernels, _ = kernel.ListKernels() for _, overlayName := range overlayNames { wwlog.Printf(wwlog.VERBOSE, "Building overlay %s for node %s in %s\n", overlayName, nodeInfo.Id.Get(), outputDir) overlaySourceDir := OverlaySourceDir(overlayName) From 121c12b5e40995eacaccad30b4d212882ce049c0 Mon Sep 17 00:00:00 2001 From: Christian Goll Date: Thu, 5 May 2022 16:15:06 +0200 Subject: [PATCH 3/3] Readd BuildTimeUnix --- internal/pkg/overlay/datastructure.go | 1 + internal/pkg/overlay/overlay.go | 1 + 2 files changed, 2 insertions(+) diff --git a/internal/pkg/overlay/datastructure.go b/internal/pkg/overlay/datastructure.go index 289106ab..70e5f79b 100644 --- a/internal/pkg/overlay/datastructure.go +++ b/internal/pkg/overlay/datastructure.go @@ -26,6 +26,7 @@ type TemplateStruct struct { AllNodes []node.NodeInfo BuildHost string BuildTime string + BuildTimeUnix string BuildSource string Ipaddr string Ipaddr6 string diff --git a/internal/pkg/overlay/overlay.go b/internal/pkg/overlay/overlay.go index 1524d8a3..1e2d1316 100644 --- a/internal/pkg/overlay/overlay.go +++ b/internal/pkg/overlay/overlay.go @@ -300,6 +300,7 @@ func BuildOverlayIndir(nodeInfo node.NodeInfo, overlayNames []string, outputDir tstruct.BuildHost = hostname dt := time.Now() tstruct.BuildTime = dt.Format("01-02-2006 15:04:05 MST") + tstruct.BuildTimeUnix = strconv.FormatInt(dt.Unix(), 10) for _, overlayName := range overlayNames { wwlog.Printf(wwlog.VERBOSE, "Building overlay %s for node %s in %s\n", overlayName, nodeInfo.Id.Get(), outputDir) overlaySourceDir := OverlaySourceDir(overlayName)