Make ipam_cidrs() return failure when call_weave fails

This commit is contained in:
Bryan Boreham committed 2015-06-16 14:47:47 +01:00
1 parent 8b5d0e3fbd
commit 32d3909023
1 file changed
+8 -3
+8 -3
View File
@@ -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