#!/bin/bash
#
# functions - ONOS driver utility functions


# Test if ONOS is enabled
function is_onos_enabled {
    [[ ,${ENABLED_SERVICES} =~ ,"onos-" ]] && return 0
    return 1
}


# Check that the bridge is up and running
function wait_for_active_bridge {
    local BRIDGE=$1
    local SLEEP_INTERVAL=$2
    local MAX_WAIT=$3

    echo "Waiting for bridge $BRIDGE to be available..."
    local testcmd="sudo ovs-vsctl list Bridge | grep $BRIDGE"
    test_with_retry "$testcmd" \
        "$BRIDGE did not become available in $MAX_WAIT seconds." \
        $MAX_WAIT $SLEEP_INTERVAL
    echo "Bridge $BRIDGE is avaialable."
}
