Merge "Support bootstrap_vlan subcloud install value"

This commit is contained in:
Zuul 2022-10-25 21:44:31 +00:00 committed by Gerrit Code Review
commit 51b5cdf9d3

View File

@ -751,6 +751,27 @@ function parse_miniboot_network_params()
;;
esac
# Parse the vlan= line from /proc/cmdline (if it exists):
local vlan=
for arg in \$(cat /proc/cmdline); do
case "\${arg}" in
vlan=*)
vlan=\${arg:5}
ilog "Parsing vlan=\${vlan}"
break
;;
esac
done
if [ -n "\${vlan}" ]; then
# Parameter format: "bootstrap_interface.bootstrap_vlan:bootstrap_interface"
dlog "Parsing vlan from \${vlan}"
vlan=\${vlan#*.} # remove prefix 'bootstrap_interface.'
vlan=\${vlan%:*} # remove suffix ':bootstrap_interface'
BOOTPARAM_VLAN=\${vlan}
BOOTPARAM_IFNAME=\${BOOTPARAM_IFNAME%.*} # remove suffix '.bootstrap_vlan'
fi
logmsg="Using IP values: ip:\$BOOTPARAM_IP_ADDR, family: \$BOOTPARAM_MGMT_ADDRESS_FAMILY"
if [ "\$BOOTPARAM_VLAN" -ne 0 ]; then
logmsg="\$logmsg vlan: \$BOOTPARAM_VLAN, "
@ -1168,7 +1189,12 @@ part_type_first_str="First sector"
part_type_end_str="Last sector"
part_type_flags_str="Attribute flags"
if [ "$(curl -sf http://pxecontroller:6385/v1/upgrade/$(hostname)/in_upgrade 2>/dev/null)" = "true" ]; then
# The /v1/upgrade/${hostname}/in_upgrade endpoint accepts any textual data
# as hostname and returns system-wide upgrade state
hostname="hostname"
if [ "$(curl -sf http://pxecontroller:6385/v1/upgrade/${hostname}/in_upgrade 2>/dev/null)" = "true" ]; then
# In an upgrade, only wipe the disk with the rootfs and boot partition
wlog "In upgrade, wiping only ${INSTDEV}"
@ -1451,9 +1477,9 @@ export INSTW=0
ilog "Setting up initial IP address for ostree pull"
parse_miniboot_network_params
mgmt_dev=$BOOTPARAM_IFNAME
mgmt_vlan=0 # TODO next commit
mgmt_address_family=$BOOTPARAM_MGMT_ADDRESS_FAMILY
mgmt_dev=${BOOTPARAM_IFNAME}
mgmt_vlan=${BOOTPARAM_VLAN}
mgmt_address_family=${BOOTPARAM_MGMT_ADDRESS_FAMILY}
if [ $mgmt_vlan -eq 0 ] ; then
@ -1475,6 +1501,37 @@ if [ $mgmt_vlan -eq 0 ] ; then
ip addr show
ilog "ip route:"
ip ${BOOTPARAM_IP_VER} route show
else
mgmt_iface=vlan${mgmt_vlan}
ilog "mgmt_dev=${mgmt_dev}"
ilog "mgmt_iface=vlan${mgmt_vlan}"
ilog "mgmt_address_family: ${mgmt_address_family}"
ilog "ip ${BOOTPARAM_IP_VER} link add link ${mgmt_dev} name $mgmt_iface type vlan id ${mgmt_vlan}"
ip ${BOOTPARAM_IP_VER} link add link ${mgmt_dev} name $mgmt_iface type vlan id ${mgmt_vlan}
if [ "${mgmt_address_family}" = "inet" ]; then
ilog "ip ${BOOTPARAM_IP_VER} address add ${BOOTPARAM_IP_ADDR}/${BOOTPARAM_PREFIX_LEN} dev ${mgmt_iface}"
ip ${BOOTPARAM_IP_VER} address add ${BOOTPARAM_IP_ADDR}/${BOOTPARAM_PREFIX_LEN} dev ${mgmt_iface}
else
ilog "ip ${BOOTPARAM_IP_VER} address add ${BOOTPARAM_IP_ADDR} dev ${mgmt_iface}"
ip ${BOOTPARAM_IP_VER} address add ${BOOTPARAM_IP_ADDR} dev ${mgmt_iface}
fi
ilog "ip ${BOOTPARAM_IP_VER} link set up dev ${mgmt_dev}"
ip ${BOOTPARAM_IP_VER} link set up dev ${mgmt_dev}
sleep 15
ilog "ip ${BOOTPARAM_IP_VER} link set up dev ${mgmt_iface}"
ip ${BOOTPARAM_IP_VER} link set up dev ${mgmt_iface}
ilog "Wait 10s to settle interface..."
sleep 10
ilog "ip ${BOOTPARAM_IP_VER} route add default ${BOOTPARAM_ROUTE_OPTIONS} dev ${mgmt_dev} ${BOOTPARAM_METRIC}"
ip ${BOOTPARAM_IP_VER} route add default ${BOOTPARAM_ROUTE_OPTIONS} dev ${mgmt_dev} ${BOOTPARAM_METRIC}
ilog "ip ${BOOTPARAM_IP_VER} addr:"
ip ${BOOTPARAM_IP_VER} addr show
ilog "ip ${BOOTPARAM_IP_VER} route:"
ip ${BOOTPARAM_IP_VER} route show
fi
# get the nameserver
local dns="none"
@ -2317,11 +2374,12 @@ ilog "************************************"
ilog "Creating network definitions in /etc/network/interfaces.d"
parse_miniboot_network_params
mgmt_dev=$BOOTPARAM_IFNAME
mgmt_vlan=0 # TODO next commit
mgmt_address_family=$BOOTPARAM_MGMT_ADDRESS_FAMILY
mgmt_dev=${BOOTPARAM_IFNAME}
mgmt_vlan=${BOOTPARAM_VLAN}
mgmt_address_family=${BOOTPARAM_MGMT_ADDRESS_FAMILY}
ilog "mgmt_dev: $mgmt_dev, mgmt_vlan: $mgmt_vlan, mgmt_address_family: $mgmt_address_family"
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
@ -2351,7 +2409,7 @@ EOF
if [ $mgmt_dev != "lo" ]; then
ilog "Creating ${IMAGE_ROOTFS}/etc/network/interfaces.d/ifcfg-$mgmt_dev"
if [ "$BOOTPARAM_MGMT_ADDRESS_FAMILY" == "inet" ]; then
if [ "${mgmt_address_family}" == "inet" ]; then
cat << EOF > ${IMAGE_ROOTFS}/etc/network/interfaces.d/ifcfg-$mgmt_dev
auto $mgmt_dev
iface $mgmt_dev inet static
@ -2359,18 +2417,73 @@ iface $mgmt_dev inet static
gateway $BOOTPARAM_GW
mtu 1500
EOF
else # ipv6
else # inet6
cat << EOF > ${IMAGE_ROOTFS}/etc/network/interfaces.d/ifcfg-$mgmt_dev
auto $mgmt_dev
iface $mgmt_dev inet6 static
address $BOOTPARAM_IP_ADDR/$BOOTPARAM_PREFIX_LEN
mtu 1500
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
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
fi
fi
ilog "Contents of ${IMAGE_ROOTFS}/etc/network/interfaces.d/ifcfg-$mgmt_dev:"
ilog "$(cat "${IMAGE_ROOTFS}/etc/network/interfaces.d/ifcfg-$mgmt_dev")"
else # vlan
ilog "Configuring vlan: mgmt_iface=vlan${mgmt_vlan}"
# Persist the boot device to the platform configuration. This will get
# overwritten later if the management_interface is on a bonded interface.
update_platform_conf "management_interface=vlan${mgmt_vlan}"
# Build networking scripts
cat << EOF > ${IMAGE_ROOTFS}/etc/network/interfaces.d/ifcfg-lo
auto lo
iface lo ${mgmt_address_family} loopback
EOF
if [ "${mgmt_address_family}" == "inet" ]; then
cat << EOF > ${IMAGE_ROOTFS}/etc/network/interfaces.d/ifcfg-$mgmt_dev
auto ${mgmt_dev}
iface ${mgmt_dev} inet manual
post-up echo 0 > /proc/sys/net/ipv4/conf/${mgmt_dev}/autoconf; echo 0 > /proc/sys/net/ipv4/conf/${mgmt_dev}/accept_ra; echo 0 > /proc/sys/net/ipv4/conf/${mgmt_dev}/accept_redirects
EOF
cat << EOF > ${IMAGE_ROOTFS}/etc/network/interfaces.d/ifcfg-vlan${mgmt_vlan}
auto vlan${mgmt_vlan}
iface vlan${mgmt_vlan} inet static
vlan-raw-device ${mgmt_dev}
address ${BOOTPARAM_IP_ADDR}/${BOOTPARAM_PREFIX_LEN}
gateway ${BOOTPARAM_GW}
mtu 1500
post-up echo 0 > /proc/sys/net/ipv4/conf/vlan${mgmt_vlan}/autoconf; echo 0 > /proc/sys/net/ipv4/conf/vlan${mgmt_vlan}/accept_ra; echo 0 > /proc/sys/net/ipv4/conf/vlan${mgmt_vlan}/accept_redirects
EOF
else # inet6
cat << EOF > ${IMAGE_ROOTFS}/etc/network/interfaces.d/ifcfg-${mgmt_dev}
auto ${mgmt_dev}
iface ${mgmt_dev} inet6 manual
post-up echo 0 > /proc/sys/net/ipv6/conf/${mgmt_dev}/autoconf; echo 0 > /proc/sys/net/ipv6/conf/${mgmt_dev}/accept_ra; echo 0 > /proc/sys/net/ipv6/conf/${mgmt_dev}/accept_redirects
EOF
cat << EOF > ${IMAGE_ROOTFS}/etc/network/interfaces.d/ifcfg-vlan${mgmt_vlan}
auto vlan${mgmt_vlan}
iface vlan${mgmt_vlan} inet6 static
vlan-raw-device ${mgmt_dev}
address ${BOOTPARAM_IP_ADDR}/${BOOTPARAM_PREFIX_LEN}
mtu 1500
post-up echo 0 > /proc/sys/net/ipv6/conf/vlan${mgmt_vlan}/autoconf; echo 0 > /proc/sys/net/ipv6/conf/vlan${mgmt_vlan}/accept_ra; echo 0 > /proc/sys/net/ipv6/conf/vlan${mgmt_vlan}/accept_redirects
EOF
fi
fi
ilog "Contents of ${IMAGE_ROOTFS}/etc/network/interfaces.d/ifcfg-lo:"
ilog "$(cat "${IMAGE_ROOTFS}/etc/network/interfaces.d/ifcfg-lo")"
ilog "Contents of ${IMAGE_ROOTFS}/etc/network/interfaces.d/ifcfg-${mgmt_dev}:"
ilog "$(cat "${IMAGE_ROOTFS}/etc/network/interfaces.d/ifcfg-${mgmt_dev}")"
if [ -f "${IMAGE_ROOTFS}/etc/network/interfaces.d/ifcfg-vlan${mgmt_vlan}" ]; then
ilog "Contents of ${IMAGE_ROOTFS}/etc/network/interfaces.d/ifcfg-vlan${mgmt_vlan}:"
ilog "$(cat "${IMAGE_ROOTFS}/etc/network/interfaces.d/ifcfg-vlan${mgmt_vlan}")"
fi
true