add disk id to config
This commit is contained in:
parent
639f4e60ea
commit
475a444129
5 changed files with 20 additions and 12 deletions
|
@ -114,13 +114,13 @@ func displayAppList(l *logger.SimpleLogger) {
|
|||
if a.Active {
|
||||
prefix = "*"
|
||||
}
|
||||
l.Infof("\t- %s[%d] %s: %s", prefix, a.ID, a.Name, a.Path)
|
||||
l.Infof("\t- %s[%d] %s: %s (disk id %s)", prefix, a.ID, a.Name, a.Path, a.DiskID)
|
||||
}
|
||||
}
|
||||
|
||||
func getRemoteConfig(l *logger.SimpleLogger, host string, id uuid.UUID, pretty bool) {
|
||||
l.Info("Getting config from remote server...")
|
||||
if pretty {
|
||||
l.Info("Getting config from remote server...")
|
||||
if err := remote.DisplayRemoteConfigPretty(context.Background(), host, id, l); err != nil {
|
||||
l.Fatal(err.Error())
|
||||
}
|
||||
|
|
|
@ -12,13 +12,14 @@ import (
|
|||
"git.faercol.me/faercol/http-boot-config/config/logger"
|
||||
)
|
||||
|
||||
var efiBootmgrRegexp = regexp.MustCompile(`Boot(?P<id>\d+)\* (?P<name>[\w ]+)\t(\w+\(.*\))/File\((?P<filepath>.+)\)`)
|
||||
var efiBootmgrRegexp = regexp.MustCompile(`Boot(?P<id>\d+)\* (?P<name>[\w ]+)\t(HD\(.+,.+,(?P<disk_id>[0-9a-f-]+),.+,.+\))/File\((?P<filepath>.+)\)`)
|
||||
var activeRegexp = regexp.MustCompile(`BootCurrent: (\d+)`)
|
||||
|
||||
type EfiApp struct {
|
||||
ID int
|
||||
Name string
|
||||
Path string
|
||||
DiskID string
|
||||
Active bool
|
||||
}
|
||||
|
||||
|
@ -49,11 +50,16 @@ func efiAppFromBootMgrOutput(rawVal string, activeId int) (app EfiApp, ok bool)
|
|||
if !ok {
|
||||
return
|
||||
}
|
||||
disk_id, ok := result["disk_id"]
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
return EfiApp{
|
||||
ID: idInt,
|
||||
Name: strings.TrimSpace(name),
|
||||
Path: strings.TrimSpace(filepath),
|
||||
Active: idInt == activeId,
|
||||
DiskID: disk_id,
|
||||
}, true
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ func TestEfiFomBootMgr(t *testing.T) {
|
|||
t.Run("OK - Windows", func(t *testing.T) {
|
||||
rawVal := (`Boot0000* Windows Boot Manager HD(1,GPT,4ad714ba-6a01-4f76-90e3-1bb93a59b67e,0x800,0x32000)/File(\EFI\MICROSOFT\BOOT\BOOTMGFW.EFI)` +
|
||||
`57494e444f5753000100000088000000780000004200430044004f0042004a004500430054003d007b00390064006500610038003600320063002d0035006300640064002d00`)
|
||||
expected := EfiApp{ID: 0, Name: "Windows Boot Manager", Path: `\EFI\MICROSOFT\BOOT\BOOTMGFW.EFI`, Active: true}
|
||||
expected := EfiApp{ID: 0, Name: "Windows Boot Manager", Path: `\EFI\MICROSOFT\BOOT\BOOTMGFW.EFI`, Active: true, DiskID: "4ad714ba-6a01-4f76-90e3-1bb93a59b67e"}
|
||||
app, ok := efiAppFromBootMgrOutput(rawVal, 0)
|
||||
assert.True(t, ok)
|
||||
assert.Equal(t, expected, app)
|
||||
|
@ -18,7 +18,7 @@ func TestEfiFomBootMgr(t *testing.T) {
|
|||
|
||||
t.Run("OK - Manjaro", func(t *testing.T) {
|
||||
rawVal := `Boot0001* Manjaro HD(1,GPT,16f06d01-50da-6544-86bd-f3457f980086,0x1000,0x96000)/File(\EFI\MANJARO\GRUBX64.EFI)`
|
||||
expected := EfiApp{ID: 1, Name: "Manjaro", Path: `\EFI\MANJARO\GRUBX64.EFI`, Active: false}
|
||||
expected := EfiApp{ID: 1, Name: "Manjaro", Path: `\EFI\MANJARO\GRUBX64.EFI`, Active: false, DiskID: "16f06d01-50da-6544-86bd-f3457f980086"}
|
||||
app, ok := efiAppFromBootMgrOutput(rawVal, 0)
|
||||
assert.True(t, ok)
|
||||
assert.Equal(t, expected, app)
|
||||
|
@ -26,7 +26,7 @@ func TestEfiFomBootMgr(t *testing.T) {
|
|||
|
||||
t.Run("OK - EFI Base", func(t *testing.T) {
|
||||
rawVal := `Boot0002* UEFI OS HD(1,GPT,16f06d01-50da-6544-86bd-f3457f980086,0x1000,0x96000)/File(\EFI\BOOT\BOOTX64.EFI)0000424f`
|
||||
expected := EfiApp{ID: 2, Name: "UEFI OS", Path: `\EFI\BOOT\BOOTX64.EFI`, Active: false}
|
||||
expected := EfiApp{ID: 2, Name: "UEFI OS", Path: `\EFI\BOOT\BOOTX64.EFI`, Active: false, DiskID: "16f06d01-50da-6544-86bd-f3457f980086"}
|
||||
app, ok := efiAppFromBootMgrOutput(rawVal, 0)
|
||||
assert.True(t, ok)
|
||||
assert.Equal(t, expected, app)
|
||||
|
|
|
@ -16,8 +16,9 @@ import (
|
|||
const enrollURL = "/enroll"
|
||||
|
||||
type enrollEFIOption struct {
|
||||
Name string `json:"name"`
|
||||
Path string `json:"path"`
|
||||
Name string `json:"name"`
|
||||
Path string `json:"path"`
|
||||
DiskID string `json:"disk_id"`
|
||||
}
|
||||
|
||||
type enrollPayload struct {
|
||||
|
@ -37,7 +38,7 @@ func enrollToServer(ctx context.Context, host string, name string, apps []prober
|
|||
}
|
||||
for _, a := range apps {
|
||||
appID := uuid.New()
|
||||
payload.Options[appID.String()] = enrollEFIOption{Name: a.Name, Path: a.Path}
|
||||
payload.Options[appID.String()] = enrollEFIOption{Name: a.Name, Path: a.Path, DiskID: a.DiskID}
|
||||
if a.Active {
|
||||
payload.SelectedOption = appID.String()
|
||||
}
|
||||
|
|
|
@ -24,8 +24,9 @@ type clientConfig struct {
|
|||
ID string `json:"ID"`
|
||||
Name string `json:"name"`
|
||||
Options map[string]struct {
|
||||
Name string `json:"name"`
|
||||
Path string `json:"path"`
|
||||
Name string `json:"name"`
|
||||
Path string `json:"path"`
|
||||
DiskID string `json:"disk_id"`
|
||||
} `json:"options"`
|
||||
SelectedOption string `json:"selected_option"`
|
||||
} `json:"efi_config"`
|
||||
|
@ -103,7 +104,7 @@ func DisplayRemoteConfigPretty(ctx context.Context, host string, id uuid.UUID, l
|
|||
}
|
||||
l.Info(" * Available options are:")
|
||||
for _, option := range parsedConf.EFIConfig.Options {
|
||||
l.Infof("\t - %s: %s", option.Name, option.Path)
|
||||
l.Infof("\t - %s: %s (disk id %s)", option.Name, option.Path, option.DiskID)
|
||||
}
|
||||
l.Infof(" * Remote boot server is listening on %s:%d", parsedConf.NetConfig.MulticastGroup, parsedConf.NetConfig.Port)
|
||||
|
||||
|
|
Loading…
Reference in a new issue