-
Notifications
You must be signed in to change notification settings - Fork 0
/
booter.go
53 lines (43 loc) · 1.08 KB
/
booter.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package pxeserver
import (
"fmt"
"io"
"go.universe.tf/netboot/pixiecore"
)
type configBooter struct {
specs map[string]*pixiecore.Spec
files Files
}
func ConfigBooter(cfg Pixiecore, files Files) (pixiecore.Booter, error) {
ret := &configBooter{
specs: make(map[string]*pixiecore.Spec),
files: files,
}
for mac, hostCfg := range cfg {
spec := &pixiecore.Spec{
Kernel: pixiecore.ID(hostCfg.Kernel),
}
for _, initrd := range hostCfg.Initrd {
spec.Initrd = append(spec.Initrd, pixiecore.ID(initrd))
}
spec.Cmdline = hostCfg.Cmdline
spec.ForcePXELinux = hostCfg.ForcePXELinux
ret.specs[string(mac)] = spec
}
return ret, nil
}
func (s *configBooter) BootSpec(m pixiecore.Machine) (*pixiecore.Spec, error) {
mac := m.MAC.String()
spec, ok := s.specs[mac]
if !ok {
return nil, fmt.Errorf("Could not find BootSpec for '%s'", mac)
}
return spec, nil
}
func (s *configBooter) ReadBootFile(id pixiecore.ID) (io.ReadCloser, int64, error) {
return s.files.Read(string(id))
}
// unused
func (s *configBooter) WriteBootFile(pixiecore.ID, io.Reader) error {
return nil
}