- 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>
65 lines
1.4 KiB
Go
65 lines
1.4 KiB
Go
package warewulfd
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/warewulf/warewulf/internal/pkg/node"
|
|
"github.com/warewulf/warewulf/internal/pkg/wwlog"
|
|
)
|
|
|
|
type templateVars struct {
|
|
Message string
|
|
WaitTime string
|
|
Hostname string
|
|
Fqdn string
|
|
Id string
|
|
Cluster string
|
|
ImageName string
|
|
Ipxe string
|
|
Hwaddr string
|
|
Ipaddr string
|
|
Ipaddr6 string
|
|
Port string
|
|
Authority string
|
|
KernelArgs string
|
|
KernelVersion string
|
|
Root string
|
|
TLS bool
|
|
Tags map[string]string
|
|
NetDevs map[string]*node.NetDev
|
|
}
|
|
|
|
func HandleProvision(w http.ResponseWriter, req *http.Request) {
|
|
// Parse just enough to determine the stage
|
|
rinfo, err := parseRequest(req)
|
|
if err != nil {
|
|
w.WriteHeader(http.StatusBadRequest)
|
|
wwlog.ErrorExc(err, "Bad status")
|
|
return
|
|
}
|
|
|
|
// Dispatch to the appropriate stage handler
|
|
var handler http.HandlerFunc
|
|
switch rinfo.stage {
|
|
case "ipxe":
|
|
handler = HandleIpxe
|
|
case "kernel":
|
|
handler = HandleKernel
|
|
case "image":
|
|
handler = HandleImage
|
|
case "system":
|
|
handler = HandleSystemOverlay
|
|
case "runtime":
|
|
handler = HandleRuntimeOverlay
|
|
case "grub":
|
|
handler = HandleGrub
|
|
case "initramfs":
|
|
handler = HandleInitramfs
|
|
default:
|
|
w.WriteHeader(http.StatusBadRequest)
|
|
wwlog.Error("Unknown stage: %s", rinfo.stage)
|
|
return
|
|
}
|
|
handler(w, req)
|
|
}
|