Merge "Debian: KS: Fix mgmt vlan support for system node installs"

This commit is contained in:
Zuul 2022-08-03 18:23:34 +00:00 committed by Gerrit Code Review
commit 9e55a32fcc

View File

@ -1841,7 +1841,7 @@ true
###########################################################################
%post --interpreter=/bin/bash
%post --interpreter=/bin/bash --nochroot
HOOK_LABEL="post"
. /tmp/lat/ks_functions.sh
@ -1869,42 +1869,41 @@ if [ -n "$BOOTIF" ] ; then
# convert to predictive name
mgmt_dev=$(get_iface_from_ethname $ndev)
if [ "${mgmt_dev}" == "" ] ; then
elog "failed to get predictive altname from ${ndev}"
mgmt_dev=${ndev}
# get vlan info for system node installs
system_node=$(is_system_node_install)
if [ "${system_node}" = true ] ; then
# Retrieve the management VLAN from sysinv if it exists
ilog "Querying system inventory for management vlan id"
mgmt_vlan=`curl -sf http://pxecontroller:6385/v1/isystems/mgmtvlan`
if [ ${?} -ne 0 ] ; then
# TODO: uncomment to force install failure for product
# report_failure_with_msg "Unable to communicate with System Inventory REST API. Aborting installation."
wlog "ERROR: Unable to communicate with System Inventory REST API."
fi
report_failure_with_msg "failed to get predictive altname from ${ndev}"
fi
# get vlan info for system node installs
if is_system_node_install -eq 0 ; then
# Retrieve the management VLAN from sysinv if it exists
ilog "Querying system inventory for management vlan id"
mgmt_vlan=`curl -sf http://pxecontroller:6385/v1/isystems/mgmtvlan`
rc=$?
if [ ${rc} -ne 0 ] ; then
report_failure_with_msg "Unable to communicate with System Inventory REST API. Aborting installation. rc:${rc}"
fi
ilog "Management Interface: ${ndev} -> ${mgmt_dev} -> vlan${mgmt_vlan}"
else
ilog "Management Interface: ${ndev} -> ${mgmt_dev}"
fi
else
elog "ERROR:POST: Unable to determine mgmt interface from BOOTIF=$BOOTIF."
report_failure_with_msg "Unable to determine mgmt interface from BOOTIF=$BOOTIF."
fi
else
wlog "BOOTIF is not set. Unable to determine mgmt interface."
fi
if [ ! -e "/etc/network/interfaces" ] ; then
cat << EOF >> /etc/network/interfaces
ilog "mgmt_dev : $mgmt_dev"
ilog "mgmt_vlan: $mgmt_vlan"
if [ ! -e "${IMAGE_ROOTFS}/etc/network/interfaces" ] ; then
cat << EOF >> ${IMAGE_ROOTFS}/etc/network/interfaces
# This file describes the network interfaces available on the system
# and how to activate them. For more information , see interfaces(5)
source /etc/network/interfaces.d/*
source ${IMAGE_ROOTFS}/etc/network/interfaces.d/*
EOF
fi
if [ ! -d "/etc/network/interfaces.d" ] ; then
mkdir -p -m 0775 /etc/network/interfaces.d
if [ ! -d "${IMAGE_ROOTFS}/etc/network/interfaces.d" ] ; then
mkdir -p -m 0775 ${IMAGE_ROOTFS}/etc/network/interfaces.d
fi
ilog "Setup network scripts"
@ -1916,13 +1915,13 @@ if [ $mgmt_vlan -eq 0 ] ; then
update_platform_conf "management_interface=$mgmt_dev"
# Build networking scripts
cat << EOF > /etc/network/interfaces.d/ifcfg-lo
cat << EOF > ${IMAGE_ROOTFS}/etc/network/interfaces.d/ifcfg-lo
auto lo
iface lo inet loopback
EOF
if [ $mgmt_dev != "lo" ]; then
cat << EOF > /etc/network/interfaces.d/ifcfg-$mgmt_dev
cat << EOF > ${IMAGE_ROOTFS}/etc/network/interfaces.d/ifcfg-$mgmt_dev
auto $mgmt_dev
iface $mgmt_dev inet dhcp
post-up echo 0 > /proc/sys/net/ipv6/conf/lo/autoconf; echo 0 > /proc/sys/net/ipv6/conf/lo/accept_ra; echo 0 > /proc/sys/net/ipv6/conf/lo/accept_redirects
@ -1951,7 +1950,7 @@ else
update_platform_conf "management_interface=vlan$mgmt_vlan"
# Build networking scripts
cat << EOF > /etc/network/interfaces.d/ifcfg-lo
cat << EOF > ${IMAGE_ROOTFS}/etc/network/interfaces.d/ifcfg-lo
auto lo
iface lo $mgmt_address_family static
address 127.0.0.1
@ -1959,18 +1958,43 @@ netmask 255.0.0.0
post-up echo 0 > /proc/sys/net/ipv6/conf/lo/autoconf; echo 0 > /proc/sys/net/ipv6/conf/lo/accept_ra; echo 0 > /proc/sys/net/ipv6/conf/lo/accept_redirects
EOF
cat << EOF > /etc/network/interfaces.d/ifcfg-$mgmt_dev
cat << EOF > ${IMAGE_ROOTFS}/etc/network/interfaces.d/ifcfg-$mgmt_dev
auto $mgmt_dev
iface $mgmt_dev $mgmt_address_family manual
post-up echo 0 > /proc/sys/net/ipv6/conf/lo/autoconf; echo 0 > /proc/sys/net/ipv6/conf/lo/accept_ra; echo 0 > /proc/sys/net/ipv6/conf/lo/accept_redirects
EOF
cat << EOF > /etc/network/interfaces.d/ifcfg-vlan$mgmt_vlan
cat << EOF > ${IMAGE_ROOTFS}/etc/network/interfaces.d/ifcfg-vlan$mgmt_vlan
auto vlan$mgmt_vlan
iface vlan$mgmt_vlan $mgmt_address_family dhcp
vlan-raw-device $mgmt_dev
post-up echo 0 > /proc/sys/net/ipv6/conf/lo/autoconf; echo 0 > /proc/sys/net/ipv6/conf/lo/accept_ra; echo 0 > /proc/sys/net/ipv6/conf/lo/accept_redirects
EOF
# Reject DHCPOFFER from DHCP server that doesn't send
# wrs-install-uuid option
echo "require wrs-install-uuid;" >>/etc/dhcp/dhclient.conf
echo "require dhcp6.wrs-install-uuid;" >>/etc/dhcp/dhclient.conf
# Bring up the mgmt vlan so that a dhcp lease is acquired and an address is
# setup prior to the post-install reboot. This is so that the timing of the IP
# address allocation is similar to how normal/non-pxe installation works.
mgmt_iface=vlan$mgmt_vlan
ilog "mgmt_iface=vlan$mgmt_vlan"
ilog "mgmt_address_family: $mgmt_address_family"
dhclient_family=$([[ $mgmt_address_family == "inet" ]] && echo -4 || echo -6)
ilog "dhclient_family: $dhclient_family"
ilog "ip link add link $mgmt_dev name $mgmt_iface type vlan id $mgmt_vlan"
ip link add link $mgmt_dev name $mgmt_iface type vlan id $mgmt_vlan
ilog "ip link set up dev $mgmt_iface"
ilog "dhclient $dhclient_family $mgmt_iface || true"
ip link set up dev $mgmt_iface
dhclient $dhclient_family $mgmt_iface || true
fi
true