Moving warewulfd code around and implementing new API for config.*()

This commit is contained in:
Gregory Kurtzer
2020-11-11 22:16:24 -08:00
parent 9a9672a060
commit fa2a7e26d3
18 changed files with 140 additions and 447 deletions

View File

@@ -11,9 +11,8 @@ import (
"path"
)
const kernelProvisionPath = "/provision/kernel/"
func Build(nodeList []assets.NodeInfo, force bool) error {
config := config.New()
set := make(map[string]int)
wwlog.Printf(wwlog.INFO, "Importing Kernels:\n")
@@ -29,12 +28,13 @@ func Build(nodeList []assets.NodeInfo, force bool) error {
for kernelVersion := range set {
kernelImage := "/boot/vmlinuz-"+kernelVersion
kernelDrivers := "/lib/modules/"+kernelVersion
kernelDestination := path.Join(config.LocalStateDir, kernelProvisionPath, "vmlinuz-"+kernelVersion)
driversDestination := path.Join(config.LocalStateDir, kernelProvisionPath, "kmods-"+kernelVersion+".img")
kernelDestination := config.KernelImage(kernelVersion)
driversDestination := config.KmodsImage(kernelVersion)
// Create the destination paths just in case it doesn't exist
os.MkdirAll(path.Dir(kernelDestination), 0755)
os.MkdirAll(path.Dir(driversDestination), 0755)
// Create the kernel destination path just in case it doesn't exist
os.MkdirAll(path.Join(config.LocalStateDir, kernelProvisionPath), 0755)
if _, err := os.Stat(kernelImage); err == nil {
if util.PathIsNewer(kernelImage, kernelDestination) && force == false {