From 2c45629b50a0e8d481433b76bbcbc00954e856c9 Mon Sep 17 00:00:00 2001 From: Jian Qiu Date: Thu, 3 Feb 2022 21:21:17 +0800 Subject: [PATCH] feature: baremetal tftp send customized files according to a file map (#13374) Co-authored-by: Qiu Jian --- pkg/baremetal/options/options.go | 2 ++ pkg/baremetal/pxe/tftp.go | 3 +++ 2 files changed, 5 insertions(+) diff --git a/pkg/baremetal/options/options.go b/pkg/baremetal/options/options.go index 5a36f9abb3..31922f9557 100644 --- a/pkg/baremetal/options/options.go +++ b/pkg/baremetal/options/options.go @@ -51,6 +51,8 @@ type BaremetalOptions struct { StatusProbeIntervalSeconds int `help:"interval to probe baremetal status, default is 60 seconds" default:"60"` LogFetchIntervalSeconds int `help:"interval to fetch baremetal log, default is 900 seconds" default:"900"` SendMetricsIntervalSeconds int `help:"interval to send baremetal metrics, default is 300 seconds" default:"300"` + + TftpFileMap map[string]string `help:"map of filename to real file path for tftp"` } var ( diff --git a/pkg/baremetal/pxe/tftp.go b/pkg/baremetal/pxe/tftp.go index 8a238ab177..63a23720ba 100644 --- a/pkg/baremetal/pxe/tftp.go +++ b/pkg/baremetal/pxe/tftp.go @@ -123,6 +123,9 @@ func (h *TFTPHandler) sendFile(filename string, _ net.Addr) (io.ReadCloser, int6 } func (h *TFTPHandler) getFilePath(fileName string) string { + if path, ok := options.Options.TftpFileMap[fileName]; ok { + return path + } return filepath.Join(h.RootDir, fileName) }