Skip to content

Commit 5f1f17a

Browse files
authored
Add support for default chainloading from /ipxe to /ipx/<uuid> (#176)
1 parent 203c2fb commit 5f1f17a

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

server/bootserver.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ func handleIPXE(w http.ResponseWriter, r *http.Request, k8sClient client.Client,
8585

8686
uuid := strings.TrimPrefix(r.URL.Path, "/ipxe/")
8787
if uuid == "" {
88-
http.Error(w, "Bad Request: UUID is required", http.StatusBadRequest)
88+
serveDefaultIPXEChainTemplate(w, log, IPXETemplateData{
89+
IPXEServerURL: ipxeServiceURL,
90+
})
8991
return
9092
}
9193

@@ -221,6 +223,21 @@ func serveDefaultIPXETemplate(w http.ResponseWriter, log logr.Logger, data IPXET
221223
}
222224
}
223225

226+
func serveDefaultIPXEChainTemplate(w http.ResponseWriter, log logr.Logger, data IPXETemplateData) {
227+
tmplPath := filepath.Join("templates", "ipxe-chainload.tpl")
228+
tmpl, err := template.ParseFiles(tmplPath)
229+
if err != nil {
230+
log.Info("Failed to parse iPXE Chainload template", "error", err)
231+
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
232+
return
233+
}
234+
235+
if err := tmpl.Execute(w, data); err != nil {
236+
log.Info("Failed to execute iPXE Chainload template", "error", err)
237+
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
238+
}
239+
}
240+
224241
func handleIgnitionHTTPBoot(w http.ResponseWriter, r *http.Request, k8sClient client.Client, log logr.Logger, uuid string) {
225242
log.Info("Processing Ignition request", "method", r.Method, "path", r.URL.Path, "clientIP", r.RemoteAddr)
226243
ctx := r.Context()

templates/ipxe-chainload.tpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!ipxe
2+
3+
set ipxe-svc {{.IPXEServerURL}}
4+
5+
set base-url ${ipxe-svc}/ipxe
6+
chain --replace --autofree ${base-url}/${uuid}

0 commit comments

Comments
 (0)