Change command-line syntax to net: prefix instead of --subnet
This commit is contained in:
1 parent
91ad3ef684
commit
a89b549c40
4 files changed
+22
-29
No files matched your search
+4
-4
@@ -33,16 +33,16 @@ allocation, and `-ipsubnet` is the subnet that will be used when
|
||||
you don't explicitly specify one.
|
||||
|
||||
Then, to request the allocation of an address from a subnet other than
|
||||
the default, use `--subnet`:
|
||||
the default, use the `net:` prefix:
|
||||
|
||||
host1# C=$(weave run --subnet 10.2.7.0/24 -ti ubuntu)
|
||||
host1# C=$(weave run net:10.2.7.0/24 -ti ubuntu)
|
||||
|
||||
To explicitly request the default subnet, use `--subnet default`.
|
||||
To explicitly request the default subnet, use `net:default`.
|
||||
|
||||
And, you can ask for multiple addresses in different subnets and add
|
||||
in manually-assigned addresses on the same line, for instance:
|
||||
|
||||
host1# C=$(weave run --subnet 10.2.7.0/24 --subnet 10.2.8.0/24 10.3.9.1/24 -ti ubuntu)
|
||||
host1# C=$(weave run net:10.2.7.0/24 net:10.2.8.0/24 ip:10.3.9.1/24 -ti ubuntu)
|
||||
|
||||
Note that `-iprange` can be smaller than `-ipsubnet`, if you want to
|
||||
use a mixture of automatically-allocated addresses and manually-chosen
|
||||
|
||||
@@ -14,16 +14,16 @@ weave_on $HOST1 launch -iprange $UNIVERSE -ipsubnet $SUBNET_1
|
||||
weave_on $HOST2 launch -iprange $UNIVERSE -ipsubnet $SUBNET_1 $HOST1
|
||||
|
||||
start_container $HOST1 $C1/24 --name=c1
|
||||
start_container $HOST2 $C2/24 --name=c2
|
||||
start_container $HOST2 ip:$C2/24 --name=c2
|
||||
assert_raises "exec_on $HOST1 c1 $PING $C2"
|
||||
|
||||
start_container $HOST1 --name=c3
|
||||
start_container $HOST2 --subnet default --name=c4
|
||||
start_container $HOST2 net:default --name=c4
|
||||
C4=$(container_ip $HOST2 c4)
|
||||
assert_raises "exec_on $HOST1 c3 $PING $C4"
|
||||
|
||||
start_container $HOST1 --subnet $SUBNET_2 --name=c5
|
||||
start_container $HOST2 --subnet $SUBNET_2 --name=c6
|
||||
start_container $HOST1 net:$SUBNET_2 --name=c5
|
||||
start_container $HOST2 net:$SUBNET_2 --name=c6
|
||||
C6=$(container_ip $HOST2 c6)
|
||||
assert_raises "exec_on $HOST1 c5 $PING $C6"
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ assert_bridge_cidrs() {
|
||||
|
||||
start_suite "Weave run/start/attach/detach with multiple cidr arguments"
|
||||
|
||||
# NOTE: in these tests, --subnet arguments are checked against a
|
||||
# NOTE: in these tests, net: arguments are checked against a
|
||||
# specific address, i.e. we are assuming that IPAM always returns the
|
||||
# lowest available address in the subnet
|
||||
|
||||
@@ -50,37 +50,37 @@ weave_on $HOST1 launch -debug -iprange 10.2.3.0/24
|
||||
weave_on $HOST1 launch-dns 10.254.254.254/24
|
||||
|
||||
# Run container with three cidrs
|
||||
CID=$(start_container $HOST1 10.2.1.1/24 10.2.2.1/24 --subnet 10.2.3.0/24 --name=multicidr -h $NAME | cut -b 1-12)
|
||||
CID=$(start_container $HOST1 ip:10.2.1.1/24 10.2.2.1/24 net:10.2.3.0/24 --name=multicidr -h $NAME | cut -b 1-12)
|
||||
assert_container_cidrs $HOST1 $CID 10.2.1.1/24 10.2.2.1/24 10.2.3.1/24
|
||||
assert_zone_records $HOST1 $CID $NAME. 10.2.1.1 10.2.2.1 10.2.3.1
|
||||
|
||||
# Remove two of them
|
||||
weave_on $HOST1 detach 10.2.1.1/24 --subnet 10.2.3.0/24 $CID
|
||||
weave_on $HOST1 detach 10.2.1.1/24 net:10.2.3.0/24 $CID
|
||||
assert_container_cidrs $HOST1 $CID 10.2.2.1/24
|
||||
assert_zone_records $HOST1 $CID $NAME. 10.2.2.1
|
||||
|
||||
# Put them both back
|
||||
weave_on $HOST1 attach 10.2.1.1/24 --subnet 10.2.3.0/24 $CID
|
||||
weave_on $HOST1 attach ip:10.2.1.1/24 net:10.2.3.0/24 $CID
|
||||
assert_container_cidrs $HOST1 $CID 10.2.2.1/24 10.2.1.1/24 10.2.3.1/24
|
||||
assert_zone_records $HOST1 $CID $NAME. 10.2.2.1 10.2.1.1 10.2.3.1
|
||||
|
||||
# Stop the container, restart with three IPs
|
||||
docker_on $HOST1 stop $CID
|
||||
weave_on $HOST1 start 10.2.1.1/24 10.2.2.1/24 --subnet 10.2.3.0/24 $CID
|
||||
weave_on $HOST1 start 10.2.1.1/24 ip:10.2.2.1/24 net:10.2.3.0/24 $CID
|
||||
assert_container_cidrs $HOST1 $CID 10.2.1.1/24 10.2.2.1/24 10.2.3.1/24
|
||||
assert_zone_records $HOST1 $CID $NAME. 10.2.1.1 10.2.2.1 10.2.3.1
|
||||
|
||||
# Expose some cidrs
|
||||
weave_on $HOST1 expose 10.2.1.2/24 10.2.2.2/24 --subnet 10.2.3.0/24
|
||||
weave_on $HOST1 expose 10.2.1.2/24 10.2.2.2/24 net:10.2.3.0/24
|
||||
assert_bridge_cidrs $HOST1 weave 10.2.1.2/24 10.2.2.2/24 10.2.3.2/24
|
||||
|
||||
# Hide some cidrs
|
||||
weave_on $HOST1 hide 10.2.1.2/24 --subnet 10.2.3.0/24
|
||||
weave_on $HOST1 hide 10.2.1.2/24 net:10.2.3.0/24
|
||||
assert_bridge_cidrs $HOST1 weave 10.2.2.2/24
|
||||
|
||||
# Now detach and run another container to check we have released IPs in IPAM
|
||||
weave_on $HOST1 detach $CID
|
||||
CID2=$(start_container $HOST1 --subnet 10.2.3.0/24)
|
||||
CID2=$(start_container $HOST1 net:10.2.3.0/24)
|
||||
assert_container_cidrs $HOST1 $CID2 10.2.3.1/24
|
||||
|
||||
end_suite
|
||||
@@ -55,7 +55,7 @@ usage() {
|
||||
echo "where <peer> = <ip_address_or_fqdn>[:<port>]"
|
||||
echo " <cidr> = <ip_address>/<routing_prefix_length>"
|
||||
echo " <peer_id> = <nickname> or weave internal peer ID"
|
||||
echo " <address_spec> = <cidr> | --subnet <cidr> | --subnet default"
|
||||
echo " <address_spec> = [ip:]<cidr> | net:<cidr> | net:default"
|
||||
echo " <address> = [tcp://][<ip_address>]:<port>"
|
||||
exit 1
|
||||
}
|
||||
@@ -106,15 +106,9 @@ validate_cidr() {
|
||||
collect_cidr_args() {
|
||||
CIDR_ARGS=""
|
||||
CIDR_ARG_COUNT=0
|
||||
while is_cidr "$1" || [ "$1" = "--subnet" ] ; do
|
||||
CIDR_ARGS="$CIDR_ARGS $1"
|
||||
while [ "$1" = "net:default" ] || is_cidr "$1" || is_cidr "${1#ip:}" || is_cidr "${1#net:}" ; do
|
||||
CIDR_ARGS="$CIDR_ARGS ${1#ip:}"
|
||||
CIDR_ARG_COUNT=$((CIDR_ARG_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_ARG_COUNT=$((CIDR_ARG_COUNT + 1))
|
||||
shift 1
|
||||
fi
|
||||
shift 1
|
||||
done
|
||||
}
|
||||
@@ -776,12 +770,11 @@ ipam_cidrs() {
|
||||
ALL_CIDRS="$IPAM_CIDRS"
|
||||
fi
|
||||
while [ $# -gt 0 ] ; do
|
||||
if [ $# -gt 1 -a "$1" = "--subnet" ] ; then
|
||||
shift 1
|
||||
if [ "$1" = "default" ] ; then
|
||||
if [ "${1%:*}" = "net" ] ; then
|
||||
if [ "$1" = "net: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)
|
||||
CIDR=$(http_call $CONTAINER_NAME $HTTP_PORT POST /ip/$CONTAINER_ID/"${1#net:}")
|
||||
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
|
||||
|
||||
Reference in new issue
Block a user