Skip to content

Commit

Permalink
Merge pull request #242 from UnityDG/master
Browse files Browse the repository at this point in the history
Add baseboard product lookup for linux/windows
  • Loading branch information
jaypipes authored May 11, 2021
2 parents 5ebee3b + eeaff74 commit a51228b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
9 changes: 8 additions & 1 deletion pkg/baseboard/baseboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type Info struct {
SerialNumber string `json:"serial_number"`
Vendor string `json:"vendor"`
Version string `json:"version"`
Product string `json:"product"`
}

func (i *Info) String() string {
Expand All @@ -38,11 +39,17 @@ func (i *Info) String() string {
versionStr = " version=" + i.Version
}

productStr := ""
if i.Product != "" {
productStr = " product=" + i.Product
}

res := fmt.Sprintf(
"baseboard%s%s%s",
"baseboard%s%s%s%s",
vendorStr,
serialStr,
versionStr,
productStr,
)
return res
}
Expand Down
1 change: 1 addition & 0 deletions pkg/baseboard/baseboard_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ func (i *Info) load() error {
i.SerialNumber = linuxdmi.Item(i.ctx, "board_serial")
i.Vendor = linuxdmi.Item(i.ctx, "board_vendor")
i.Version = linuxdmi.Item(i.ctx, "board_version")
i.Product = linuxdmi.Item(i.ctx, "board_name")

return nil
}
4 changes: 3 additions & 1 deletion pkg/baseboard/baseboard_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ import (
"github.com/StackExchange/wmi"
)

const wqlBaseboard = "SELECT Manufacturer, SerialNumber, Tag, Version FROM Win32_BaseBoard"
const wqlBaseboard = "SELECT Manufacturer, SerialNumber, Tag, Version, Product FROM Win32_BaseBoard"

type win32Baseboard struct {
Manufacturer *string
SerialNumber *string
Tag *string
Version *string
Product *string
}

func (i *Info) load() error {
Expand All @@ -29,6 +30,7 @@ func (i *Info) load() error {
i.SerialNumber = *win32BaseboardDescriptions[0].SerialNumber
i.Vendor = *win32BaseboardDescriptions[0].Manufacturer
i.Version = *win32BaseboardDescriptions[0].Version
i.Product = *win32BaseboardDescriptions[0].Product
}

return nil
Expand Down

0 comments on commit a51228b

Please sign in to comment.