Skip to content

Commit

Permalink
Fix configure bios (#35)
Browse files Browse the repository at this point in the history
* fix configure bios

* detect board type early
  • Loading branch information
majst01 authored May 25, 2021
1 parent 83028db commit 3d7b597
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 20 deletions.
25 changes: 12 additions & 13 deletions internal/vendors/supermicro/sum.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,17 @@ func newSum(sumBin, boardName string) (*sum, error) {
if err != nil {
return nil, fmt.Errorf("sum binary not present at:%s err:%w", sumBin, err)
}
return &sum{
sum := &sum{
binary: sumBin,
boardName: boardName,
}, nil
}
bm, ok := boardModels[boardName]
if ok {
sum.boardModel = bm
} else {
sum.boardModel = X11DPT_B
}
return sum, nil
}

func NewRemoteSum(sumBin, boardName string, ip, user, password string) (*sum, error) {
Expand All @@ -211,7 +218,7 @@ func NewRemoteSum(sumBin, boardName string, ip, user, password string) (*sum, er
// If returns whether machine needs to be rebooted or not.
func (s *sum) ConfigureBIOS() (bool, error) {
firmware := kernel.Firmware()
log.Info("firmware", "is", firmware)
log.Info("firmware", "is", firmware, "board", s.boardModel, "boardname", s.boardName)

// We must not configure the Bios if UEFI is already activated and the board is one of the following.
if firmware == kernel.EFI && (s.boardModel == X11SDV_8C_TP8F || s.boardModel == X11SDD_8C_F) {
Expand All @@ -222,6 +229,8 @@ func (s *sum) ConfigureBIOS() (bool, error) {
if err != nil {
return false, err
}
log.Info("firmware", "is", firmware, "board", s.boardModel, "boardname", s.boardName, "secureboot", s.secureBootEnabled)

// Secureboot can be set for specific bigtwins, called CSM Support in the bios
// This is so far only possible on these machines, detection requires sum call which downloads the bios.xml
if firmware == kernel.EFI && s.secureBootEnabled {
Expand Down Expand Up @@ -268,7 +277,6 @@ func (s *sum) prepare() error {
return errors.Wrapf(err, "unable to unmarshal BIOS configuration:\n%s", s.biosCfgXML)
}

s.determineMachineType()
s.determineSecureBoot()

return s.findUEFINetworkBootOption()
Expand All @@ -292,15 +300,6 @@ func (s *sum) getCurrentBiosCfg() error {
return nil
}

func (s *sum) determineMachineType() {
bm, ok := boardModels[s.boardName]
if ok {
s.boardModel = bm
} else {
s.boardModel = X11DPT_B
}
}

func (s *sum) determineSecureBoot() {
if s.boardModel == X11SDV_8C_TP8F || s.boardModel == X11SDD_8C_F { // secure boot option is not available in S2 BIOS
return
Expand Down
8 changes: 1 addition & 7 deletions internal/vendors/supermicro/sum_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,12 @@ func TestParseUUIDLine(t *testing.T) {

func TestUnmarshalS2BiosCfg(t *testing.T) {
// given
s := &sum{boardName: "X11SDV-8C-TP8F"}
s, _ := newSum("/bin/true", "X11SDV-8C-TP8F")
s.biosCfgXML = testS2BiosCfg

// when
err := s.unmarshalBiosCfg()

// when
s.determineMachineType()

// then
require.Equal(t, X11SDV_8C_TP8F, s.boardModel)

Expand All @@ -48,9 +45,6 @@ func TestUnmarshalBigTwinBiosCfg(t *testing.T) {
// when
err := s.unmarshalBiosCfg()

// when
s.determineMachineType()

// then
require.Equal(t, X11DPT_B, s.boardModel)

Expand Down

0 comments on commit 3d7b597

Please sign in to comment.