From 8d1695fa6a1e318300cffc87b0bce0a84f41cfc9 Mon Sep 17 00:00:00 2001 From: Saul Wold Date: Mon, 30 Mar 2020 12:07:19 -0700 Subject: [PATCH] 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 --- bsp-files/kickstarts/post_net_common.cfg | 12 ++++-------- bsp-files/kickstarts/post_pxeboot_controller.cfg | 12 ++++-------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/bsp-files/kickstarts/post_net_common.cfg b/bsp-files/kickstarts/post_net_common.cfg index 8b854ff9..3ca9f7d5 100755 --- a/bsp-files/kickstarts/post_net_common.cfg +++ b/bsp-files/kickstarts/post_net_common.cfg @@ -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 diff --git a/bsp-files/kickstarts/post_pxeboot_controller.cfg b/bsp-files/kickstarts/post_pxeboot_controller.cfg index 6e6d0c6b..cf76f145 100644 --- a/bsp-files/kickstarts/post_pxeboot_controller.cfg +++ b/bsp-files/kickstarts/post_pxeboot_controller.cfg @@ -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