Merge pull request #1112 from MiddelkoopT/tm-wwid-raspberry-pi

Get wwid from interface not /proc/cmdline when wwid=[interface] is set
This commit is contained in:
Christian Goll
2024-03-12 19:33:41 +01:00
committed by GitHub
2 changed files with 20 additions and 0 deletions

View File

@@ -9,6 +9,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Add the ability to boot nodes with `wwid=[interface]`, which replaces
`interface` with the interface MAC address
## [4.5.0] 2024-02-08
### Added
- Added https://github.com/Masterminds/sprig functions to templates #1030
### Changed

View File

@@ -152,6 +152,19 @@ func CobraRunE(cmd *cobra.Command, args []string) (err error) {
}
wwid := strings.Split(wwid_tmp[1], " ")[0]
wwid = strings.TrimSuffix(wwid, "\n")
// Dereference wwid from [interface] for cases that cannot have /proc/cmdline set by bootloader
if string(wwid[0]) == "[" {
iface := wwid[1 : len(wwid)-1]
wwid_tmp, err := os.ReadFile(fmt.Sprintf("/sys/class/net/%s/address", iface))
if err != nil {
wwlog.Error("'wwid' cannot be dereferenced from /sys/class/net", iface)
os.Exit(1)
}
wwid = strings.TrimSuffix(string(wwid_tmp), "\n")
wwlog.Info("Dereferencing wwid from [%s] to %s", iface, wwid)
}
duration := 300
if conf.Warewulf.UpdateInterval > 0 {