1
0
mirror of https://github.com/rancher/os.git synced 2025-09-17 23:48:09 +00:00

Add ipxe support

This commit is contained in:
Darren Shepherd
2021-10-13 16:00:29 -07:00
parent b4cc0014b2
commit 0e46d19194
16 changed files with 287 additions and 126 deletions

41
pkg/config/tftpget.go Normal file
View File

@@ -0,0 +1,41 @@
package config
import (
"bytes"
"fmt"
"net"
"net/url"
"gopkg.in/pin/tftp.v2"
"sigs.k8s.io/yaml"
)
func tftpGet(tftpURL string) (map[string]interface{}, error) {
u, err := url.Parse(tftpURL)
if err != nil {
return nil, err
}
host, _, err := net.SplitHostPort(u.Host)
if err != nil {
host = u.Host + ":69"
}
fmt.Printf("Downloading config from host %s, file %s\n", host, u.Path)
client, err := tftp.NewClient(host)
if err != nil {
return nil, err
}
writerTo, err := client.Receive(u.Path, "octet")
if err != nil {
return nil, err
}
buf := &bytes.Buffer{}
if _, err := writerTo.WriteTo(buf); err != nil {
return nil, err
}
result := map[string]interface{}{}
return result, yaml.Unmarshal(buf.Bytes(), &result)
}