Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SetBiosFromFile #403

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bmc/bios.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func SetBiosConfigurationFromFileInterfaces(ctx context.Context, generic []inter
temp.BiosConfigurationSetter = p
implementations = append(implementations, temp)
default:
e := fmt.Sprintf("not a BiosConfigurationSetter implementation: %T", p)
e := fmt.Sprintf("not a BiosConfigurationSetterFromFile implementation: %T", p)
err = multierror.Append(err, errors.New(e))
}
}
Expand All @@ -219,7 +219,7 @@ func SetBiosConfigurationFromFileInterfaces(ctx context.Context, generic []inter
err,
errors.Wrap(
bmclibErrs.ErrProviderImplementation,
("no BiosConfigurationSetter implementations found"),
("no BiosConfigurationSetterFromFile implementations found"),
),
)
}
Expand Down
26 changes: 5 additions & 21 deletions examples/bios/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,29 +93,14 @@ func main() {
l.Error(err)
}
case "setfile":
exampleConfig := make(map[string]string)

if *dfile != "" {
cfgFile, err := os.Open(*dfile)
if err != nil {
l.Fatal(err)
}

defer cfgFile.Close()
fmt.Println("Attempting to set BIOS configuration:")

jsonData, _ := io.ReadAll(cfgFile)
err = json.Unmarshal(jsonData, &exampleConfig)
if err != nil {
l.Error(err)
}
} else {
exampleConfig["TpmSecurity"] = "Off"
contents, err := os.ReadFile(*dfile)
if err != nil {
l.Fatal(err)
}

fmt.Println("Attempting to set BIOS configuration:")
fmt.Printf("exampleConfig: %+v\n", exampleConfig)

err := client.SetBiosConfiguration(ctx, exampleConfig)
err = client.SetBiosConfigurationFromFile(ctx, string(contents))
if err != nil {
l.Error(err)
}
Expand All @@ -126,6 +111,5 @@ func main() {
}
default:
l.Fatal("Unknown mode: " + *mode)

}
}
2 changes: 1 addition & 1 deletion providers/supermicro/supermicro.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ func (c *Client) SetBiosConfiguration(ctx context.Context, biosConfig map[string
}

// SetBiosConfigurationFromFile sets the bios configuration from a raw vendor config file
func (c *Client) SetBIOSConfigurationFromFile(ctx context.Context, cfg string) (err error) {
func (c *Client) SetBiosConfigurationFromFile(ctx context.Context, cfg string) (err error) {
if c.serviceClient == nil || c.serviceClient.sum == nil {
return errors.Wrap(bmclibErrs.ErrLoginFailed, "client not initialized")
}
Expand Down
Loading