Skip to content

Commit 614202f

Browse files
committed
On unstack : clean up network namespaces created by quantum
Also removes OVS ports Fix Bug #1156837 Change-Id: Id4178c0a12a3ada76403a57a736a9c7a908d6a4a
1 parent 7640350 commit 614202f

8 files changed

Lines changed: 24 additions & 8 deletions

File tree

lib/quantum

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,14 @@ function stop_quantum() {
406406
# cleanup_quantum() - Remove residual data files, anything left over from previous
407407
# runs that a clean run would need to clean up
408408
function cleanup_quantum() {
409-
:
409+
if is_quantum_ovs_base_plugin; then
410+
quantum_ovs_base_cleanup
411+
fi
412+
413+
# delete all namespaces created by quantum
414+
for ns in $(sudo ip netns list | grep -o -e qdhcp-[0-9a-f\-]* -e qrouter-[0-9a-f\-]*); do
415+
sudo ip netns delete ${ns}
416+
done
410417
}
411418

412419
# _configure_quantum_common()
@@ -502,7 +509,6 @@ function _configure_quantum_l3_agent() {
502509
# for l3-agent, only use per tenant router if we have namespaces
503510
Q_L3_ROUTER_PER_TENANT=$Q_USE_NAMESPACE
504511
AGENT_L3_BINARY="$QUANTUM_DIR/bin/quantum-l3-agent"
505-
PUBLIC_BRIDGE=${PUBLIC_BRIDGE:-br-ex}
506512
Q_L3_CONF_FILE=$QUANTUM_CONF_DIR/l3_agent.ini
507513

508514
cp $QUANTUM_DIR/etc/l3_agent.ini $Q_L3_CONF_FILE

lib/quantum_plugins/nec

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ OFC_DRIVER=${OFC_DRIVER:-trema}
1717
OFC_RETRY_MAX=${OFC_RETRY_MAX:-0}
1818
OFC_RETRY_INTERVAL=${OFC_RETRY_INTERVAL:-1}
1919

20-
OVS_BRIDGE=${OVS_BRIDGE:-br-int}
21-
2220
# Main logic
2321
# ---------------------------
2422

lib/quantum_plugins/nicira

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ set +o xtrace
88
source $TOP_DIR/lib/quantum_plugins/ovs_base
99

1010
function setup_integration_bridge() {
11-
OVS_BRIDGE=${OVS_BRIDGE:-br-int}
1211
_quantum_ovs_base_setup_bridge $OVS_BRIDGE
1312
# Set manager to NVP controller (1st of list)
1413
if [[ "$NVP_CONTROLLERS" != "" ]]; then

lib/quantum_plugins/openvswitch

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ function quantum_plugin_configure_l3_agent() {
4141

4242
function quantum_plugin_configure_plugin_agent() {
4343
# Setup integration bridge
44-
OVS_BRIDGE=${OVS_BRIDGE:-br-int}
4544
_quantum_ovs_base_setup_bridge $OVS_BRIDGE
4645
_quantum_ovs_base_configure_firewall_driver
4746

lib/quantum_plugins/ovs_base

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
MY_XTRACE=$(set +o | grep xtrace)
66
set +o xtrace
77

8+
OVS_BRIDGE=${OVS_BRIDGE:-br-int}
9+
PUBLIC_BRIDGE=${PUBLIC_BRIDGE:-br-ex}
10+
811
function is_quantum_ovs_base_plugin() {
912
# Yes, we use OVS.
1013
return 0
@@ -17,6 +20,18 @@ function _quantum_ovs_base_setup_bridge() {
1720
sudo ovs-vsctl --no-wait br-set-external-id $bridge bridge-id $bridge
1821
}
1922

23+
function quantum_ovs_base_cleanup() {
24+
# remove all OVS ports that look like Quantum created ports
25+
for port in $(sudo ovs-vsctl list port | grep -o -e tap[0-9a-f\-]* -e q[rg]-[0-9a-f\-]*); do
26+
sudo ovs-vsctl del-port ${port}
27+
done
28+
29+
# remove all OVS bridges created by Quantum
30+
for bridge in $(sudo ovs-vsctl list-br | grep -o -e ${OVS_BRIDGE} -e ${PUBLIC_BRIDGE}); do
31+
sudo ovs-vsctl del-br ${bridge}
32+
done
33+
}
34+
2035
function _quantum_ovs_base_install_agent_packages() {
2136
local kernel_version
2237
# Install deps

lib/quantum_plugins/ryu

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ function quantum_plugin_configure_l3_agent() {
4545

4646
function quantum_plugin_configure_plugin_agent() {
4747
# Set up integration bridge
48-
OVS_BRIDGE=${OVS_BRIDGE:-br-int}
4948
_quantum_ovs_base_setup_bridge $OVS_BRIDGE
5049
if [ -n "$RYU_INTERNAL_INTERFACE" ]; then
5150
sudo ovs-vsctl --no-wait -- --may-exist add-port $OVS_BRIDGE $RYU_INTERNAL_INTERFACE

lib/quantum_thirdparty/bigswitch_floodlight

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ set +o xtrace
77

88
BS_FL_CONTROLLERS_PORT=${BS_FL_CONTROLLERS_PORT:-localhost:80}
99
BS_FL_OF_PORT=${BS_FL_OF_PORT:-6633}
10-
OVS_BRIDGE=${OVS_BRIDGE:-br-int}
1110

1211
function configure_bigswitch_floodlight() {
1312
:

unstack.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,5 @@ fi
109109
if is_service_enabled quantum; then
110110
stop_quantum
111111
stop_quantum_third_party
112+
cleanup_quantum
112113
fi

0 commit comments

Comments
 (0)