From: Gianluca Merlo <gianluca.me...@gmail.com>

Reuse code for determining attached port to prevent ovs-docker to proceed if a
port for the given container and interface is already attached.
---
I'm posting this patch that was already submitted as a Github pull
request at: https://github.com/openvswitch/ovs/pull/36

 utilities/ovs-docker | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/utilities/ovs-docker b/utilities/ovs-docker
index 099ba31..d157fc1 100755
--- a/utilities/ovs-docker
+++ b/utilities/ovs-docker
@@ -73,6 +73,14 @@ 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"
-- 
2.1.3

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to