Merge pull request #651 from mslacken/MakeIpxeConfig
make ipxe binary source configurable
This commit is contained in:
@@ -27,7 +27,7 @@ func BINDIR() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func DATADIR() string {
|
func DATADIR() string {
|
||||||
wwlog.Debug("DATADIR = '%s'", bindir)
|
wwlog.Debug("DATADIR = '%s'", datadir)
|
||||||
return datadir
|
return datadir
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,9 +11,8 @@ import (
|
|||||||
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
"github.com/hpcng/warewulf/internal/pkg/wwlog"
|
||||||
)
|
)
|
||||||
|
|
||||||
var tftpdir string = path.Join(buildconfig.TFTPDIR(), "warewulf")
|
|
||||||
|
|
||||||
func TFTP() error {
|
func TFTP() error {
|
||||||
|
var tftpdir string = path.Join(buildconfig.TFTPDIR(), "warewulf")
|
||||||
controller, err := warewulfconf.New()
|
controller, err := warewulfconf.New()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
wwlog.Error("%s", err)
|
wwlog.Error("%s", err)
|
||||||
@@ -27,11 +26,15 @@ func TFTP() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("Writing PXE files to: %s\n", tftpdir)
|
fmt.Printf("Writing PXE files to: %s\n", tftpdir)
|
||||||
for _, f := range [4]string{"x86_64.efi", "x86_64.kpxe", "arm64.efi"} {
|
copyCheck := make(map[string]bool)
|
||||||
err = util.SafeCopyFile(path.Join(buildconfig.DATADIR(), "warewulf", "ipxe", f), path.Join(tftpdir, f))
|
for _, f := range controller.Tftp.IpxeBinaries {
|
||||||
|
if copyCheck[f] {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
copyCheck[f] = true
|
||||||
|
err = util.SafeCopyFile(path.Join(buildconfig.DATADIR(), f), path.Join(tftpdir, f))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
wwlog.Error("%s", err)
|
wwlog.Warn("ipxe binary could not be copied, booting may not work: %s", err)
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,7 +42,7 @@ func TFTP() error {
|
|||||||
wwlog.Info("Warewulf does not auto start TFTP services due to disable by warewulf.conf")
|
wwlog.Info("Warewulf does not auto start TFTP services due to disable by warewulf.conf")
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("Enabling and restarting the TFTP services\n")
|
fmt.Printf("Enabling and restarting the TFTP services\n")
|
||||||
err = util.SystemdStart(controller.Tftp.SystemdName)
|
err = util.SystemdStart(controller.Tftp.SystemdName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ type TemplateStruct struct {
|
|||||||
Dhcp warewulfconf.DhcpConf
|
Dhcp warewulfconf.DhcpConf
|
||||||
Nfs warewulfconf.NfsConf
|
Nfs warewulfconf.NfsConf
|
||||||
Warewulf warewulfconf.WarewulfConf
|
Warewulf warewulfconf.WarewulfConf
|
||||||
|
Tftp warewulfconf.TftpConf
|
||||||
AllNodes []node.NodeInfo
|
AllNodes []node.NodeInfo
|
||||||
node.NodeConf
|
node.NodeConf
|
||||||
// backward compatiblity
|
// backward compatiblity
|
||||||
@@ -64,6 +65,7 @@ func InitStruct(nodeInfo node.NodeInfo) TemplateStruct {
|
|||||||
tstruct.AllNodes = allNodes
|
tstruct.AllNodes = allNodes
|
||||||
tstruct.Nfs = *controller.Nfs
|
tstruct.Nfs = *controller.Nfs
|
||||||
tstruct.Dhcp = *controller.Dhcp
|
tstruct.Dhcp = *controller.Dhcp
|
||||||
|
tstruct.Tftp = *controller.Tftp
|
||||||
tstruct.Warewulf = *controller.Warewulf
|
tstruct.Warewulf = *controller.Warewulf
|
||||||
tstruct.Ipaddr = controller.Ipaddr
|
tstruct.Ipaddr = controller.Ipaddr
|
||||||
tstruct.Ipaddr6 = controller.Ipaddr6
|
tstruct.Ipaddr6 = controller.Ipaddr6
|
||||||
|
|||||||
@@ -36,8 +36,14 @@ func New() (ControllerConf, error) {
|
|||||||
ret.Tftp = &tftpconf
|
ret.Tftp = &tftpconf
|
||||||
ret.Nfs = &nfsConf
|
ret.Nfs = &nfsConf
|
||||||
err := defaults.Set(&ret)
|
err := defaults.Set(&ret)
|
||||||
|
// ipxe binaries are merged not overwritten, store defaults separate
|
||||||
|
defIpxe := make(map[string]string)
|
||||||
|
for k, v := range ret.Tftp.IpxeBinaries {
|
||||||
|
defIpxe[k] = v
|
||||||
|
delete(ret.Tftp.IpxeBinaries, k)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
wwlog.Error("Coult initialize default variables")
|
wwlog.Error("Could initialize default variables")
|
||||||
return ret, err
|
return ret, err
|
||||||
}
|
}
|
||||||
// Check if cached config is old before re-reading config file
|
// Check if cached config is old before re-reading config file
|
||||||
@@ -53,7 +59,9 @@ func New() (ControllerConf, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return ret, err
|
return ret, err
|
||||||
}
|
}
|
||||||
|
if len(ret.Tftp.IpxeBinaries) == 0 {
|
||||||
|
ret.Tftp.IpxeBinaries = defIpxe
|
||||||
|
}
|
||||||
if ret.Ipaddr == "" || ret.Netmask == "" {
|
if ret.Ipaddr == "" || ret.Netmask == "" {
|
||||||
conn, error := net.Dial("udp", "8.8.8.8:80")
|
conn, error := net.Dial("udp", "8.8.8.8:80")
|
||||||
if error != nil {
|
if error != nil {
|
||||||
|
|||||||
@@ -44,6 +44,8 @@ type TftpConf struct {
|
|||||||
Enabled bool `yaml:"enabled" default:"true"`
|
Enabled bool `yaml:"enabled" default:"true"`
|
||||||
TftpRoot string `yaml:"tftproot" default:"/var/lib/tftpboot"`
|
TftpRoot string `yaml:"tftproot" default:"/var/lib/tftpboot"`
|
||||||
SystemdName string `yaml:"systemd name" default:"tftp"`
|
SystemdName string `yaml:"systemd name" default:"tftp"`
|
||||||
|
// Path is relative to buildconfig.DATADIR()
|
||||||
|
IpxeBinaries map[string]string `yaml:"ipxe" default:"{\"00:09\": \"x86_64.efi\",\"00:00\": \"x86_64.kpxe\",\"00:0B\": \"arm64.efi\",\"00:07\": \"x86_64.efi\"}"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type NfsConf struct {
|
type NfsConf struct {
|
||||||
|
|||||||
@@ -20,15 +20,11 @@ option architecture-type code 93 = unsigned integer 16;
|
|||||||
if exists user-class and option user-class = "iPXE" {
|
if exists user-class and option user-class = "iPXE" {
|
||||||
filename "http://{{$.Ipaddr}}:{{$.Warewulf.Port}}/ipxe/${mac:hexhyp}";
|
filename "http://{{$.Ipaddr}}:{{$.Warewulf.Port}}/ipxe/${mac:hexhyp}";
|
||||||
} else {
|
} else {
|
||||||
if option architecture-type = 00:0B {
|
{{range $type,$name := $.Tftp.IpxeBinaries }}
|
||||||
filename "/warewulf/arm64.efi";
|
if option architecture-type = {{ $type }} {
|
||||||
} elsif option architecture-type = 00:09 {
|
filename "/warewulf/{{ $name }}";
|
||||||
filename "/warewulf/x86_64.efi";
|
}
|
||||||
} elsif option architecture-type = 00:07 {
|
{{ end }}
|
||||||
filename "/warewulf/x86_64.efi";
|
|
||||||
} elsif option architecture-type = 00:00 {
|
|
||||||
filename "/warewulf/x86_64.kpxe";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{{if eq .Dhcp.Template "static" -}}
|
{{if eq .Dhcp.Template "static" -}}
|
||||||
|
|||||||
Reference in New Issue
Block a user