mirror of
https://github.com/davidallendj/magellan.git
synced 2025-12-20 03:27:03 -07:00
Modified update command and implementation
This commit is contained in:
parent
62dd01e1ca
commit
5b390a65c2
2 changed files with 100 additions and 19 deletions
|
|
@ -8,9 +8,13 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
host string
|
||||
port int
|
||||
firmwarePath string
|
||||
firmwareVersion string
|
||||
component string
|
||||
transferProtocol string
|
||||
status bool
|
||||
)
|
||||
|
||||
var updateCmd = &cobra.Command{
|
||||
|
|
@ -22,17 +26,39 @@ var updateCmd = &cobra.Command{
|
|||
FirmwarePath: firmwarePath,
|
||||
FirmwareVersion: firmwareVersion,
|
||||
Component: component,
|
||||
TransferProtocol: transferProtocol,
|
||||
QueryParams: magellan.QueryParams{
|
||||
Drivers: []string{"redfish"},
|
||||
Preferred: "redfish",
|
||||
Host: host,
|
||||
User: user,
|
||||
Pass: pass,
|
||||
Timeout: timeout,
|
||||
Port: port,
|
||||
WithSecureTLS: withSecureTLS,
|
||||
},
|
||||
}
|
||||
client, err := magellan.NewClient(l, &q.QueryParams)
|
||||
if err != nil {
|
||||
l.Log.Errorf("could not make client: %v", err)
|
||||
|
||||
// check if required params are set
|
||||
if host == "" || user == "" || pass == "" {
|
||||
l.Log.Fatal("requires host, user, and pass to be set")
|
||||
}
|
||||
err = magellan.UpdateFirmware(client, l, q)
|
||||
|
||||
// get status if flag is set and exit
|
||||
if status {
|
||||
err := magellan.GetUpdateStatus(q)
|
||||
if err != nil {
|
||||
l.Log.Errorf("could not get update status: %v", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// client, err := magellan.NewClient(l, &q.QueryParams)
|
||||
// if err != nil {
|
||||
// l.Log.Errorf("could not make client: %v", err)
|
||||
// }
|
||||
// err = magellan.UpdateFirmware(client, l, q)
|
||||
err := magellan.UpdateFirmwareRemote(q)
|
||||
if err != nil {
|
||||
l.Log.Errorf("could not update firmware: %v", err)
|
||||
}
|
||||
|
|
@ -40,10 +66,15 @@ var updateCmd = &cobra.Command{
|
|||
}
|
||||
|
||||
func init() {
|
||||
updateCmd.PersistentFlags().StringVar(&user, "user", "", "set the BMC user")
|
||||
updateCmd.PersistentFlags().StringVar(&pass, "pass", "", "set the BMC password")
|
||||
updateCmd.PersistentFlags().StringVar(&firmwarePath, "firmware-path", "", "set the path to the firmware")
|
||||
updateCmd.PersistentFlags().StringVar(&firmwareVersion, "firmware-version", "", "set the version of firmware to be installed")
|
||||
updateCmd.PersistentFlags().StringVar(&component, "component", "", "set the component to upgrade")
|
||||
updateCmd.Flags().StringVar(&host, "host", "", "set the BMC host")
|
||||
updateCmd.Flags().IntVar(&port, "port", 443, "set the BMC port")
|
||||
updateCmd.Flags().StringVar(&user, "user", "", "set the BMC user")
|
||||
updateCmd.Flags().StringVar(&pass, "pass", "", "set the BMC password")
|
||||
updateCmd.Flags().StringVar(&transferProtocol, "protocol", "HTTP", "set the transfer protocol")
|
||||
updateCmd.Flags().StringVar(&firmwarePath, "firmware-path", "", "set the path to the firmware")
|
||||
updateCmd.Flags().StringVar(&firmwareVersion, "firmware-version", "", "set the version of firmware to be installed")
|
||||
updateCmd.Flags().StringVar(&component, "component", "", "set the component to upgrade")
|
||||
updateCmd.Flags().BoolVar(&withSecureTLS, "secure-tls", false, "enable secure TLS")
|
||||
updateCmd.Flags().BoolVar(&status, "status", false, "get the status of the update")
|
||||
rootCmd.AddCommand(updateCmd)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue