3 debug
"Setting up NAT gateway"
5 natgw_nodes
="${CTDB_BASE}/natgw_nodes"
10 # A separate function for this makes sense because it can be done
11 # multiple times per test
15 while read -r _ip _opts
; do
18 export FAKE_CTDB_NATGW_LEADER
="$_ip"
22 printf "%s\tfollower-only\n" "$_ip"
30 # Assume all of the nodes are on a /24 network and have IPv4
32 read -r _ip
<"$natgw_nodes"
34 setup_script_options
<<EOF
35 CTDB_NATGW_NODES="$natgw_nodes"
36 CTDB_NATGW_PRIVATE_NETWORK="${_ip%.*}.0/24"
37 # These are fixed. Probably don't use the same network for the
38 # private node IPs. To unset the default gateway just set it to
40 CTDB_NATGW_PUBLIC_IP="10.1.1.121/24"
41 CTDB_NATGW_PUBLIC_IFACE="eth1"
42 CTDB_NATGW_DEFAULT_GATEWAY="10.1.1.254"
46 ok_natgw_leader_ip_addr_show
()
48 _mac
=$
(echo "$CTDB_NATGW_PUBLIC_IFACE" |
50 sed -r -e 's@(..)(..)(..).*@fe:fe:fe:\1:\2:\3@')
52 # This is based on CTDB_NATGW_PUBLIC_IP
56 1: ${CTDB_NATGW_PUBLIC_IFACE}: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
57 link/ether ${_mac} brd ff:ff:ff:ff:ff:ff
58 inet ${CTDB_NATGW_PUBLIC_IP} brd ${_brd} scope global ${CTDB_NATGW_PUBLIC_IFACE}
59 valid_lft forever preferred_lft forever
63 ok_natgw_follower_ip_addr_show
()
65 _mac
=$
(echo "$CTDB_NATGW_PUBLIC_IFACE" |
67 sed -r -e 's@(..)(..)(..).*@fe:fe:fe:\1:\2:\3@')
70 1: ${CTDB_NATGW_PUBLIC_IFACE}: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
71 link/ether ${_mac} brd ff:ff:ff:ff:ff:ff
75 ok_natgw_leader_static_routes
()
80 for _i
in $CTDB_NATGW_STATIC_ROUTES; do
81 # This is intentionally different to the code in 11.natgw ;-)
84 _net
=$
(echo "$_i" |
sed -e 's|@.*||')
85 _gw
=$
(echo "$_i" |
sed -e 's|.*@||')
89 _gw
="$CTDB_NATGW_DEFAULT_GATEWAY"
93 [ -n "$_gw" ] ||
continue
94 _t
="${_t}${_t:+${_nl}}"
95 _t
="${_t}${_net} via ${_gw} dev ethXXX metric 10 "
97 _t
=$
(echo "$_t" |
sort)
101 ok_natgw_follower_static_routes
()
106 for _i
in $CTDB_NATGW_STATIC_ROUTES; do
107 # This is intentionally different to the code in 11.natgw ;-)
108 _net
=$
(echo "$_i" |
sed -e 's|@.*||')
110 # The interface for the private network isn't
111 # specified as part of the NATGW configuration and
112 # isn't part of the command to add the route. It is
113 # implicitly added by "ip route" but our stub doesn't
114 # do this and adds "ethXXX".
115 _t
="${_t}${_t:+${_nl}}"
116 _t
="${_t}${_net} via ${FAKE_CTDB_NATGW_LEADER} dev ethXXX metric 10 "
118 _t
=$
(echo "$_t" |
sort)