Skip to content

Commit

Permalink
examples: update based on feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
joelrebel committed Jun 27, 2023
1 parent 0793b70 commit 3932529
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions examples/install-firmware/doc.go
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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
Expand Down
12 changes: 6 additions & 6 deletions examples/install-firmware/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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")
Expand All @@ -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)
}
Expand All @@ -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
Expand All @@ -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
}
Expand Down

0 comments on commit 3932529

Please sign in to comment.