Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions scripts/ironic-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ get_provisioning_interface()
return
fi

local interface="provisioning"
local interface=""

for mac in ${PROVISIONING_MACS//,/ }; do
if ip -br link show up | grep -i "$mac" &>/dev/null; then
Expand Down Expand Up @@ -116,10 +116,20 @@ parse_ip_address()
# Wait for the interface or IP to be up, sets $IRONIC_IP
wait_for_interface_or_ip()
{
# If $PROVISIONING_IP is specified, then we wait for that to become
# available on an interface, otherwise we look at $PROVISIONING_INTERFACE
# for an IP
if [[ -n "${PROVISIONING_IP}" ]]; then
# IRONIC_IP already defined overrides everything else
if [[ -n "${IRONIC_IP}" ]]; then
local PARSED_IP
PARSED_IP="$(parse_ip_address "${IRONIC_IP}")"
if [[ -z "${PARSED_IP}" ]]; then
echo "ERROR: PROVISIONING_IP contains an invalid IP address, failed to start ironic"
exit 1
fi

export IRONIC_IP="${PARSED_IP}"
elif [[ -n "${PROVISIONING_IP}" ]]; then
# If $PROVISIONING_IP is specified, then we wait for that to become
# available on an interface, otherwise we look at $PROVISIONING_INTERFACE
# for an IP
local PARSED_IP
PARSED_IP="$(parse_ip_address "${PROVISIONING_IP}")"
if [[ -z "${PARSED_IP}" ]]; then
Expand All @@ -138,13 +148,16 @@ wait_for_interface_or_ip()

export PROVISIONING_INTERFACE="${IFACE_OF_IP}"
export IRONIC_IP="${PARSED_IP}"
else
elif [[ -n "${PROVISIONING_INTERFACE}" ]]; then
until [[ -n "$IRONIC_IP" ]]; do
echo "Waiting for ${PROVISIONING_INTERFACE} interface to be configured"
IRONIC_IP="$(ip -br addr show scope global up dev "${PROVISIONING_INTERFACE}" | awk '{print $3}' | sed -e 's%/.*%%' | head -n 1)"
export IRONIC_IP
sleep 1
done
else
echo "ERROR: cannot determine an interface or an IP for binding and creating URLs"
return 1
fi

# If the IP contains a colon, then it's an IPv6 address, and the HTTP
Expand Down
Loading