OpenVswitch: cleanup interfaces without tap device

Show bridges without tab device

brctl show | egrep "qvb|tap" | sed '$!N;/\n.*tap/d;P;D' | awk '{print substr($1,4,8)}'

Get interface details

TOKEN=cac559da
 
# show port details
docker exec openvswitch_vswitchd ovsdb-client dump | grep ${TOKEN}
 
# get OVS port
docker exec openvswitch_vswitchd ovs-vsctl list-ports br-int | grep ${TOKEN}
 
# get OVS interface
docker exec openvswitch_vswitchd ovs-vsctl list-ifaces br-int | grep ${TOKEN}
 
# show host bridges
brctl show | grep ${TOKEN}
 
# show host interfaces
ip a | grep ${TOKEN}

Delete interface

TOKEN=a101dd83
# get port ID
PORT_ID=$(docker exec openvswitch_vswitchd ovs-vsctl list-ports br-int | grep ${TOKEN})
echo ${PORT_ID}
 
# remove port
docker exec openvswitch_vswitchd ovs-vsctl del-port br-int ${PORT_ID}
 
# remove bridge
BRIDGE_ID=${PORT_ID/qvo/qbr}
echo ${BRIDGE_ID}
ip link set ${BRIDGE_ID} down
brctl delbr ${BRIDGE_ID}
 
# remove interface
ip link delete ${PORT_ID}