Skip to content

Commit

Permalink
Add discover bootScript (#95)
Browse files Browse the repository at this point in the history
This is for DiscoveryOS mode, a new mode of OSIE that offers various
tools to auto-detect and setup hardware during initial rack enrollment
of a server.
  • Loading branch information
mergify[bot] authored Nov 10, 2020
2 parents e400da1 + b24db19 commit 47569a7
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 2 deletions.
77 changes: 75 additions & 2 deletions installers/osie/ipxe_script_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,18 @@ func TestScript(t *testing.T) {
}

var prefaces = map[string]string{
"discover": `echo Packet.net Baremetal - iPXE boot
set iface eth0 || shell
set tinkerbell http://127.0.0.1
set syslog_host 127.0.0.1
set ipxe_cloud_config packet
set action %s
set state %s
set arch %s
set parch %s
set bootdevmac %s
set base-url http://install.ewr1.packet.net/misc/osie/current
`,
"install": `echo Packet.net Baremetal - iPXE boot
set iface eth0 || shell
set tinkerbell http://127.0.0.1
Expand Down Expand Up @@ -126,8 +138,69 @@ set base-url http://install.` + facility + `.packet.net/misc/osie/current
}

var action2Plan2Body = map[string]map[string]string{
"install": installBodies,
"rescue": rescueBodies,
"discover": discoverBodies,
"install": installBodies,
"rescue": rescueBodies,
}

var discoverBodies = map[string]string{
"baremetal_0": `
kernel ${base-url}/vmlinuz-${parch} ip=dhcp modules=loop,squashfs,sd-mod,usb-storage alpine_repo=${base-url}/repo-${arch}/main modloop=${base-url}/modloop-${parch} tinkerbell=${tinkerbell} syslog_host=${syslog_host} parch=${parch} packet_action=${action} packet_state=${state} packet_bootdev_mac=${bootdevmac} facility=` + facility + ` initrd=initramfs-${parch} console=tty0 console=ttyS1,115200
initrd ${base-url}/initramfs-${parch}
boot
`,
"baremetal_1": `
kernel ${base-url}/vmlinuz-${parch} ip=dhcp modules=loop,squashfs,sd-mod,usb-storage alpine_repo=${base-url}/repo-${arch}/main modloop=${base-url}/modloop-${parch} tinkerbell=${tinkerbell} syslog_host=${syslog_host} parch=${parch} packet_action=${action} packet_state=${state} packet_bootdev_mac=${bootdevmac} facility=` + facility + ` initrd=initramfs-${parch} console=tty0 console=ttyS1,115200
initrd ${base-url}/initramfs-${parch}
boot
`,
"baremetal_2": `
kernel ${base-url}/vmlinuz-${parch} ip=dhcp modules=loop,squashfs,sd-mod,usb-storage alpine_repo=${base-url}/repo-${arch}/main modloop=${base-url}/modloop-${parch} tinkerbell=${tinkerbell} syslog_host=${syslog_host} parch=${parch} packet_action=${action} packet_state=${state} packet_bootdev_mac=${bootdevmac} facility=` + facility + ` initrd=initramfs-${parch} console=tty0 console=ttyS1,115200
initrd ${base-url}/initramfs-${parch}
boot
`,
"baremetal_3": `
kernel ${base-url}/vmlinuz-${parch} ip=dhcp modules=loop,squashfs,sd-mod,usb-storage alpine_repo=${base-url}/repo-${arch}/main modloop=${base-url}/modloop-${parch} tinkerbell=${tinkerbell} syslog_host=${syslog_host} parch=${parch} packet_action=${action} packet_state=${state} packet_bootdev_mac=${bootdevmac} facility=` + facility + ` initrd=initramfs-${parch} console=tty0 console=ttyS1,115200
initrd ${base-url}/initramfs-${parch}
boot
`,
"baremetal_2a": `
kernel ${base-url}/vmlinuz-${parch} ip=dhcp modules=loop,squashfs,sd-mod,usb-storage alpine_repo=${base-url}/repo-${arch}/main modloop=${base-url}/modloop-${parch} tinkerbell=${tinkerbell} syslog_host=${syslog_host} parch=${parch} packet_action=${action} packet_state=${state} packet_bootdev_mac=${bootdevmac} facility=` + facility + ` initrd=initramfs-${parch} console=ttyAMA0,115200
initrd ${base-url}/initramfs-${parch}
boot
`,
"baremetal_2a2": `
kernel ${base-url}/vmlinuz-${parch} ip=dhcp modules=loop,squashfs,sd-mod,usb-storage alpine_repo=${base-url}/repo-${arch}/main modloop=${base-url}/modloop-${parch} tinkerbell=${tinkerbell} syslog_host=${syslog_host} parch=${parch} packet_action=${action} packet_state=${state} packet_bootdev_mac=${bootdevmac} facility=` + facility + ` initrd=initramfs-${parch} console=ttyAMA0,115200
initrd ${base-url}/initramfs-${parch}
sleep 15
boot
`,
"baremetal_2a4": `
kernel ${base-url}/vmlinuz-${parch} ip=dhcp modules=loop,squashfs,sd-mod,usb-storage alpine_repo=${base-url}/repo-${arch}/main modloop=${base-url}/modloop-${parch} tinkerbell=${tinkerbell} syslog_host=${syslog_host} parch=${parch} packet_action=${action} packet_state=${state} packet_bootdev_mac=${bootdevmac} facility=` + facility + ` initrd=initramfs-${parch} console=ttyAMA0,115200
initrd ${base-url}/initramfs-${parch}
boot
`,
"baremetal_2a5": `
kernel ${base-url}/vmlinuz-${parch} ip=dhcp modules=loop,squashfs,sd-mod,usb-storage alpine_repo=${base-url}/repo-${arch}/main modloop=${base-url}/modloop-${parch} tinkerbell=${tinkerbell} syslog_host=${syslog_host} parch=${parch} packet_action=${action} packet_state=${state} packet_bootdev_mac=${bootdevmac} facility=` + facility + ` initrd=initramfs-${parch} console=ttyAMA0,115200
initrd ${base-url}/initramfs-${parch}
boot
`,
"baremetal_s": `
kernel ${base-url}/vmlinuz-${parch} ip=dhcp modules=loop,squashfs,sd-mod,usb-storage alpine_repo=${base-url}/repo-${arch}/main modloop=${base-url}/modloop-${parch} tinkerbell=${tinkerbell} syslog_host=${syslog_host} parch=${parch} packet_action=${action} packet_state=${state} packet_bootdev_mac=${bootdevmac} facility=` + facility + ` initrd=initramfs-${parch} console=tty0 console=ttyS1,115200
initrd ${base-url}/initramfs-${parch}
boot
`,
"baremetal_hua": `
kernel ${base-url}/vmlinuz-${parch} ip=dhcp modules=loop,squashfs,sd-mod,usb-storage alpine_repo=${base-url}/repo-${arch}/main modloop=${base-url}/modloop-${parch} tinkerbell=${tinkerbell} syslog_host=${syslog_host} parch=${parch} packet_action=${action} packet_state=${state} packet_bootdev_mac=${bootdevmac} facility=` + facility + ` initrd=initramfs-${parch} console=ttyS0,115200
initrd ${base-url}/initramfs-${parch}
sleep 15
boot
`,
"c2.large.arm": `
kernel ${base-url}/vmlinuz-${parch} ip=dhcp modules=loop,squashfs,sd-mod,usb-storage alpine_repo=${base-url}/repo-${arch}/main modloop=${base-url}/modloop-${parch} tinkerbell=${tinkerbell} syslog_host=${syslog_host} parch=${parch} packet_action=${action} packet_state=${state} packet_bootdev_mac=${bootdevmac} facility=` + facility + ` iommu.passthrough=1 initrd=initramfs-${parch} console=ttyAMA0,115200
initrd ${base-url}/initramfs-${parch}
boot
`,
}

var installBodies = map[string]string{
Expand Down
6 changes: 6 additions & 0 deletions installers/osie/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
func init() {
job.RegisterDefaultInstaller(bootScripts["install"])
job.RegisterDistro("alpine", bootScripts["rescue"])
job.RegisterDistro("discovery", bootScripts["discover"])
}

var bootScripts = map[string]func(job.Job, *ipxe.Script){
Expand All @@ -34,6 +35,11 @@ var bootScripts = map[string]func(job.Job, *ipxe.Script){
s.Set("state", j.HardwareState())
bootScript("install", j, s)
},
"discover": func(j job.Job, s *ipxe.Script) {
s.Set("action", "discover")
s.Set("state", j.HardwareState())
bootScript("discover", j, s)
},
}

func bootScript(action string, j job.Job, s *ipxe.Script) {
Expand Down

0 comments on commit 47569a7

Please sign in to comment.