mirror of
https://github.com/davidallendj/magellan.git
synced 2025-12-20 11:37:01 -07:00
Moved clients back into goroutine and add checks
This commit is contained in:
parent
b610eda4d8
commit
6a59ba2a41
1 changed files with 40 additions and 72 deletions
|
|
@ -130,15 +130,6 @@ func CollectAll(probeStates *[]ScannedResult, l *log.Logger, q *QueryParams) err
|
||||||
NodeBMC: -1,
|
NodeBMC: -1,
|
||||||
}
|
}
|
||||||
|
|
||||||
bmclibClient, err := NewClient(l, q)
|
|
||||||
if err != nil {
|
|
||||||
l.Log.Errorf("could not make client: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
c, err := connectGofish(q)
|
|
||||||
if err != nil {
|
|
||||||
l.Log.Errorf("could not connect to bmc (%v:%v): %v", q.Host, q.Port, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// collect bmc information asynchronously
|
// collect bmc information asynchronously
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
|
|
@ -156,6 +147,16 @@ func CollectAll(probeStates *[]ScannedResult, l *log.Logger, q *QueryParams) err
|
||||||
|
|
||||||
node.NodeBMC += 1
|
node.NodeBMC += 1
|
||||||
|
|
||||||
|
bmclibClient, err := NewClient(l, q)
|
||||||
|
if err != nil {
|
||||||
|
l.Log.Errorf("could not make client: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
gofishClient, err := connectGofish(q)
|
||||||
|
if err != nil {
|
||||||
|
l.Log.Errorf("could not connect to bmc (%v:%v): %v", q.Host, q.Port, err)
|
||||||
|
}
|
||||||
|
|
||||||
// data to be sent to smd
|
// data to be sent to smd
|
||||||
data := map[string]any{
|
data := map[string]any{
|
||||||
"ID": fmt.Sprintf("%v", node.String()[:len(node.String())-2]),
|
"ID": fmt.Sprintf("%v", node.String()[:len(node.String())-2]),
|
||||||
|
|
@ -172,15 +173,18 @@ func CollectAll(probeStates *[]ScannedResult, l *log.Logger, q *QueryParams) err
|
||||||
var rm map[string]json.RawMessage
|
var rm map[string]json.RawMessage
|
||||||
|
|
||||||
// inventories
|
// inventories
|
||||||
|
if bmclibClient != nil {
|
||||||
inventory, err := CollectInventory(bmclibClient, q)
|
inventory, err := CollectInventory(bmclibClient, q)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.Log.Errorf("could not query inventory (%v:%v): %v", q.Host, q.Port, err)
|
l.Log.Errorf("could not query inventory (%v:%v): %v", q.Host, q.Port, err)
|
||||||
}
|
}
|
||||||
json.Unmarshal(inventory, &rm)
|
json.Unmarshal(inventory, &rm)
|
||||||
data["Inventory"] = rm["Inventory"]
|
data["Inventory"] = rm["Inventory"]
|
||||||
|
}
|
||||||
|
|
||||||
// chassis
|
// chassis
|
||||||
chassis, err := CollectChassis(c, q)
|
if gofishClient != nil {
|
||||||
|
chassis, err := CollectChassis(gofishClient, q)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.Log.Errorf("could not query chassis: %v", err)
|
l.Log.Errorf("could not query chassis: %v", err)
|
||||||
continue
|
continue
|
||||||
|
|
@ -188,35 +192,8 @@ func CollectAll(probeStates *[]ScannedResult, l *log.Logger, q *QueryParams) err
|
||||||
json.Unmarshal(chassis, &rm)
|
json.Unmarshal(chassis, &rm)
|
||||||
data["Chassis"] = rm["Chassis"]
|
data["Chassis"] = rm["Chassis"]
|
||||||
|
|
||||||
// ethernet interfaces
|
|
||||||
// interfaces, err := QueryEthernetInterfaces(client, q)
|
|
||||||
// if err != nil {
|
|
||||||
// l.Log.Errorf("could not query ethernet interfaces: %v", err)
|
|
||||||
// continue
|
|
||||||
// }
|
|
||||||
// json.Unmarshal(interfaces, &rm)
|
|
||||||
// data["Interfaces"] = rm["Interfaces"]
|
|
||||||
|
|
||||||
// storage
|
|
||||||
// storage, err := QueryStorage(q)
|
|
||||||
// if err != nil {
|
|
||||||
// l.Log.Errorf("could not query storage: %v", err)
|
|
||||||
// continue
|
|
||||||
// }
|
|
||||||
// json.Unmarshal(storage, &rm)
|
|
||||||
// data["Storage"] = rm["Storage"]
|
|
||||||
|
|
||||||
// get specific processor info
|
|
||||||
// procs, err := QueryProcessors(q)
|
|
||||||
// if err != nil {
|
|
||||||
// l.Log.Errorf("could not query processors: %v", err)
|
|
||||||
// }
|
|
||||||
// var p map[string]interface{}
|
|
||||||
// json.Unmarshal(procs, &p)
|
|
||||||
// data["Processors"] = rm["Processors"]
|
|
||||||
|
|
||||||
// systems
|
// systems
|
||||||
systems, err := CollectSystems(c, q)
|
systems, err := CollectSystems(gofishClient, q)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.Log.Errorf("could not query systems: %v", err)
|
l.Log.Errorf("could not query systems: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -229,16 +206,7 @@ func CollectAll(probeStates *[]ScannedResult, l *log.Logger, q *QueryParams) err
|
||||||
json.Unmarshal(rm["Systems"], &s)
|
json.Unmarshal(rm["Systems"], &s)
|
||||||
data["Name"] = s["Name"]
|
data["Name"] = s["Name"]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// data["Type"] = rm[""]
|
|
||||||
|
|
||||||
// registries
|
|
||||||
// registries, err := QueryRegisteries(q)
|
|
||||||
// if err != nil {
|
|
||||||
// l.Log.Errorf("could not query registries: %v", err)
|
|
||||||
// }
|
|
||||||
// json.Unmarshal(registries, &rm)
|
|
||||||
// data["Registries"] = rm["Registries"]
|
|
||||||
|
|
||||||
headers := make(map[string]string)
|
headers := make(map[string]string)
|
||||||
headers["Content-Type"] = "application/json"
|
headers["Content-Type"] = "application/json"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue