Convert BOOTIF MAC to NIC name

When booting via PXE one can set the ksdevice=bootif and add
'IPAPPEND 2' to the PXE boot config, this will set the MAC
address in the BOOTIF kernel cmdline which can then be used to
determine the NIC name to be used for the installation.

Tested with both valid and invalid input to BOOTIF=

Story: 2007486
Task: 39205
Change-Id: Iec1e8215571a6bb8fb79a461ce9210dddf2c764f
Signed-off-by: Saul Wold <sgw@linux.intel.com>
This commit is contained in:
Saul Wold 2020-03-30 12:07:19 -07:00
parent 980720173a
commit 8d1695fa6a
2 changed files with 8 additions and 16 deletions

View File

@ -22,18 +22,14 @@ echo "repo --name=updates --baseurl=http://pxecontroller:${http_port:-8080}/upda
echo http_port=$(get_http_port) >> /etc/platform/platform.conf
# Obtain the boot interface from the PXE boot
BOOTIF=`cat /proc/cmdline |xargs -n1 echo |grep BOOTIF=`
if [ -d /sys/firmware/efi ] ; then
BOOTIF=${BOOTIF#BOOTIF=}
else
BOOTIF=${BOOTIF#BOOTIF=01-}
BOOTIF=${BOOTIF//-/:}
fi
BOOTIF=$(cat /proc/cmdline |xargs -n1 echo |grep BOOTIF=)
BOOTIF=${BOOTIF#BOOTIF=}
mgmt_dev=none
mgmt_vlan=0
if [ -n "$BOOTIF" ] ; then
ndev=`ip link show |grep -B 1 $BOOTIF |head -1 |awk '{print $2}' |sed -e 's/://'`
BOOTIF=$(echo $BOOTIF | sed -r -e 's/.*(..-..-..-..-..-..)$/\1/' -e 's/-/:/g')
ndev=$(ip -br link | awk -v mac="$BOOTIF" '$0 ~ mac {print $1}')
if [ -n "$ndev" ] ; then
mgmt_dev=$ndev
# Retrieve the management VLAN from sysinv if it exists

View File

@ -17,17 +17,13 @@ echo "repo --name=updates --baseurl=xxxHTTP_URLxxx/patches/" > /tmp/repo-include
. /tmp/ks-functions.sh
# Obtain the boot interface from the PXE boot
BOOTIF=`cat /proc/cmdline |xargs -n1 echo |grep BOOTIF=`
if [ -d /sys/firmware/efi ] ; then
BOOTIF=${BOOTIF#BOOTIF=}
else
BOOTIF=${BOOTIF#BOOTIF=01-}
BOOTIF=${BOOTIF//-/:}
fi
BOOTIF=$(cat /proc/cmdline |xargs -n1 echo |grep BOOTIF=)
BOOTIF=${BOOTIF#BOOTIF=}
mgmt_dev=none
if [ -n "$BOOTIF" ] ; then
ndev=`ip link show |grep -B 1 $BOOTIF |head -1 |awk '{print $2}' |sed -e 's/://'`
BOOTIF=$(echo $BOOTIF | sed -r -e 's/.*(..-..-..-..-..-..)$/\1/' -e 's/-/:/g')
ndev=$(ip -br link | awk -v mac="$BOOTIF" '$0 ~ mac {print $1}')
if [ -n "$ndev" ] ; then
mgmt_dev=$ndev