Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
make multiweave work with weave running in the host netns
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
awh authored and rade committed Feb 2, 2016
1 parent fdd0060 commit cfd5136
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions bin/multiweave
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ set -e
START=${FIRST_WEAVE:-1}
COUNT=${NUM_WEAVES:-28}
FINISH=$((START+COUNT-1))
PORT=6783

SUBNET=192.168.7

weavedir=$(dirname $0)/..

Expand All @@ -26,32 +27,39 @@ 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)) )
}

weave() {
i=$1
shift
WEAVE_CONTAINER_NAME=weave$i WEAVE_HTTP_ADDR=$SUBNET.$i:6784 $weavedir/weave "$@"
}

case "$1" in
launch)
shift 1
echo $(date -R) launching
sudo ip link add name multiweave type bridge
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
if [ $START -ne 1 ] ; then
status=$(docker inspect --format='{{.State.Running}} {{.NetworkSettings.IPAddress}}' weave$((START-1)))
PREV="${status#true }"
fi
echo $(date -R) connecting
for i in $(seq $START $FINISH); do
if [ -n "$PREV" ] ; then
echo connecting weave$i to $PREV
WEAVE_CONTAINER_NAME=weave$i $weavedir/weave connect $PREV
fi
status=$(docker inspect --format='{{.State.Running}} {{.NetworkSettings.IPAddress}}' weave$i)
PREV="${status#true }"
for i in $(seq $((START+1)) $FINISH); do
TO=$SUBNET.$((i-1))
echo connecting weave$i to $TO
weave $i connect $TO
done
echo $(date -R) done
;;
stop)
for i in $(seq $START $FINISH); do
echo Stopping weave$i
WEAVE_CONTAINER_NAME=weave$i $weavedir/weave stop-router
weave $i stop-router
done
sudo ip link del multiweave
;;
*)
weave "$@"
;;
esac

0 comments on commit cfd5136

Please sign in to comment.