Add GRUB config route, tests, and server route documentation

- Add /grub/{hwaddr} route for serving GRUB configuration files,
  replacing the shim handler with a config-based approach
- Add short URL aliases: 'system' for overlay-system, 'runtime' for
  overlay-runtime, and 'grub' stage in parser
- Add 'grub' to status stage tracking in request handling
- Add comprehensive test coverage for EFI, GRUB, initramfs, iPXE,
  overlay, and provision handlers (efi_test.go, grub_test.go,
  initramfs_test.go, ipxe_test.go, overlay_test.go)
- Expand existing parser and provision tests
- Remove shim.go (functionality folded into grub.go)
- Add userdocs/server/routes.rst documenting all warewulfd HTTP routes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
Jonathon Anderson
2026-03-06 11:38:40 -07:00
parent a886b4958b
commit 779434331c
14 changed files with 902 additions and 74 deletions

View File

@@ -2,32 +2,25 @@ package warewulfd
import (
"net/http"
"path"
"github.com/warewulf/warewulf/internal/pkg/image"
"github.com/warewulf/warewulf/internal/pkg/wwlog"
)
// HandleGrub handles direct GRUB binary requests
// HandleGrub handles GRUB configuration requests
func HandleGrub(w http.ResponseWriter, req *http.Request) {
ctx, err := initHandleRequest(w, req)
if err != nil {
return // response already written
}
var stageFile string
if !ctx.remoteNode.Valid() {
wwlog.Error("%s (unknown/unconfigured node)", ctx.rinfo.hwaddr)
} else {
if ctx.remoteNode.ImageName != "" {
stageFile = image.GrubFind(ctx.remoteNode.ImageName)
if stageFile == "" {
wwlog.Error("No grub found for image %s", ctx.remoteNode.ImageName)
}
} else {
wwlog.Warn("No conainer set for node %s", ctx.remoteNode.Id())
}
w.WriteHeader(http.StatusNotFound)
return
}
sendResponse(w, req, stageFile, nil, ctx)
stageFile := path.Join(ctx.conf.Paths.Sysconfdir, "warewulf/grub/grub.cfg.ww")
tmplData := buildTemplateVars(ctx.conf, ctx.rinfo, ctx.remoteNode)
sendResponse(w, req, stageFile, tmplData, ctx)
}