diff --git a/weave b/weave index c5e9eb3b..e653a1bf 100755 --- a/weave +++ b/weave @@ -788,7 +788,9 @@ ipam_cidrs() { IPAM_CIDRs="" if [ $# -eq 0 ] ; then # If no addresses passed in, get one in the default subnet - IPAM_CIDRS=$(call_weave POST /ip/$CONTAINER_ID) + if ! IPAM_CIDRS=$(call_weave POST /ip/$CONTAINER_ID) ; then + return 1 + fi if [ "$IPAM_CIDRS" = "404 page not found" ] ; then echo "No IP address supplied (use the -iprange option on 'weave launch' to enable IP address allocation)" >&2 return 1 @@ -798,9 +800,12 @@ ipam_cidrs() { while [ $# -gt 0 ] ; do if [ "${1%:*}" = "net" ] ; then if [ "$1" = "net:default" ] ; then - CIDR=$(call_weave POST /ip/$CONTAINER_ID) + IPAM_URL=/ip/$CONTAINER_ID else - CIDR=$(call_weave POST /ip/$CONTAINER_ID/"${1#net:}") + IPAM_URL=/ip/$CONTAINER_ID/"${1#net:}" + fi + if ! CIDR=$(call_weave POST $IPAM_URL) ; then + return 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