Support '--subnet default'

This commit is contained in:
Bryan Boreham committed 2015-06-10 17:21:16 +01:00
1 parent 3a9af4413d
commit 2b4eec39cf
2 files changed
+12 -2

No files matched your search

+1 -1
View File
@@ -18,7 +18,7 @@ start_container $HOST2 $C2/24 --name=c2
assert_raises "exec_on $HOST1 c1 $PING $C2"
start_container $HOST1 --name=c3
start_container $HOST2 --name=c4
start_container $HOST2 --subnet default --name=c4
C4=$(container_ip $HOST2 c4)
assert_raises "exec_on $HOST1 c3 $PING $C4"
+11 -1
View File
@@ -108,6 +108,12 @@ collect_cidr_args() {
while is_cidr "$1" || [ "$1" = "--subnet" ] ; do
CIDR_ARGS="$CIDR_ARGS $1"
CIDR_COUNT=$((CIDR_COUNT + 1))
# only accept 'default' after '--subnet', in case someone has a container called 'default'
if [ "$1" = "--subnet" -a "$2" = "default" ] ; then
CIDR_ARGS="$CIDR_ARGS $2"
CIDR_COUNT=$((CIDR_ARG_COUNT + 1))
shift 1
fi
shift 1
done
}
@@ -762,7 +768,11 @@ ipam_cidrs() {
while [ $# -gt 0 ] ; do
if [ $# -gt 1 -a "$1" = "--subnet" ] ; then
shift 1
CIDR=$(http_call $CONTAINER_NAME $HTTP_PORT POST /ip/$CONTAINER_ID/$1)
if [ "$1" = "default" ] ; then
CIDR=$(http_call $CONTAINER_NAME $HTTP_PORT POST /ip/$CONTAINER_ID)
else
CIDR=$(http_call $CONTAINER_NAME $HTTP_PORT POST /ip/$CONTAINER_ID/$1)
fi
if [ "$CIDR" = "404 page not found" ] ; then
echo "IP address allocation must be enabled to use --subnet (use the -iprange option on 'weave launch')" >&2
return 1