From 614202fc40923a60f83d7108ea66ce07846de324 Mon Sep 17 00:00:00 2001 From: JordanP Date: Thu, 16 May 2013 11:16:13 +0200 Subject: [PATCH] On unstack : clean up network namespaces created by quantum Also removes OVS ports Fix Bug #1156837 Change-Id: Id4178c0a12a3ada76403a57a736a9c7a908d6a4a --- lib/quantum | 10 ++++++++-- lib/quantum_plugins/nec | 2 -- lib/quantum_plugins/nicira | 1 - lib/quantum_plugins/openvswitch | 1 - lib/quantum_plugins/ovs_base | 15 +++++++++++++++ lib/quantum_plugins/ryu | 1 - lib/quantum_thirdparty/bigswitch_floodlight | 1 - unstack.sh | 1 + 8 files changed, 24 insertions(+), 8 deletions(-) diff --git a/lib/quantum b/lib/quantum index dfd73e99f4..4d6793c510 100644 --- a/lib/quantum +++ b/lib/quantum @@ -406,7 +406,14 @@ function stop_quantum() { # cleanup_quantum() - Remove residual data files, anything left over from previous # runs that a clean run would need to clean up function cleanup_quantum() { - : + if is_quantum_ovs_base_plugin; then + quantum_ovs_base_cleanup + fi + + # delete all namespaces created by quantum + for ns in $(sudo ip netns list | grep -o -e qdhcp-[0-9a-f\-]* -e qrouter-[0-9a-f\-]*); do + sudo ip netns delete ${ns} + done } # _configure_quantum_common() @@ -502,7 +509,6 @@ function _configure_quantum_l3_agent() { # for l3-agent, only use per tenant router if we have namespaces Q_L3_ROUTER_PER_TENANT=$Q_USE_NAMESPACE AGENT_L3_BINARY="$QUANTUM_DIR/bin/quantum-l3-agent" - PUBLIC_BRIDGE=${PUBLIC_BRIDGE:-br-ex} Q_L3_CONF_FILE=$QUANTUM_CONF_DIR/l3_agent.ini cp $QUANTUM_DIR/etc/l3_agent.ini $Q_L3_CONF_FILE diff --git a/lib/quantum_plugins/nec b/lib/quantum_plugins/nec index 4a2a49767a..411f5a4b01 100644 --- a/lib/quantum_plugins/nec +++ b/lib/quantum_plugins/nec @@ -17,8 +17,6 @@ OFC_DRIVER=${OFC_DRIVER:-trema} OFC_RETRY_MAX=${OFC_RETRY_MAX:-0} OFC_RETRY_INTERVAL=${OFC_RETRY_INTERVAL:-1} -OVS_BRIDGE=${OVS_BRIDGE:-br-int} - # Main logic # --------------------------- diff --git a/lib/quantum_plugins/nicira b/lib/quantum_plugins/nicira index 305c3bfa7d..fc06b55713 100644 --- a/lib/quantum_plugins/nicira +++ b/lib/quantum_plugins/nicira @@ -8,7 +8,6 @@ set +o xtrace source $TOP_DIR/lib/quantum_plugins/ovs_base function setup_integration_bridge() { - OVS_BRIDGE=${OVS_BRIDGE:-br-int} _quantum_ovs_base_setup_bridge $OVS_BRIDGE # Set manager to NVP controller (1st of list) if [[ "$NVP_CONTROLLERS" != "" ]]; then diff --git a/lib/quantum_plugins/openvswitch b/lib/quantum_plugins/openvswitch index dda9e61129..374172014b 100644 --- a/lib/quantum_plugins/openvswitch +++ b/lib/quantum_plugins/openvswitch @@ -41,7 +41,6 @@ function quantum_plugin_configure_l3_agent() { function quantum_plugin_configure_plugin_agent() { # Setup integration bridge - OVS_BRIDGE=${OVS_BRIDGE:-br-int} _quantum_ovs_base_setup_bridge $OVS_BRIDGE _quantum_ovs_base_configure_firewall_driver diff --git a/lib/quantum_plugins/ovs_base b/lib/quantum_plugins/ovs_base index 2ada0dbf5a..a5e03acd51 100644 --- a/lib/quantum_plugins/ovs_base +++ b/lib/quantum_plugins/ovs_base @@ -5,6 +5,9 @@ MY_XTRACE=$(set +o | grep xtrace) set +o xtrace +OVS_BRIDGE=${OVS_BRIDGE:-br-int} +PUBLIC_BRIDGE=${PUBLIC_BRIDGE:-br-ex} + function is_quantum_ovs_base_plugin() { # Yes, we use OVS. return 0 @@ -17,6 +20,18 @@ function _quantum_ovs_base_setup_bridge() { sudo ovs-vsctl --no-wait br-set-external-id $bridge bridge-id $bridge } +function quantum_ovs_base_cleanup() { + # remove all OVS ports that look like Quantum created ports + for port in $(sudo ovs-vsctl list port | grep -o -e tap[0-9a-f\-]* -e q[rg]-[0-9a-f\-]*); do + sudo ovs-vsctl del-port ${port} + done + + # remove all OVS bridges created by Quantum + for bridge in $(sudo ovs-vsctl list-br | grep -o -e ${OVS_BRIDGE} -e ${PUBLIC_BRIDGE}); do + sudo ovs-vsctl del-br ${bridge} + done +} + function _quantum_ovs_base_install_agent_packages() { local kernel_version # Install deps diff --git a/lib/quantum_plugins/ryu b/lib/quantum_plugins/ryu index 1b039dc950..c482747759 100644 --- a/lib/quantum_plugins/ryu +++ b/lib/quantum_plugins/ryu @@ -45,7 +45,6 @@ function quantum_plugin_configure_l3_agent() { function quantum_plugin_configure_plugin_agent() { # Set up integration bridge - OVS_BRIDGE=${OVS_BRIDGE:-br-int} _quantum_ovs_base_setup_bridge $OVS_BRIDGE if [ -n "$RYU_INTERNAL_INTERFACE" ]; then sudo ovs-vsctl --no-wait -- --may-exist add-port $OVS_BRIDGE $RYU_INTERNAL_INTERFACE diff --git a/lib/quantum_thirdparty/bigswitch_floodlight b/lib/quantum_thirdparty/bigswitch_floodlight index 60e39248c4..385bd0d9b0 100644 --- a/lib/quantum_thirdparty/bigswitch_floodlight +++ b/lib/quantum_thirdparty/bigswitch_floodlight @@ -7,7 +7,6 @@ set +o xtrace BS_FL_CONTROLLERS_PORT=${BS_FL_CONTROLLERS_PORT:-localhost:80} BS_FL_OF_PORT=${BS_FL_OF_PORT:-6633} -OVS_BRIDGE=${OVS_BRIDGE:-br-int} function configure_bigswitch_floodlight() { : diff --git a/unstack.sh b/unstack.sh index 3ac29857f8..d1d03494de 100755 --- a/unstack.sh +++ b/unstack.sh @@ -109,4 +109,5 @@ fi if is_service_enabled quantum; then stop_quantum stop_quantum_third_party + cleanup_quantum fi