2017-09-12 16:13:27 -05:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2019-07-29 20:10:26 -05:00
|
|
|
STATE_DB_IDX="6"
|
2017-09-12 16:13:27 -05:00
|
|
|
|
2019-07-29 20:10:26 -05:00
|
|
|
PORT_TABLE_PREFIX="PORT_TABLE"
|
|
|
|
VLAN_TABLE_PREFIX="VLAN_TABLE"
|
|
|
|
LAG_TABLE_PREFIX="LAG_TABLE"
|
2017-09-12 16:13:27 -05:00
|
|
|
|
2019-07-29 20:10:26 -05:00
|
|
|
function wait_until_iface_ready
|
|
|
|
{
|
|
|
|
TABLE_PREFIX=$1
|
|
|
|
IFACE=$2
|
2017-11-20 23:07:28 -06:00
|
|
|
|
2019-07-29 20:10:26 -05:00
|
|
|
echo "Waiting until interface $IFACE is ready..."
|
2017-11-20 23:07:28 -06:00
|
|
|
|
2019-07-29 20:10:26 -05:00
|
|
|
# Wait for the interface to come up
|
|
|
|
# (i.e., interface is present in STATE_DB and state is "ok")
|
2017-11-20 23:07:28 -06:00
|
|
|
while true; do
|
2019-07-29 20:10:26 -05:00
|
|
|
RESULT=$(redis-cli -n ${STATE_DB_IDX} HGET "${TABLE_PREFIX}|${IFACE}" "state" 2> /dev/null)
|
|
|
|
if [ x"$RESULT" == x"ok" ]; then
|
2017-11-20 23:07:28 -06:00
|
|
|
break
|
|
|
|
fi
|
|
|
|
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
|
2019-07-29 20:10:26 -05:00
|
|
|
echo "Interface ${IFACE} is ready!"
|
2017-09-12 16:13:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-07-29 20:10:26 -05:00
|
|
|
# Wait for all interfaces to be up and ready
|
2017-09-12 16:13:27 -05:00
|
|
|
{% for (name, prefix) in INTERFACE %}
|
2019-07-29 20:10:26 -05:00
|
|
|
wait_until_iface_ready ${PORT_TABLE_PREFIX} {{ name }}
|
2017-09-12 16:13:27 -05:00
|
|
|
{% endfor %}
|
|
|
|
{% for (name, prefix) in VLAN_INTERFACE %}
|
2019-07-29 20:10:26 -05:00
|
|
|
wait_until_iface_ready ${VLAN_TABLE_PREFIX} {{ name }}
|
2017-09-12 16:13:27 -05:00
|
|
|
{% endfor %}
|
|
|
|
{% for (name, prefix) in PORTCHANNEL_INTERFACE %}
|
2019-07-29 20:10:26 -05:00
|
|
|
wait_until_iface_ready ${LAG_TABLE_PREFIX} {{ name }}
|
2017-09-12 16:13:27 -05:00
|
|
|
{% endfor %}
|