Skip to content

Commit

Permalink
Merge pull request #1243 from threefoldtech/development_proxy_outofsp…
Browse files Browse the repository at this point in the history
…ec-dmi-memory

skip the empty slots & handle the out of spec memory type
  • Loading branch information
Omarabdul3ziz authored Dec 8, 2024
2 parents 22c5317 + e5f240c commit aac7301
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions grid-proxy/internal/indexer/dmi.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ import (

const (
DmiCallCmd = "zos.system.dmi"

outOfSpec = "<OUT OF SPEC>"
unknown = "Unknown"
other = "Other"
)

type DMIWork struct {
Expand Down Expand Up @@ -40,7 +44,6 @@ func (w *DMIWork) Get(ctx context.Context, rmb *peer.RpcClient, twinId uint32) (

res := parseDmiResponse(dmi, twinId)
return []types.Dmi{res}, nil

}

func (w *DMIWork) Upsert(ctx context.Context, db db.Database, batch []types.Dmi) error {
Expand All @@ -63,11 +66,20 @@ func parseDmiResponse(dmiResponse zosDmiTypes.DMI, twinId uint32) types.Dmi {
if sec.TypeStr == "MemoryDevice" {
for _, subSec := range sec.SubSections {
if subSec.Title == "Memory Device" {
if subSec.Properties["Type"].Val == "Unknown" {
// skips the empty slots
if subSec.Properties["Type"].Val == other &&
subSec.Properties["Manufacturer"].Val == unknown {
continue
}

// proper unknown memory type
memType := subSec.Properties["Type"].Val
if memType == outOfSpec {
memType = unknown
}

info.Memory = append(info.Memory, types.Memory{
Type: subSec.Properties["Type"].Val,
Type: memType,
Manufacturer: subSec.Properties["Manufacturer"].Val,
})
}
Expand Down

0 comments on commit aac7301

Please # to comment.