kolla/docker/openvswitch/openvswitch-db-server/ovs_ensure_configured.sh
Pavel Glushchak 4489bf24d8 Ensure interface exists before adding OVS port
Otherwise fail.

Change-Id: Ia84d146e568071a84a7d0e06fcd88e64427904b8
Closes-Bug: #1700745
Signed-off-by: Pavel Glushchak <pglushchak@virtuozzo.com>
2017-07-24 08:50:45 +00:00

24 lines
399 B
Bash

#!/bin/bash
bridge=$1
port=$2
ip link show $port
if [[ $? -ne 0 ]]; then
# fail when device doesn't exist
exit 1
fi
ovs-vsctl br-exists $bridge
if [[ $? -eq 2 ]]; then
changed=changed
ovs-vsctl --no-wait add-br $bridge
fi
if [[ ! $(ovs-vsctl list-ports $bridge) =~ $(echo "\<$port\>") ]]; then
changed=changed
ovs-vsctl --no-wait add-port $bridge $port
fi
echo $changed