make multiweave work with weave running in the host netns

Multiweave now creates a temporary bridge with an IP alias per router
in the host netns, and overrides the router to bind to that specific
IP for weave protocol and data traffic and http control.
This commit is contained in:
Adam Harrison authored and Matthias Radestock committed 2016-02-03 11:57:12 +00:00
1 parent cf24bb0e89
commit 034d8933c0
1 file changed
+25 -14
+25 -14
View File
@@ -14,7 +14,8 @@ set -e
START=${FIRST_WEAVE:-1} START=${FIRST_WEAVE:-1}
COUNT=${NUM_WEAVES:-28} COUNT=${NUM_WEAVES:-28}
FINISH=$((START+COUNT-1)) FINISH=$((START+COUNT-1))
PORT=6783
SUBNET=192.168.7
weavedir=$(dirname $0)/.. weavedir=$(dirname $0)/..
@@ -26,32 +27,42 @@ random_mac() {
od -txC -An -N6 /dev/urandom | ( read a b c d e f && printf "%02x:$b:$c:$d:$e:$f" $((0x$a & ~1 | 2)) ) od -txC -An -N6 /dev/urandom | ( read a b c d e f && printf "%02x:$b:$c:$d:$e:$f" $((0x$a & ~1 | 2)) )
} }
weave() {
i=$1
shift
WEAVE_CONTAINER_NAME=weave$i WEAVE_HTTP_ADDR=$SUBNET.$i:6784 $weavedir/weave "$@"
}
case "$1" in case "$1" in
launch) launch)
shift 1 shift 1
echo $(date -R) launching echo $(date -R) launching
ip link show multiweave >/dev/null 2>&1 || sudo ip link add name multiweave type bridge
for i in $(seq $START $FINISH); do for i in $(seq $START $FINISH); do
WEAVE_CONTAINER_NAME=weave$i WEAVE_PORT=$((5000+i)) $weavedir/weave launch-router --iface '' --name $(random_mac) --nickname weave$i --port $PORT --no-dns "$@" IP=$SUBNET.$i
sudo ip addr add $IP/24 dev multiweave
weave $i launch-router --datapath '' --iface '' --no-dns --host $IP \
--name $(random_mac) --nickname weave$i "$@"
done done
if [ $START -ne 1 ] ; then
status=$(docker inspect --format='{{.State.Running}} {{.NetworkSettings.IPAddress}}' weave$((START-1)))
PREV="${status#true }"
fi
echo $(date -R) connecting echo $(date -R) connecting
[ $START -gt 1 ] || START=2
for i in $(seq $START $FINISH); do for i in $(seq $START $FINISH); do
if [ -n "$PREV" ] ; then TO=$SUBNET.$((i-1))
echo connecting weave$i to $PREV echo connecting weave$i to $TO
WEAVE_CONTAINER_NAME=weave$i $weavedir/weave connect $PREV weave $i connect $TO
fi
status=$(docker inspect --format='{{.State.Running}} {{.NetworkSettings.IPAddress}}' weave$i)
PREV="${status#true }"
done done
echo $(date -R) done echo $(date -R) done
;; ;;
stop) stop)
for i in $(seq $START $FINISH); do for i in $(seq $FINISH -1 $START); do
IP=$SUBNET.$i
echo Stopping weave$i echo Stopping weave$i
WEAVE_CONTAINER_NAME=weave$i $weavedir/weave stop-router weave $i stop-router
sudo ip addr del $IP/24 dev multiweave || true
done done
[ -z "$(ip -4 -o addr show multiweave)" ] && sudo ip link del multiweave
;;
*)
weave "$@"
;; ;;
esac esac