mirror of
https://github.com/davidallendj/magellan.git
synced 2025-12-20 03:27:03 -07:00
collect: return collection output from CollectInventory()
This commit is contained in:
parent
1477da9693
commit
524a38a475
2 changed files with 10 additions and 48 deletions
10
go.sum
10
go.sum
|
|
@ -124,11 +124,14 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y
|
||||||
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
|
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
|
||||||
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
|
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
|
<<<<<<< HEAD
|
||||||
golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U=
|
golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U=
|
||||||
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
|
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
|
||||||
=======
|
=======
|
||||||
golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=
|
golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=
|
||||||
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
|
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
|
||||||
|
=======
|
||||||
|
>>>>>>> 97a569d (collect: return collection output from CollectInventory())
|
||||||
golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc=
|
golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc=
|
||||||
golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc=
|
golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc=
|
||||||
>>>>>>> 3b85dd3 (chore: fix critical dependabot issues by updating crypto)
|
>>>>>>> 3b85dd3 (chore: fix critical dependabot issues by updating crypto)
|
||||||
|
|
@ -159,11 +162,14 @@ golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
|
<<<<<<< HEAD
|
||||||
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
|
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
|
||||||
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
=======
|
=======
|
||||||
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
|
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
|
||||||
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
|
=======
|
||||||
|
>>>>>>> 97a569d (collect: return collection output from CollectInventory())
|
||||||
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
|
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
|
||||||
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
>>>>>>> 3b85dd3 (chore: fix critical dependabot issues by updating crypto)
|
>>>>>>> 3b85dd3 (chore: fix critical dependabot issues by updating crypto)
|
||||||
|
|
@ -180,9 +186,13 @@ golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||||
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
|
<<<<<<< HEAD
|
||||||
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
|
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
|
||||||
=======
|
=======
|
||||||
>>>>>>> 3b85dd3 (chore: fix critical dependabot issues by updating crypto)
|
>>>>>>> 3b85dd3 (chore: fix critical dependabot issues by updating crypto)
|
||||||
|
=======
|
||||||
|
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
|
||||||
|
>>>>>>> 97a569d (collect: return collection output from CollectInventory())
|
||||||
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
|
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,6 @@ type UpdateParams struct {
|
||||||
// UpdateFirmwareRemote() uses 'gofish' to update the firmware of a BMC node.
|
// UpdateFirmwareRemote() uses 'gofish' to update the firmware of a BMC node.
|
||||||
// The function expects the firmware URL, firmware version, and component flags to be
|
// The function expects the firmware URL, firmware version, and component flags to be
|
||||||
// set from the CLI to perform a firmware update.
|
// set from the CLI to perform a firmware update.
|
||||||
<<<<<<< HEAD
|
|
||||||
// Example:
|
// Example:
|
||||||
// ./magellan update https://192.168.23.40 --username root --password 0penBmc
|
// ./magellan update https://192.168.23.40 --username root --password 0penBmc
|
||||||
// --firmware-url http://192.168.23.19:1337/obmc-phosphor-image.static.mtd.tar
|
// --firmware-url http://192.168.23.19:1337/obmc-phosphor-image.static.mtd.tar
|
||||||
|
|
@ -42,15 +41,12 @@ type UpdateParams struct {
|
||||||
// q.URI https://192.168.23.40
|
// q.URI https://192.168.23.40
|
||||||
// q.TransferProtocol TFTP
|
// q.TransferProtocol TFTP
|
||||||
// q.FirmwarePath http://192.168.23.19:1337/obmc-phosphor-image.static.mtd.tar
|
// q.FirmwarePath http://192.168.23.19:1337/obmc-phosphor-image.static.mtd.tar
|
||||||
=======
|
|
||||||
>>>>>>> 81116ec (refactor: moved internal functions to pkg and updated refs)
|
|
||||||
func UpdateFirmwareRemote(q *UpdateParams) error {
|
func UpdateFirmwareRemote(q *UpdateParams) error {
|
||||||
// parse URI to set up full address
|
// parse URI to set up full address
|
||||||
uri, err := url.ParseRequestURI(q.URI)
|
uri, err := url.ParseRequestURI(q.URI)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to parse URI: %w", err)
|
return fmt.Errorf("failed to parse URI: %w", err)
|
||||||
}
|
}
|
||||||
<<<<<<< HEAD
|
|
||||||
|
|
||||||
// Connect to the Redfish service using gofish
|
// Connect to the Redfish service using gofish
|
||||||
client, err := gofish.Connect(gofish.ClientConfig{Endpoint: uri.String(), Username: q.Username, Password: q.Password, Insecure: q.Insecure})
|
client, err := gofish.Connect(gofish.ClientConfig{Endpoint: uri.String(), Username: q.Username, Password: q.Password, Insecure: q.Insecure})
|
||||||
|
|
@ -77,34 +73,6 @@ func UpdateFirmwareRemote(q *UpdateParams) error {
|
||||||
return fmt.Errorf("firmware update failed: %w", err)
|
return fmt.Errorf("firmware update failed: %w", err)
|
||||||
}
|
}
|
||||||
fmt.Println("Firmware update initiated successfully.")
|
fmt.Println("Firmware update initiated successfully.")
|
||||||
=======
|
|
||||||
uri.User = url.UserPassword(q.Username, q.Password)
|
|
||||||
|
|
||||||
// set up other vars
|
|
||||||
updateUrl := fmt.Sprintf("%s/redfish/v1/UpdateService/Actions/SimpleUpdate", uri.String())
|
|
||||||
headers := map[string]string{
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"cache-control": "no-cache",
|
|
||||||
}
|
|
||||||
b := map[string]any{
|
|
||||||
"UpdateComponent": q.Component, // BMC, BIOS
|
|
||||||
"TransferProtocol": q.TransferProtocol,
|
|
||||||
"ImageURI": q.FirmwarePath,
|
|
||||||
}
|
|
||||||
data, err := json.Marshal(b)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("failed to marshal data: %v", err)
|
|
||||||
}
|
|
||||||
res, body, err := client.MakeRequest(nil, updateUrl, "POST", data, headers)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("something went wrong: %v", err)
|
|
||||||
} else if res == nil {
|
|
||||||
return fmt.Errorf("no response returned (url: %s)", updateUrl)
|
|
||||||
}
|
|
||||||
if len(body) > 0 {
|
|
||||||
fmt.Printf("%d: %v\n", res.StatusCode, string(body))
|
|
||||||
}
|
|
||||||
>>>>>>> 81116ec (refactor: moved internal functions to pkg and updated refs)
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -114,7 +82,6 @@ func GetUpdateStatus(q *UpdateParams) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to parse URI: %w", err)
|
return fmt.Errorf("failed to parse URI: %w", err)
|
||||||
}
|
}
|
||||||
<<<<<<< HEAD
|
|
||||||
|
|
||||||
// Connect to the Redfish service using gofish
|
// Connect to the Redfish service using gofish
|
||||||
client, err := gofish.Connect(gofish.ClientConfig{Endpoint: uri.String(), Username: q.Username, Password: q.Password, Insecure: q.Insecure})
|
client, err := gofish.Connect(gofish.ClientConfig{Endpoint: uri.String(), Username: q.Username, Password: q.Password, Insecure: q.Insecure})
|
||||||
|
|
@ -133,20 +100,5 @@ func GetUpdateStatus(q *UpdateParams) error {
|
||||||
status := updateService.Status
|
status := updateService.Status
|
||||||
fmt.Printf("Update Status: %v\n", status)
|
fmt.Printf("Update Status: %v\n", status)
|
||||||
|
|
||||||
=======
|
|
||||||
uri.User = url.UserPassword(q.Username, q.Password)
|
|
||||||
updateUrl := fmt.Sprintf("%s/redfish/v1/UpdateService", uri.String())
|
|
||||||
res, body, err := client.MakeRequest(nil, updateUrl, "GET", nil, nil)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("something went wrong: %v", err)
|
|
||||||
} else if res == nil {
|
|
||||||
return fmt.Errorf("no response returned (url: %s)", updateUrl)
|
|
||||||
} else if res.StatusCode != http.StatusOK {
|
|
||||||
return fmt.Errorf("returned status code %d", res.StatusCode)
|
|
||||||
}
|
|
||||||
if len(body) > 0 {
|
|
||||||
fmt.Printf("%v\n", string(body))
|
|
||||||
}
|
|
||||||
>>>>>>> 81116ec (refactor: moved internal functions to pkg and updated refs)
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue