Added ability to update endpoint when conflicting with existing + processor info

Signed-off-by: David J. Allen <allend@lanl.gov>
This commit is contained in:
David J. Allen 2023-09-28 14:46:21 -06:00
parent 2bfc42a064
commit 54dde2dda6
4 changed files with 130 additions and 37 deletions

View file

@ -5,6 +5,7 @@ package smd
// https://github.com/alexlovelltroy/hms-smd
import (
"fmt"
"net/http"
"github.com/bikeshack/magellan/internal/util"
// hms "github.com/alexlovelltroy/hms-smd"
@ -47,17 +48,34 @@ func AddRedfishEndpoint(data []byte, headers map[string]string) error {
return fmt.Errorf("could not add redfish endpoint: no data found")
}
// var ep hms.RedfishEP
// _ = ep
// Add redfish endpoint via POST `/hsm/v2/Inventory/RedfishEndpoints` endpoint
url := makeEndpointUrl("/Inventory/RedfishEndpoints")
res, body, _ := util.MakeRequest(url, "POST", data, headers)
res, body, err := util.MakeRequest(url, "POST", data, headers)
fmt.Printf("smd url: %v\n", url)
fmt.Printf("res: %v %v\n", res.StatusCode, res.Status)
fmt.Printf("res: %v\n", res.Status)
fmt.Printf("body: %v\n", string(body))
return nil
if res != nil {
if res.StatusCode != http.StatusOK {
return fmt.Errorf("could not add redfish endpoint")
}
}
return err
}
func UpdateRedfishEndpoint() {
func UpdateRedfishEndpoint(xname string, data []byte, headers map[string]string) error {
if data == nil {
return fmt.Errorf("could not add redfish endpoint: no data found")
}
// Update redfish endpoint via PUT `/hsm/v2/Inventory/RedfishEndpoints` endpoint
url := makeEndpointUrl("/Inventory/RedfishEndpoints/" + xname)
res, body, err := util.MakeRequest(url, "PUT", data, headers)
fmt.Printf("smd url: %v\n", url)
fmt.Printf("res: %v\n", res.Status)
fmt.Printf("body: %v\n", string(body))
if res != nil {
if res.StatusCode != http.StatusOK {
return fmt.Errorf("could not update redfish endpoint")
}
}
return err
}