Change ipxe-boot image to try all interfaces

The current implementation will only try an iPXE
boot from eth0. This patch sets it to try all
interfaces up to 10 attempts, then reboots and
starts again.

Change-Id: I9259a275f5f1f248905755ec5955ace5b67fc2bd
This commit is contained in:
Jesse Pretorius (odyssey4me) 2019-08-12 20:02:19 +01:00 committed by Jiri Stransky
parent d3704c9bc5
commit 23c0c73e5f
1 changed files with 12 additions and 21 deletions

View File

@ -3,14 +3,14 @@
# This is the iPXE boot script that we embed into the iPXE binary. # This is the iPXE boot script that we embed into the iPXE binary.
# #
# The default behaviour is to get DHCP and assume that DHCP includes # The default behaviour is to get DHCP and assume that DHCP includes
# the filename option. If it fails, then it just stops. # the filename option. It will only try eth0. If it fails, then it
# just stops.
# #
# This script implements more retries until both DHCP and the filename # This script makes it attempt to boot from eth0. If that fails, it
# option are present. This makes sure that the underlying network has # will try the next interface. This will retry 10 times before
# plenty of time to be ready. If this still fails, then rather than # rebooting.
# halt, then host will reboot to try again.
# #
# Based on: # Inspired by:
# https://github.com/danderson/netboot/blob/master/pixiecore/boot.ipxe # https://github.com/danderson/netboot/blob/master/pixiecore/boot.ipxe
# #
@ -19,25 +19,16 @@ prompt --key 0x02 --timeout 2000 Press Ctrl-B for the iPXE command line... && sh
set attempts:int32 10 set attempts:int32 10
set x:int32 1 set x:int32 1
:dhcploop :loop
dhcp || goto nodhcp autoboot || goto retry
isset ${filename} || goto nobootconfig
goto boot goto boot
:nodhcp
echo -n No DHCP response
goto retry
:nobootconfig
echo -n No filename option present
goto retry
:retry :retry
echo (attempt ${x}/${attempts}). echo iPXE boot failed, retrying (attempt ${x}/${attempts}).
sleep 1
iseq ${x} ${attempts} && goto fail || iseq ${x} ${attempts} && goto fail ||
inc x inc x
sleep 1 goto loop
goto dhcploop
:boot :boot
echo Booting using ${ifname}. echo Booting using ${ifname}.
@ -53,7 +44,7 @@ echo Set MTU to ${mtu}.
chain ${filename} chain ${filename}
:fail :fail
echo Failed to get a correct DHCP response after ${attempts} attempts. echo Failed to iPXE boot successfully after ${attempts} attempts.
echo echo
echo Rebooting in 5 seconds... echo Rebooting in 5 seconds...
sleep 5 sleep 5