From 3932529c84665dbe4973ddf733cd7386b974d43c Mon Sep 17 00:00:00 2001 From: Joel Rebello Date: Tue, 27 Jun 2023 13:30:38 +0200 Subject: [PATCH] examples: update based on feedback --- examples/install-firmware/doc.go | 4 ++-- examples/install-firmware/main.go | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/install-firmware/doc.go b/examples/install-firmware/doc.go index 2e7ae93c..16753bfe 100644 --- a/examples/install-firmware/doc.go +++ b/examples/install-firmware/doc.go @@ -1,5 +1,5 @@ /* -install-firmware is an example commmand that utilizes the 'v1' bmclib interface +install-firmware is an example command that utilizes the 'v1' bmclib interface methods to flash a firmware image to a BMC. Note: The example installs the firmware and polls until the status until the install is complete, @@ -8,7 +8,7 @@ and if required by the install process - power cycles the host. $ go run ./examples/v1/install-firmware/main.go -h Usage of /tmp/go-build2950657412/b001/exe/main: -cert-pool string - Path to an file containing x509 CAs. An empty string uses the system CAs. Only takes effect when --secure-tls=true + Path to an file containing x509 CAs. An empty string uses the system CAs. Only takes effect when -secure-tls=true -firmware string The local path of the firmware to install -host string diff --git a/examples/install-firmware/main.go b/examples/install-firmware/main.go index 57b88995..d1820e0a 100644 --- a/examples/install-firmware/main.go +++ b/examples/install-firmware/main.go @@ -26,7 +26,7 @@ func main() { withSecureTLS := flag.Bool("secure-tls", false, "Enable secure TLS") certPoolPath := flag.String("cert-pool", "", "Path to an file containing x509 CAs. An empty string uses the system CAs. Only takes effect when --secure-tls=true") firmwarePath := flag.String("firmware", "", "The local path of the firmware to install") - //firmwareVersion := flag.String("version", "", "The firmware version being installed") + firmwareVersion := flag.String("version", "", "The firmware version being installed") flag.Parse() @@ -64,7 +64,7 @@ func main() { clientOpts = append(clientOpts, bmclib.WithSecureTLS(pool)) } - cl := bmclib.NewClient(*host, *user, *pass, clientOpts...).PreferProvider("supermicro") + cl := bmclib.NewClient(*host, *user, *pass, clientOpts...) err := cl.Open(ctx) if err != nil { l.Fatal(err, "bmc login failed") @@ -79,7 +79,7 @@ func main() { } defer fh.Close() - _, err = cl.FirmwareInstall(ctx, *component, constants.FirmwareApplyOnReset, true, fh) + taskID, err := cl.FirmwareInstall(ctx, *component, constants.FirmwareApplyOnReset, true, fh) if err != nil { l.Fatal(err) } @@ -89,11 +89,11 @@ func main() { l.Fatal(ctx.Err()) } - state, err := cl.FirmwareInstallStatus(ctx, "", *component, "") + state, err := cl.FirmwareInstallStatus(ctx, *firmwareVersion, *component, taskID) if err != nil { // when its under update a connection refused is returned if strings.Contains(err.Error(), "connection refused") || strings.Contains(err.Error(), "operation timed out") { - l.Info("BMC refused connection, BMC most likely resetting..") + l.Info("BMC refused connection, BMC most likely resetting...") time.Sleep(2 * time.Second) continue @@ -105,7 +105,7 @@ func main() { l.Fatal(err, "bmc re-login failed") } - l.WithFields(logrus.Fields{"state": state, "component": *component}).Info("BMC session expired, logging in..") + l.WithFields(logrus.Fields{"state": state, "component": *component}).Info("BMC session expired, logging in...") continue }