Merge "Select a valid management gateway"

This commit is contained in:
Zuul 2024-06-26 14:20:08 +00:00 committed by Gerrit Code Review
commit 34d9a015be

View File

@ -2646,7 +2646,22 @@ if [ -n "${BOOTIF}" ] ; then
if [ -z "${mgmt_ip}" -o "${mgmt_ip}" == "None" -o -z "${mgmt_nm}" -o "${mgmt_nm}" = "None" ] ; then
report_failure_with_msg "Unable to parse management ip and netmask from sysinv queried mgmt_ip info : value:${host_info}. Aborting Installation."
else
# the mgmt floating address is running on the active controller, so it is our gateway
mgmt_gw=$(echo "${host_info}" | grep -o '"floating": "[^"]*' | cut -d'"' -f4)
if [ -z "${mgmt_gw}" -o "${mgmt_gw}" == "None" ] ; then
ilog "invalid mgmt_gw=${mgmt_gw}, extrapolate gateway from ${mgmt_ip}"
# this step is done only to have a valid address value for mgmt_gw, to not create
# parsing errors for ifupdown, no need to interrupt installation, as all traffic
# post install will run locally on the management network until puppet executes
# the manifest and with it the definitive network configuration is applied.
if [[ ${mgmt_ip} =~ ^([0-9a-fA-F]{0,4}:){1,7}[0-9a-fA-F]{0,4}$ ]]; then
# IPv6
mgmt_gw=$(echo "${mgmt_ip}" | awk -F':' -v OFS=':' '{$NF=1}1')
else
# IPv4
mgmt_gw=$(echo "${mgmt_ip}" | awk -F'.' -v OFS='.' '{$NF=1}1')
fi
fi
ilog "... mgmt_gw=${mgmt_gw}"
fi