Refactor bee CLI and LiveCD integration
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
package collector
|
||||
|
||||
import (
|
||||
"bee/audit/internal/runtimeenv"
|
||||
"bee/audit/internal/schema"
|
||||
"log/slog"
|
||||
"time"
|
||||
@@ -11,7 +12,7 @@ import (
|
||||
|
||||
// Run executes all collectors and returns the combined snapshot.
|
||||
// Partial failures are logged as warnings; collection always completes.
|
||||
func Run() schema.HardwareIngestRequest {
|
||||
func Run(runtimeMode runtimeenv.Mode) schema.HardwareIngestRequest {
|
||||
start := time.Now()
|
||||
slog.Info("audit started")
|
||||
|
||||
@@ -39,7 +40,7 @@ func Run() schema.HardwareIngestRequest {
|
||||
|
||||
slog.Info("audit completed", "duration", time.Since(start).Round(time.Millisecond))
|
||||
|
||||
sourceType := "livcd"
|
||||
sourceType := string(runtimeMode)
|
||||
protocol := "os-direct"
|
||||
|
||||
return schema.HardwareIngestRequest{
|
||||
|
||||
@@ -27,6 +27,9 @@ type nvidiaGPUInfo struct {
|
||||
// If the driver/tool is unavailable, NVIDIA devices get UNKNOWN status and
|
||||
// a stable serial fallback based on board serial + slot.
|
||||
func enrichPCIeWithNVIDIA(devs []schema.HardwarePCIeDevice, boardSerial string) []schema.HardwarePCIeDevice {
|
||||
if !hasNVIDIADevices(devs) {
|
||||
return devs
|
||||
}
|
||||
gpuByBDF, err := queryNVIDIAGPUs()
|
||||
if err != nil {
|
||||
slog.Info("nvidia: enrichment skipped", "err", err)
|
||||
@@ -35,6 +38,15 @@ func enrichPCIeWithNVIDIA(devs []schema.HardwarePCIeDevice, boardSerial string)
|
||||
return enrichPCIeWithNVIDIAData(devs, gpuByBDF, boardSerial, true)
|
||||
}
|
||||
|
||||
func hasNVIDIADevices(devs []schema.HardwarePCIeDevice) bool {
|
||||
for _, dev := range devs {
|
||||
if isNVIDIADevice(dev) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func enrichPCIeWithNVIDIAData(devs []schema.HardwarePCIeDevice, gpuByBDF map[string]nvidiaGPUInfo, boardSerial string, driverLoaded bool) []schema.HardwarePCIeDevice {
|
||||
enriched := 0
|
||||
for i := range devs {
|
||||
|
||||
Reference in New Issue
Block a user