ovs-docker: check if port is already attached for container/interface
authorGianluca Merlo <gianluca.merlo@gmail.com>
Sun, 1 Mar 2015 05:05:37 +0000 (21:05 -0800)
committerGurucharan Shetty <gshetty@nicira.com>
Tue, 3 Mar 2015 16:52:07 +0000 (08:52 -0800)
Reuse code for determining attached port to prevent ovs-docker to proceed if a
port for the given container and interface is already attached.

Signed-off-by: Gianluca Merlo <gianluca.merlo@gmail.com>
Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
utilities/ovs-docker

index 099ba31..dd2aef1 100755 (executable)
@@ -73,6 +73,15 @@ add_port () {
         exit 1
     fi
 
+    # Check if a port is already attached for the given container and interface
+    PORT=`get_port_for_container_interface "$CONTAINER" "$INTERFACE" \
+            2>/dev/null`
+    if [ -n "$PORT" ]; then
+        echo >&2 "$UTIL: Port already attached" \
+                 "for CONTAINER=$CONTAINER and INTERFACE=$INTERFACE"
+        exit 1
+    fi
+
     if ovs_vsctl br-exists "$BRIDGE" || \
         ovs_vsctl add-br "$BRIDGE"; then :; else
         echo >&2 "$UTIL: Failed to create bridge $BRIDGE"