2019-03-02 17:45:43 -06:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
VLAN_TABLE_PREFIX="VLAN_TABLE"
|
|
|
|
|
|
|
|
function wait_until_iface_ready
|
|
|
|
{
|
|
|
|
TABLE_PREFIX=$1
|
|
|
|
IFACE=$2
|
|
|
|
|
|
|
|
echo "Waiting until interface $IFACE is ready..."
|
|
|
|
|
|
|
|
# Wait for the interface to come up
|
|
|
|
# (i.e., interface is present in STATE_DB and state is "ok")
|
|
|
|
while true; do
|
2020-01-22 13:27:21 -06:00
|
|
|
RESULT=$(sonic-db-cli STATE_DB HGET "${TABLE_PREFIX}|${IFACE}" "state" 2> /dev/null)
|
2019-03-02 17:45:43 -06:00
|
|
|
if [ x"$RESULT" == x"ok" ]; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
|
|
|
|
echo "Interface ${IFACE} is ready!"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Wait for all interfaces to be up and ready
|
2019-06-10 16:02:55 -05:00
|
|
|
{% for (name, prefix) in VLAN_INTERFACE|pfx_filter %}
|
2019-03-02 17:45:43 -06:00
|
|
|
wait_until_iface_ready ${VLAN_TABLE_PREFIX} {{ name }}
|
|
|
|
{% endfor %}
|