Update wwclient to send hwaddr and asset/uuid tags
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/hpcng/warewulf/internal/pkg/warewulfconf"
|
||||
@@ -49,8 +50,7 @@ func main() {
|
||||
if conf.Warewulf.Secure {
|
||||
// Setup local port to something privileged (<1024)
|
||||
localTCPAddr.Port = 987
|
||||
} else {
|
||||
fmt.Printf("INFO: Running from an insecure port\n")
|
||||
wwlog.Printf(wwlog.INFO, "Running from trusted port\n")
|
||||
}
|
||||
|
||||
webclient := &http.Client{
|
||||
@@ -68,12 +68,30 @@ func main() {
|
||||
},
|
||||
}
|
||||
|
||||
smbiosDump, _ := smbios.New()
|
||||
smbiosDump, err := smbios.New()
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Could not get SMBIOS info: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
sysinfoDump := smbiosDump.SystemInformation()
|
||||
localUUID, _ := sysinfoDump.UUID()
|
||||
x := smbiosDump.SystemEnclosure()
|
||||
tag := x.AssetTagNumber()
|
||||
|
||||
cmdline, err := os.ReadFile("/proc/cmdline")
|
||||
if err != nil {
|
||||
wwlog.Printf(wwlog.ERROR, "Could not read from /proc/cmdline: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
wwid_tmp := strings.Split(string(cmdline), "wwid=")
|
||||
if len(wwid_tmp) < 2 {
|
||||
wwlog.Printf(wwlog.ERROR, "'wwid' is not defined in /proc/cmdline\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
wwid := strings.Split(wwid_tmp[1], " ")[0]
|
||||
|
||||
for {
|
||||
var resp *http.Response
|
||||
counter := 0
|
||||
@@ -81,7 +99,7 @@ func main() {
|
||||
for {
|
||||
var err error
|
||||
|
||||
getString := fmt.Sprintf("http://%s:%d/overlay-runtime?assetkey=%s&uuid=%s", conf.Ipaddr, conf.Warewulf.Port, tag, localUUID)
|
||||
getString := fmt.Sprintf("http://%s:%d/overlay-runtime/%s?assetkey=%s&uuid=%s", conf.Ipaddr, conf.Warewulf.Port, wwid, tag, localUUID)
|
||||
resp, err = webclient.Get(getString)
|
||||
if err == nil {
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user