Merge pull request #1109 from MiddelkoopT/tm-smbios-raspberry-pi

Add support for machines that do not have a SMBIOS
This commit is contained in:
Christian Goll
2024-03-11 10:26:19 +01:00
committed by GitHub
3 changed files with 26 additions and 9 deletions

View File

@@ -15,7 +15,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Locally defined `tr` has been dropped, templates updated to use Sprig replace.
## [4.5.0]
### Fixed
- Systems with no SMBIOS (Raspberry Pi) will create a UUID from
`/sys/firmware/devicetree/base/serial-number`
## [4.5.0] 2024-02-08
- Official v4.5.0 release.
- Publish v4.5.x documentation separately from `main`. #919

View File

@@ -32,3 +32,4 @@
* Andreas Skau <andreas@scheen.no> @buzh
* Dietmar Rieder <dietmar.rieder@i-med.ac.at>
* Andreas Henkel <henkel@uni-mainz.de>
* Timothy Middelkoop <tmiddelkoop@internet2.edu>

View File

@@ -118,15 +118,26 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) {
ExpectContinueTimeout: 1 * time.Second,
},
}
smbiosDump, err := smbios.New()
if err != nil {
wwlog.Error("Could not get SMBIOS info: %s", err)
os.Exit(1)
var localUUID uuid.UUID
var tag string
smbiosDump, smbiosErr := smbios.New()
if smbiosErr == nil {
sysinfoDump := smbiosDump.SystemInformation()
localUUID, _ = sysinfoDump.UUID()
x := smbiosDump.SystemEnclosure()
tag = strings.ReplaceAll(x.AssetTagNumber(), " ", "_")
} else {
// Raspberry Pi serial and DUID locations
// /sys/firmware/devicetree/base/serial-number
// /sys/firmware/devicetree/base/chosen/rpi-duid
piSerial, err := os.ReadFile("/sys/firmware/devicetree/base/serial-number")
if err != nil {
wwlog.Error("Could not get SMBIOS info: %s", smbiosErr)
os.Exit(1)
}
localUUID = uuid.NewSHA1(uuid.NameSpaceURL, []byte("http://raspberrypi.com/serial-number/"+string(piSerial)))
tag = "Unknown"
}
sysinfoDump := smbiosDump.SystemInformation()
localUUID, _ := sysinfoDump.UUID()
x := smbiosDump.SystemEnclosure()
tag := strings.ReplaceAll(x.AssetTagNumber(), " ", "_")
cmdline, err := os.ReadFile("/proc/cmdline")
if err != nil {