X-Git-Url: http://git.cascardo.eti.br/?a=blobdiff_plain;f=utilities%2Fovs-docker;h=43cea54393e6a0ce349b3f0845809af6e8c43fc3;hb=ca7e7bee86b4ee821d61b58bf15c89a9d8a3cb30;hp=dd2aef1c652478c6f9efe8efbca5ccaef00e5237;hpb=709344386fd84b92aef6e5301539f69d4e7a2e61;p=cascardo%2Fovs.git diff --git a/utilities/ovs-docker b/utilities/ovs-docker index dd2aef1c6..43cea5439 100755 --- a/utilities/ovs-docker +++ b/utilities/ovs-docker @@ -65,14 +65,38 @@ add_port () { BRIDGE="$1" INTERFACE="$2" CONTAINER="$3" - ADDRESS="$4" - GATEWAY="$5" - if [ "$#" -lt 3 ]; then - usage + if [ -z "$BRIDGE" ] || [ -z "$INTERFACE" ] || [ -z "$CONTAINER" ]; then + echo >&2 "$UTIL add-port: not enough arguments (use --help for help)" exit 1 fi + shift 3 + while [ $# -ne 0 ]; do + case $1 in + --ipaddress=*) + ADDRESS=`expr X"$1" : 'X[^=]*=\(.*\)'` + shift + ;; + --macaddress=*) + MACADDRESS=`expr X"$1" : 'X[^=]*=\(.*\)'` + shift + ;; + --gateway=*) + GATEWAY=`expr X"$1" : 'X[^=]*=\(.*\)'` + shift + ;; + --mtu=*) + MTU=`expr X"$1" : 'X[^=]*=\(.*\)'` + shift + ;; + *) + echo >&2 "$UTIL add-port: unknown option \"$1\"" + exit 1 + ;; + esac + done + # Check if a port is already attached for the given container and interface PORT=`get_port_for_container_interface "$CONTAINER" "$INTERFACE" \ 2>/dev/null` @@ -117,10 +141,18 @@ add_port () { ip netns exec "$PID" ip link set dev "${PORTNAME}_c" name "$INTERFACE" ip netns exec "$PID" ip link set "$INTERFACE" up + if [ -n "$MTU" ]; then + ip netns exec "$PID" ip link set dev "$INTERFACE" mtu "$MTU" + fi + if [ -n "$ADDRESS" ]; then ip netns exec "$PID" ip addr add "$ADDRESS" dev "$INTERFACE" fi + if [ -n "$MACADDRESS" ]; then + ip netns exec "$PID" ip link set dev "$INTERFACE" address "$MACADDRESS" + fi + if [ -n "$GATEWAY" ]; then ip netns exec "$PID" ip route add default via "$GATEWAY" fi @@ -190,14 +222,17 @@ ${UTIL}: Performs integration of Open vSwitch with Docker. usage: ${UTIL} COMMAND Commands: - add-port BRIDGE INTERFACE CONTAINER [ADDRESS [GATEWAY]] + add-port BRIDGE INTERFACE CONTAINER [--ipaddress="ADDRESS"] + [--gateway=GATEWAY] [--macaddress="MACADDRESS"] + [--mtu=MTU] Adds INTERFACE inside CONTAINER and connects it as a port in Open vSwitch BRIDGE. Optionally, sets ADDRESS on INTERFACE. ADDRESS can include a '/' to represent network - prefix length. Along with ADDRESS, optionally set the - default gateway for the container. e.g.: - ${UTIL} add-port br-int eth1 c474a0e2830e 192.168.1.2/24 \ - 192.168.1.1 + prefix length. Optionally, sets a GATEWAY, MACADDRESS + and MTU. e.g.: + ${UTIL} add-port br-int eth1 c474a0e2830e + --ipaddress=192.168.1.2/24 --gateway=192.168.1.1 + --macaddress="a2:c3:0d:49:7f:f8" --mtu=1450 del-port BRIDGE INTERFACE CONTAINER Deletes INTERFACE inside CONTAINER and removes its connection to Open vSwitch BRIDGE. e.g.: