30 lines
863 B
Go
30 lines
863 B
Go
package models
|
|
|
|
import "strings"
|
|
|
|
// HasInventoryIdentity reports whether the DIMM has enough identifying
|
|
// inventory data to treat it as a populated module even when size is unknown.
|
|
func (m MemoryDIMM) HasInventoryIdentity() bool {
|
|
return strings.TrimSpace(m.SerialNumber) != "" ||
|
|
strings.TrimSpace(m.PartNumber) != "" ||
|
|
strings.TrimSpace(m.Type) != "" ||
|
|
strings.TrimSpace(m.Technology) != "" ||
|
|
strings.TrimSpace(m.Description) != ""
|
|
}
|
|
|
|
// IsInstalledInventory reports whether the DIMM represents an installed module
|
|
// that should be kept in canonical inventory and exports.
|
|
func (m MemoryDIMM) IsInstalledInventory() bool {
|
|
if !m.Present {
|
|
return false
|
|
}
|
|
|
|
status := strings.ToLower(strings.TrimSpace(m.Status))
|
|
switch status {
|
|
case "empty", "absent", "not installed":
|
|
return false
|
|
}
|
|
|
|
return m.SizeMB > 0 || m.HasInventoryIdentity()
|
|
}
|