Update wwclient to send hwaddr and asset/uuid tags
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/hpcng/warewulf/internal/pkg/warewulfconf"
|
"github.com/hpcng/warewulf/internal/pkg/warewulfconf"
|
||||||
@@ -49,8 +50,7 @@ func main() {
|
|||||||
if conf.Warewulf.Secure {
|
if conf.Warewulf.Secure {
|
||||||
// Setup local port to something privileged (<1024)
|
// Setup local port to something privileged (<1024)
|
||||||
localTCPAddr.Port = 987
|
localTCPAddr.Port = 987
|
||||||
} else {
|
wwlog.Printf(wwlog.INFO, "Running from trusted port\n")
|
||||||
fmt.Printf("INFO: Running from an insecure port\n")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
webclient := &http.Client{
|
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()
|
sysinfoDump := smbiosDump.SystemInformation()
|
||||||
localUUID, _ := sysinfoDump.UUID()
|
localUUID, _ := sysinfoDump.UUID()
|
||||||
x := smbiosDump.SystemEnclosure()
|
x := smbiosDump.SystemEnclosure()
|
||||||
tag := x.AssetTagNumber()
|
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 {
|
for {
|
||||||
var resp *http.Response
|
var resp *http.Response
|
||||||
counter := 0
|
counter := 0
|
||||||
@@ -81,7 +99,7 @@ func main() {
|
|||||||
for {
|
for {
|
||||||
var err error
|
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)
|
resp, err = webclient.Get(getString)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ initrd --name kmods ${base}/kmods/{{.Hwaddr}}?assetkey=${asset}&uuid=${uuid}
|
|||||||
initrd --name system ${base}/overlay-system/{{.Hwaddr}}?assetkey=${asset}&uuid=${uuid} || goto reboot
|
initrd --name system ${base}/overlay-system/{{.Hwaddr}}?assetkey=${asset}&uuid=${uuid} || goto reboot
|
||||||
initrd --name runtime ${base}/overlay-runtime/{{.Hwaddr}}?assetkey=${asset}&uuid=${uuid} || goto reboot
|
initrd --name runtime ${base}/overlay-runtime/{{.Hwaddr}}?assetkey=${asset}&uuid=${uuid} || goto reboot
|
||||||
|
|
||||||
boot kernel initrd=container initrd=kmods initrd=system initrd=runtime {{.KernelArgs}} || goto reboot
|
boot kernel initrd=container initrd=kmods initrd=system initrd=runtime wwid={{.Hwaddr}} {{.KernelArgs}} || goto reboot
|
||||||
|
|
||||||
:reboot
|
:reboot
|
||||||
echo
|
echo
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ imgextract --name kmods ${base}/kmods/{{.Hwaddr}}?assetkey=${asset}&uuid=${uuid}
|
|||||||
imgextract --name system ${base}/overlay-system/{{.Hwaddr}}?assetkey=${asset}&uuid=${uuid} || goto reboot
|
imgextract --name system ${base}/overlay-system/{{.Hwaddr}}?assetkey=${asset}&uuid=${uuid} || goto reboot
|
||||||
imgextract --name runtime ${base}/overlay-runtime/{{.Hwaddr}}?assetkey=${asset}&uuid=${uuid} || goto reboot
|
imgextract --name runtime ${base}/overlay-runtime/{{.Hwaddr}}?assetkey=${asset}&uuid=${uuid} || goto reboot
|
||||||
|
|
||||||
boot kernel initrd=container initrd=kmods initrd=system initrd=runtime {{.KernelArgs}} || goto reboot
|
boot kernel initrd=container initrd=kmods initrd=system initrd=runtime wwid={{.Hwaddr}} {{.KernelArgs}} || goto reboot
|
||||||
|
|
||||||
:reboot
|
:reboot
|
||||||
echo
|
echo
|
||||||
|
|||||||
Reference in New Issue
Block a user