[dhcp_relay] Properly wait for routed interfaces to be ready before starting relay agent (#3441)
This commit is contained in:
parent
2114b2129f
commit
0e62280725
@ -2,21 +2,17 @@
|
|||||||
|
|
||||||
STATE_DB_IDX="6"
|
STATE_DB_IDX="6"
|
||||||
|
|
||||||
PORT_TABLE_PREFIX="PORT_TABLE"
|
|
||||||
VLAN_TABLE_PREFIX="VLAN_TABLE"
|
|
||||||
LAG_TABLE_PREFIX="LAG_TABLE"
|
|
||||||
|
|
||||||
function wait_until_iface_ready
|
function wait_until_iface_ready
|
||||||
{
|
{
|
||||||
TABLE_PREFIX=$1
|
IFACE_NAME=$1
|
||||||
IFACE=$2
|
IFACE_CIDR=$2
|
||||||
|
|
||||||
echo "Waiting until interface $IFACE is ready..."
|
echo "Waiting until interface ${IFACE_NAME} is ready..."
|
||||||
|
|
||||||
# Wait for the interface to come up
|
# Wait for the interface to come up
|
||||||
# (i.e., interface is present in STATE_DB and state is "ok")
|
# (i.e., interface is present in STATE_DB and state is "ok")
|
||||||
while true; do
|
while true; do
|
||||||
RESULT=$(redis-cli -n ${STATE_DB_IDX} HGET "${TABLE_PREFIX}|${IFACE}" "state" 2> /dev/null)
|
RESULT=$(redis-cli -n ${STATE_DB_IDX} HGET "INTERFACE_TABLE|${IFACE_NAME}|${IFACE_CIDR}" "state" 2> /dev/null)
|
||||||
if [ x"$RESULT" == x"ok" ]; then
|
if [ x"$RESULT" == x"ok" ]; then
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
@ -24,24 +20,23 @@ function wait_until_iface_ready
|
|||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "Interface ${IFACE} is ready!"
|
echo "Interface ${IFACE_NAME} is ready!"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Wait for all interfaces to be up and ready
|
# Wait for all interfaces with IPv4 addresses to be up and ready
|
||||||
{% for name in PORT %}
|
{% for (name, prefix) in INTERFACE|pfx_filter %}
|
||||||
{% if name in INTERFACE %}
|
{% if prefix | ipv4 %}
|
||||||
wait_until_iface_ready ${PORT_TABLE_PREFIX} {{ name }}
|
wait_until_iface_ready {{ name }} {{ prefix }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% for name in VLAN %}
|
{% for (name, prefix) in VLAN_INTERFACE|pfx_filter %}
|
||||||
{% if name in VLAN_INTERFACE %}
|
{% if prefix | ipv4 %}
|
||||||
wait_until_iface_ready ${VLAN_TABLE_PREFIX} {{ name }}
|
wait_until_iface_ready {{ name }} {{ prefix }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% for name in PORTCHANNEL %}
|
{% for (name, prefix) in PORTCHANNEL_INTERFACE|pfx_filter %}
|
||||||
{% if name in PORTCHANNEL_INTERFACE %}
|
{% if prefix | ipv4 %}
|
||||||
wait_until_iface_ready ${LAG_TABLE_PREFIX} {{ name }}
|
wait_until_iface_ready {{ name }} {{ prefix }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
@ -2,21 +2,17 @@
|
|||||||
|
|
||||||
STATE_DB_IDX="6"
|
STATE_DB_IDX="6"
|
||||||
|
|
||||||
PORT_TABLE_PREFIX="PORT_TABLE"
|
|
||||||
VLAN_TABLE_PREFIX="VLAN_TABLE"
|
|
||||||
LAG_TABLE_PREFIX="LAG_TABLE"
|
|
||||||
|
|
||||||
function wait_until_iface_ready
|
function wait_until_iface_ready
|
||||||
{
|
{
|
||||||
TABLE_PREFIX=$1
|
IFACE_NAME=$1
|
||||||
IFACE=$2
|
IFACE_CIDR=$2
|
||||||
|
|
||||||
echo "Waiting until interface $IFACE is ready..."
|
echo "Waiting until interface ${IFACE_NAME} is ready..."
|
||||||
|
|
||||||
# Wait for the interface to come up
|
# Wait for the interface to come up
|
||||||
# (i.e., interface is present in STATE_DB and state is "ok")
|
# (i.e., interface is present in STATE_DB and state is "ok")
|
||||||
while true; do
|
while true; do
|
||||||
RESULT=$(redis-cli -n ${STATE_DB_IDX} HGET "${TABLE_PREFIX}|${IFACE}" "state" 2> /dev/null)
|
RESULT=$(redis-cli -n ${STATE_DB_IDX} HGET "INTERFACE_TABLE|${IFACE_NAME}|${IFACE_CIDR}" "state" 2> /dev/null)
|
||||||
if [ x"$RESULT" == x"ok" ]; then
|
if [ x"$RESULT" == x"ok" ]; then
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
@ -24,14 +20,14 @@ function wait_until_iface_ready
|
|||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "Interface ${IFACE} is ready!"
|
echo "Interface ${IFACE_NAME} is ready!"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Wait for all interfaces to be up and ready
|
# Wait for all interfaces with IPv4 addresses to be up and ready
|
||||||
wait_until_iface_ready ${VLAN_TABLE_PREFIX} Vlan1000
|
wait_until_iface_ready Vlan1000 192.168.0.1/27
|
||||||
wait_until_iface_ready ${LAG_TABLE_PREFIX} PortChannel01
|
wait_until_iface_ready PortChannel01 10.0.0.56/31
|
||||||
wait_until_iface_ready ${LAG_TABLE_PREFIX} PortChannel02
|
wait_until_iface_ready PortChannel02 10.0.0.58/31
|
||||||
wait_until_iface_ready ${LAG_TABLE_PREFIX} PortChannel03
|
wait_until_iface_ready PortChannel03 10.0.0.60/31
|
||||||
wait_until_iface_ready ${LAG_TABLE_PREFIX} PortChannel04
|
wait_until_iface_ready PortChannel04 10.0.0.62/31
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user