iPXE: Fix assumption that ${mac} is the MAC of the NIC it's booting

The ${mac} variable not necessarily points to the MAC address of the NIC
we are booting from. This patch updates the boot.ipxe script to make it
more robust by interating over all NICs found in the machine and boot
from the first one capable of booting (the one that contains a
configuration file in the server). If no NICs are capable of booting the
script will fail just like before telling the user that the network boot
failed because we couldn't find any configuration for the present NICs.

In case the inc command is not found, the boot.ipxe will fall back to
the old behavior.

This backport is the combination of 2 commits (squashed):

(cherry picked from commit 1c28eb79a5)
(cherry picked from commit f968e1a22d)

We need to squash both patches because they must merge at the same time
to avoid breakages.

Closes-Bug: #1507738
Closes-Bug: #1504482
Change-Id: I5b8f0740fa42f611e84b66dc7f6578cffe02760a
This commit is contained in:
Lucas Alvares Gomes 2015-10-09 11:26:13 +01:00
parent 6eb970b71c
commit 35c7f81fa8
2 changed files with 23 additions and 4 deletions

View File

@ -1,10 +1,24 @@
#!ipxe
# load the MAC-specific file or fail if it's not found
chain pxelinux.cfg/${mac:hexhyp} || goto error_no_config
# NOTE(lucasagomes): Loop over all network devices and boot from
# the first one capable of booting. For more information see:
# https://bugs.launchpad.net/ironic/+bug/1504482
set netid:int32 -1
:loop
inc netid || chain pxelinux.cfg/${mac:hexhyp} || goto old_rom
isset ${net${netid}/mac} || goto loop_done
echo Attempting to boot from MAC ${net${netid}/mac:hexhyp}
chain pxelinux.cfg/${net${netid}/mac:hexhyp} || goto loop
:error_no_config
echo PXE boot failed. No configuration found for MAC ${mac}
:loop_done
echo PXE boot failed! No configuration found for any of the present NICs.
echo Press any key to reboot...
prompt --timeout 180
reboot
:old_rom
echo PXE boot failed! No configuration found for NIC ${mac:hexhyp}.
echo Please update your iPXE ROM and retry.
echo Press any key to reboot...
prompt --timeout 180
reboot

View File

@ -0,0 +1,5 @@
---
fixes:
- Make boot.ipxe fallback to its previous behavior on *really* old iPXE
ROMs where 'inc' command is not available at all, see
https://launchpad.net/bugs/1507738.