mirror of
https://github.com/davidallendj/magellan.git
synced 2025-12-20 03:27:03 -07:00
Added more output messages for handling errors
This commit is contained in:
parent
f4540ea4ce
commit
0f74e1e7f7
1 changed files with 27 additions and 6 deletions
|
|
@ -100,7 +100,7 @@ func CollectAll(probeStates *[]ScannedResult, l *log.Logger, q *QueryParams) err
|
|||
|
||||
gofishClient, err := connectGofish(q)
|
||||
if err != nil {
|
||||
l.Log.Errorf("failed to connect to bmc (%v:%v): %v", q.Host, q.Port, err)
|
||||
l.Log.Errorf("failed to connect to BMC (%v:%v): %v", q.Host, q.Port, err)
|
||||
}
|
||||
|
||||
// data to be sent to smd
|
||||
|
|
@ -145,9 +145,15 @@ func CollectAll(probeStates *[]ScannedResult, l *log.Logger, q *QueryParams) err
|
|||
// add other fields from systems
|
||||
if len(rm["Systems"]) > 0 {
|
||||
var s map[string][]interface{}
|
||||
json.Unmarshal(rm["Systems"], &s)
|
||||
err = json.Unmarshal(rm["Systems"], &s)
|
||||
if err != nil {
|
||||
l.Log.Errorf("failed to unmarshal systems JSON: %v", err)
|
||||
}
|
||||
data["Name"] = s["Name"]
|
||||
}
|
||||
} else {
|
||||
l.Log.Errorf("invalid client (client is nil)")
|
||||
continue
|
||||
}
|
||||
|
||||
headers := make(map[string]string)
|
||||
|
|
@ -349,17 +355,29 @@ func CollectEthernetInterfaces(c *gofish.APIClient, q *QueryParams, systemID str
|
|||
return nil, fmt.Errorf("failed to query storage systems (%v:%v): %v", q.Host, q.Port, err)
|
||||
}
|
||||
|
||||
var interfaces []*redfish.EthernetInterface
|
||||
var (
|
||||
interfaces []*redfish.EthernetInterface
|
||||
errList []error
|
||||
)
|
||||
|
||||
// get all of the ethernet interfaces in our systems
|
||||
for _, system := range systems {
|
||||
i, err := redfish.ListReferencedEthernetInterfaces(c, "/redfish/v1/Systems/"+system.ID+"/EthernetInterfaces/")
|
||||
if err != nil {
|
||||
errList = append(errList, err)
|
||||
continue
|
||||
}
|
||||
interfaces = append(interfaces, i...)
|
||||
}
|
||||
|
||||
if len(interfaces) <= 0 {
|
||||
return nil, fmt.Errorf("failed to get ethernet interfaces: %v", err)
|
||||
// format the error message for printing
|
||||
for i, e := range errList {
|
||||
err = fmt.Errorf("\t[%d] %v\n", i, e)
|
||||
}
|
||||
|
||||
// print any report errors
|
||||
if len(errList) > 0 {
|
||||
return nil, fmt.Errorf("failed to get ethernet interfaces with %d errors: \n%v", len(errList), err)
|
||||
}
|
||||
|
||||
data := map[string]any{"EthernetInterfaces": interfaces}
|
||||
|
|
@ -425,7 +443,10 @@ func CollectSystems(c *gofish.APIClient, q *QueryParams) ([]byte, error) {
|
|||
continue
|
||||
}
|
||||
var i map[string]any
|
||||
json.Unmarshal(interfaces, &i)
|
||||
err = json.Unmarshal(interfaces, &i)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to unmarshal interface: %v", err)
|
||||
}
|
||||
temp = append(temp, map[string]any{
|
||||
"Data": system,
|
||||
"EthernetInterfaces": i["EthernetInterfaces"],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue