mirror of
https://github.com/davidallendj/magellan.git
synced 2025-12-20 11:37:01 -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)
|
gofishClient, err := connectGofish(q)
|
||||||
if err != nil {
|
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
|
// 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
|
// add other fields from systems
|
||||||
if len(rm["Systems"]) > 0 {
|
if len(rm["Systems"]) > 0 {
|
||||||
var s map[string][]interface{}
|
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"]
|
data["Name"] = s["Name"]
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
l.Log.Errorf("invalid client (client is nil)")
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
headers := make(map[string]string)
|
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)
|
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 {
|
for _, system := range systems {
|
||||||
i, err := redfish.ListReferencedEthernetInterfaces(c, "/redfish/v1/Systems/"+system.ID+"/EthernetInterfaces/")
|
i, err := redfish.ListReferencedEthernetInterfaces(c, "/redfish/v1/Systems/"+system.ID+"/EthernetInterfaces/")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
errList = append(errList, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
interfaces = append(interfaces, i...)
|
interfaces = append(interfaces, i...)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(interfaces) <= 0 {
|
// format the error message for printing
|
||||||
return nil, fmt.Errorf("failed to get ethernet interfaces: %v", err)
|
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}
|
data := map[string]any{"EthernetInterfaces": interfaces}
|
||||||
|
|
@ -425,7 +443,10 @@ func CollectSystems(c *gofish.APIClient, q *QueryParams) ([]byte, error) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
var i map[string]any
|
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{
|
temp = append(temp, map[string]any{
|
||||||
"Data": system,
|
"Data": system,
|
||||||
"EthernetInterfaces": i["EthernetInterfaces"],
|
"EthernetInterfaces": i["EthernetInterfaces"],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue