[SCM] CTDB repository - branch 2.5 updated - ctdb-2.5.2-90-gce7e1ce

Amitay Isaacs amitay at samba.org
Wed Mar 26 23:31:28 MDT 2014


The branch, 2.5 has been updated
       via  ce7e1cecb831e9eb1c994aa4b86ce13299af436f (commit)
       via  12ec379d6cfd58dc2416f9e212973ef04a2326e6 (commit)
       via  ceea3beb65e524bc864ea17940bb846b28b302e3 (commit)
       via  a4ff3c748d253162289f95c3fe94e935f8acc48f (commit)
       via  2d616266a221e54019eaf09ff5276c2c455bbf57 (commit)
       via  41b630097d0cabfe32bd2b3cf9cbcae9aeff5c5f (commit)
       via  8909030c2559b0e627db83937580d2fbf1227247 (commit)
       via  f4bd0dca4ad63268203ef123bcd1287a38583844 (commit)
       via  a15fbcc26c9b1753a525694c318d8f77c0f38dfa (commit)
       via  e046b625e0f1461bfa84972f0b981111fce725bb (commit)
       via  62268bf277dad3d79e33bc88d51dffc53a3a873d (commit)
       via  6587dc06cc5b697289af3888cd94a5c6d1e5ce8e (commit)
      from  e386fc4e82a30dc7dd37b1a3de928bddfca871a8 (commit)

http://gitweb.samba.org/?p=ctdb.git;a=shortlog;h=2.5


- Log -----------------------------------------------------------------
commit ce7e1cecb831e9eb1c994aa4b86ce13299af436f
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Mar 17 16:06:48 2014 +1100

    tests: Add NAT gateway eventscript unit tests for static routes
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    
    (Imported from commit 2b83bec1041995478e613ebefb1035ff91e1b4e2)

commit 12ec379d6cfd58dc2416f9e212973ef04a2326e6
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Mar 7 15:33:17 2014 +1100

    eventscripts: CTDB_NATGW_STATIC_ROUTES can specify gateways
    
    Extend CTDB_NATGW_STATIC_ROUTES so that each network can have an
    optional gateway that overrides CTDB_NATGW_DEFAULT_GATEWAY.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    
    (Imported from commit a8fa3e780f6cd9505867cbd073c2333653bf4d32)

commit ceea3beb65e524bc864ea17940bb846b28b302e3
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Mar 7 15:11:36 2014 +1100

    eventscripts: New configuration variable CTDB_NATGW_STATIC_ROUTES
    
    This can be used to create more specific NATGW routes than the usual
    NATGW default route.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    
    (Imported from commit 3a623223153657acf8ea1ab38652f729b204b918)

commit a4ff3c748d253162289f95c3fe94e935f8acc48f
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Mar 7 14:14:16 2014 +1100

    eventscripts: Clarify that CTDB_NATGW_DEFAULT_GATEWAY is optional
    
    This has been implied since the command to add the route has had
    errors redirected to /dev/null.  If infrastucture (e.g. ADS, DNS) is
    on the same network as CTDB_NATGW_PUBLIC_IP then no route is
    necessary.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    
    (Imported from commit d88ace388e7a5a9e04d0d0c7f3e55edc16d8771b)

commit 2d616266a221e54019eaf09ff5276c2c455bbf57
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Mar 7 14:07:17 2014 +1100

    eventscripts: Improve check in NATGW "startup" event
    
    Although the dots in $CTDB_NATGW_PUBLIC_IP could probably only help
    match an invalid public IP address, this is only executed once so do
    as exact a check as possible.
    
    Use CTDB_BASE instead of hardcoding /etc/ctdb.
    
    Make the error message less redundant.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    
    (Imported from commit 1615c21fe0bbbae03f2e8e15c3527cd4bd3b2bf5)

commit 41b630097d0cabfe32bd2b3cf9cbcae9aeff5c5f
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Mar 7 13:55:47 2014 +1100

    eventscripts: Reformat natgw_clear()
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    
    (Imported from commit 996b639ea76d0e5d3b2a4eaa1279e5efdd24ca8f)

commit 8909030c2559b0e627db83937580d2fbf1227247
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Mar 7 13:47:43 2014 +1100

    eventscripts: Rename some NAT gateway functions
    
    delete_all() really needed renaming for clarity.  While doing this,
    might as well rename some of the others that don't start with
    "natgw_".
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    
    (Imported from commit 9ef20edcbe7331138cd4b2eb1aafc007c682a296)

commit f4bd0dca4ad63268203ef123bcd1287a38583844
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Mar 17 06:15:39 2014 +1100

    tests: Add a test for NAT gateway sanity checking
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    
    (Imported from commit 7c0b7f699900aff69723c1f27341946752ba2bb4)

commit a15fbcc26c9b1753a525694c318d8f77c0f38dfa
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Mar 7 13:43:17 2014 +1100

    eventscripts: Sanity check NAT gateway configuration
    
    NAT gateway really can't operate unless most of the configuration
    variables are set.
    
    A check in delete_all() can be removed - strange that this isn't also
    done in the add case.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    
    (Imported from commit d4f333f5e6186d88f436b0a747f500f3f32ed9bd)

commit e046b625e0f1461bfa84972f0b981111fce725bb
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Mar 7 13:35:03 2014 +1100

    eventscripts: Improve readability of NAT gateway update code
    
    Put the code into a couple of usefully named functions.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    
    (Imported from commit a7b2794f7bbf601351cef1e18bfc8c05183b35de)

commit 62268bf277dad3d79e33bc88d51dffc53a3a873d
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Mar 14 16:29:01 2014 +1100

    tests: Add some tests for 11.natgw eventscript
    
    This includes adding support for:
    
    * Configuring fake NATGW state in the eventscript unit tests
    
    * "natgwlist" and "setnatgwstate" in ctdb command stub
    
    * ip command stub to default to "main table" when no table specified,
      allow routes to be added without "dev" option (just add a default
      dev), support "metric" option
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    
    (Imported from commit bfb615cfec4ebbdb75ebebc67087e0b43df386e7)

commit 6587dc06cc5b697289af3888cd94a5c6d1e5ce8e
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Mar 7 13:37:21 2014 +1100

    eventscripts: Use set_proc() to update /proc
    
    In case we want to write some unit tests in the future.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    
    (Imported from commit 5519a05766ca9e0a8ace39c49661b9ad52440cac)

-----------------------------------------------------------------------

Summary of changes:
 config/events.d/11.natgw                           |  139 ++++++++++++++------
 doc/ctdb.7.xml                                     |   23 +++-
 doc/ctdbd.conf.5.xml                               |   61 ++++++++-
 .../{13.per_ip_routing.001.sh => 11.natgw.001.sh}  |    3 -
 .../{13.per_ip_routing.002.sh => 11.natgw.002.sh}  |   14 ++-
 tests/eventscripts/11.natgw.011.sh                 |   23 ++++
 tests/eventscripts/11.natgw.012.sh                 |   23 ++++
 tests/eventscripts/11.natgw.013.sh                 |   25 ++++
 tests/eventscripts/11.natgw.014.sh                 |   25 ++++
 tests/eventscripts/11.natgw.015.sh                 |   61 +++++++++
 tests/eventscripts/11.natgw.021.sh                 |   25 ++++
 tests/eventscripts/11.natgw.022.sh                 |   25 ++++
 tests/eventscripts/11.natgw.023.sh                 |   25 ++++
 tests/eventscripts/11.natgw.024.sh                 |   25 ++++
 tests/eventscripts/11.natgw.025.sh                 |   63 +++++++++
 tests/eventscripts/scripts/local.sh                |  101 ++++++++++++++
 tests/eventscripts/stubs/ctdb                      |   82 +++++++++++-
 tests/eventscripts/stubs/ip                        |   84 ++++++++++--
 18 files changed, 750 insertions(+), 77 deletions(-)
 copy tests/eventscripts/{13.per_ip_routing.001.sh => 11.natgw.001.sh} (79%)
 copy tests/eventscripts/{13.per_ip_routing.002.sh => 11.natgw.002.sh} (52%)
 create mode 100755 tests/eventscripts/11.natgw.011.sh
 create mode 100755 tests/eventscripts/11.natgw.012.sh
 create mode 100755 tests/eventscripts/11.natgw.013.sh
 create mode 100755 tests/eventscripts/11.natgw.014.sh
 create mode 100755 tests/eventscripts/11.natgw.015.sh
 create mode 100755 tests/eventscripts/11.natgw.021.sh
 create mode 100755 tests/eventscripts/11.natgw.022.sh
 create mode 100755 tests/eventscripts/11.natgw.023.sh
 create mode 100755 tests/eventscripts/11.natgw.024.sh
 create mode 100755 tests/eventscripts/11.natgw.025.sh


Changeset truncated at 500 lines:

diff --git a/config/events.d/11.natgw b/config/events.d/11.natgw
index 8555005..b2a219c 100755
--- a/config/events.d/11.natgw
+++ b/config/events.d/11.natgw
@@ -14,7 +14,22 @@ loadconfig
 [ -n "$CTDB_NATGW_NODES" ] || exit 0
 export CTDB_NATGW_NODES
 
-set_natgw_capability ()
+natgw_check_config ()
+{
+    [ -r "$CTDB_NATGW_NODES" ] || \
+	die "error: CTDB_NATGW_NODES=${CTDB_NATGW_NODES} unreadable"
+    [ -n "$CTDB_NATGW_PUBLIC_IP" ] || \
+	die "Invalid configuration: CTDB_NATGW_PUBLIC_IP not set"
+    [ -n "$CTDB_NATGW_PUBLIC_IFACE" ] || \
+	die "Invalid configuration: CTDB_NATGW_PUBLIC_IFACE not set"
+    [ -n "$CTDB_NATGW_PRIVATE_NETWORK" ] || \
+	die "Invalid configuration: CTDB_NATGW_PRIVATE_NETWORK not set"
+
+    # The default is to create a single default route
+    [ -n "$CTDB_NATGW_STATIC_ROUTES" ] || CTDB_NATGW_STATIC_ROUTES="0.0.0.0/0"
+}
+
+natgw_set_capability ()
 {
     # Set NATGW capability depending on configuration
     if [ "$CTDB_NATGW_SLAVE_ONLY" = "yes" ] ; then
@@ -24,24 +39,70 @@ set_natgw_capability ()
     fi
 }
 
-delete_all() {
-	_ip="${CTDB_NATGW_PUBLIC_IP%/*}"
-	_maskbits="${CTDB_NATGW_PUBLIC_IP#*/}"
+natgw_clear ()
+{
+    _ip="${CTDB_NATGW_PUBLIC_IP%/*}"
+    _maskbits="${CTDB_NATGW_PUBLIC_IP#*/}"
+
+    delete_ip_from_iface \
+	$CTDB_NATGW_PUBLIC_IFACE $_ip $_maskbits >/dev/null 2>&1
+    for _net_gw in $CTDB_NATGW_STATIC_ROUTES ; do
+	_net="${_net_gw%@*}"
+	ip route del "$_net" metric 10 >/dev/null 2>/dev/null
+    done
+
+    # Delete the masquerading setup from a previous iteration where we
+    # were the NAT-GW
+    iptables -D POSTROUTING -t nat \
+	-s $CTDB_NATGW_PRIVATE_NETWORK ! -d $CTDB_NATGW_PRIVATE_NETWORK \
+	-j MASQUERADE >/dev/null 2>/dev/null
+
+    iptables -D INPUT -p tcp --syn -d $_ip/32 -j REJECT 2>/dev/null
+}
 
-	[ -z "$CTDB_NATGW_PUBLIC_IFACE" ] || {
-	    delete_ip_from_iface $CTDB_NATGW_PUBLIC_IFACE $_ip $_maskbits >/dev/null 2>&1
-	}
-	ip route del 0.0.0.0/0 metric 10 >/dev/null 2>/dev/null
+natgw_set_master ()
+{
+    set_proc sys/net/ipv4/ip_forward 1
+    iptables -A POSTROUTING -t nat \
+	-s $CTDB_NATGW_PRIVATE_NETWORK ! -d $CTDB_NATGW_PRIVATE_NETWORK \
+	-j MASQUERADE
+
+    # block all incoming connections to the NATGW IP address
+    ctdb_natgw_public_ip_host="${CTDB_NATGW_PUBLIC_IP%/*}/32"
+    iptables -D INPUT -p tcp --syn \
+	-d $ctdb_natgw_public_ip_host -j REJECT 2>/dev/null
+    iptables -I INPUT -p tcp --syn \
+	-d $ctdb_natgw_public_ip_host -j REJECT 2>/dev/null
+
+    ip addr add $CTDB_NATGW_PUBLIC_IP dev $CTDB_NATGW_PUBLIC_IFACE
+    for _net_gw in $CTDB_NATGW_STATIC_ROUTES ; do
+	_net="${_net_gw%@*}"
+	if [ "$_net" != "$_net_gw" ] ; then
+	    _gw="${_net_gw#*@}"
+	else
+	    _gw="$CTDB_NATGW_DEFAULT_GATEWAY"
+	fi
 
-	# Delete the masquerading setup from a previous iteration where we
-	# were the NAT-GW
-	iptables -D POSTROUTING -t nat -s $CTDB_NATGW_PRIVATE_NETWORK ! -d $CTDB_NATGW_PRIVATE_NETWORK -j MASQUERADE >/dev/null 2>/dev/null
+	[ -n "$_gw" ] || continue
+	ip route add "$_net" metric 10 via "$_gw"
+    done
+}
 
-	# remove any iptables rule we may have on this address
-	iptables -D INPUT -p tcp --syn -d $_ip/32 -j REJECT 2>/dev/null
+natgw_set_slave ()
+{
+    _natgwip="$1"
+
+    for _net_gw in $CTDB_NATGW_STATIC_ROUTES ; do
+	_net="${_net_gw%@*}"
+	ip route add "$_net" via "$_natgwip" metric 10
+    done
+
+    # Make sure winbindd does not stay bound to this address if we are
+    # no longer NATGW master
+    smbcontrol winbindd ip-dropped $CTDB_NATGW_PUBLIC_IP >/dev/null 2>&1
 }
 
-ensure_natgwmaster ()
+natgw_ensure_master ()
 {
     _event="$1"
 
@@ -57,57 +118,53 @@ ensure_natgwmaster ()
 
 case "$1" in 
     setup)
-	set_natgw_capability
+	natgw_check_config
+	natgw_set_capability
 	;;
 
     startup)
+	natgw_check_config
+
 	# Error if CTDB_NATGW_PUBLIC_IP is listed in public addresses
-	grep -q "^$CTDB_NATGW_PUBLIC_IP[[:space:]]" "${CTDB_PUBLIC_ADDRESSES:-/etc/ctdb/public_addresses}" && \
-	    die "ERROR: NATGW configured to use a public address. NATGW must not use a public address."
+	ip_pat=$(echo "$CTDB_NATGW_PUBLIC_IP" | sed -e 's@\.@\\. at g')
+	if grep -q "^${ip_pat}[[:space:]]" \
+	    "${CTDB_PUBLIC_ADDRESSES:-${CTDB_BASE}/public_addresses}" ; then
+	    die "ERROR: CTDB_NATGW_PUBLIC_IP same as a public address"
+	fi
 
 	# do not send out arp requests from loopback addresses
-	echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce
+	set_proc sys/net/ipv4/conf/all/arp_announce 2
 	;;
 
     updatenatgw|ipreallocated)
+	natgw_check_config
+
 	mypnn=$(ctdb pnn | cut -d: -f2)
 
-	set_natgw_capability
-	ensure_natgwmaster "$1"
+	natgw_set_capability
+	natgw_ensure_master "$1"
 
-	delete_all
+	natgw_clear
 
 	if [ "$mypnn" = "$natgwmaster" ]; then
-		# This is the NAT GW
-		echo 1 >/proc/sys/net/ipv4/ip_forward
-		iptables -A POSTROUTING -t nat -s $CTDB_NATGW_PRIVATE_NETWORK ! -d $CTDB_NATGW_PRIVATE_NETWORK -j MASQUERADE
-
-		# block all incoming connections to the natgw address
-		ctdb_natgw_public_ip_host="${CTDB_NATGW_PUBLIC_IP%/*}/32"
-		iptables -D INPUT -p tcp --syn -d $ctdb_natgw_public_ip_host -j REJECT 2>/dev/null
-		iptables -I INPUT -p tcp --syn -d $ctdb_natgw_public_ip_host -j REJECT 2>/dev/null
-
-		ip addr add $CTDB_NATGW_PUBLIC_IP dev $CTDB_NATGW_PUBLIC_IFACE
-		ip route add 0.0.0.0/0 metric 10 via $CTDB_NATGW_DEFAULT_GATEWAY >/dev/null 2>/dev/null
+	    natgw_set_master
 	else
-		# This is NOT the NAT GW
-		ip route add 0.0.0.0/0 via $natgwip metric 10
-		# Make sure winbindd does not stay bound to this address
-		# if we are no longer natgwmaster
-		smbcontrol winbindd ip-dropped $CTDB_NATGW_PUBLIC_IP >/dev/null 2>/dev/null
+	    natgw_set_slave "$natgwip"
 	fi
 
 	# flush our route cache
-	echo 1 > /proc/sys/net/ipv4/route/flush
+	set_proc sys/net/ipv4/route/flush 1
 	;;
 
     shutdown|removenatgw)
-	delete_all
+	natgw_check_config
+	natgw_clear
 	;;
 
     monitor)
-	set_natgw_capability
-	ensure_natgwmaster "$1"
+	natgw_check_config
+	natgw_set_capability
+	natgw_ensure_master "$1"
 	;;
 
     *)
diff --git a/doc/ctdb.7.xml b/doc/ctdb.7.xml
index 989a280..f48d5a6 100644
--- a/doc/ctdb.7.xml
+++ b/doc/ctdb.7.xml
@@ -635,11 +635,12 @@ CTDB_NATGW_DEFAULT_GATEWAY=10.0.0.1
 	<varname>CTDB_NATGW_PUBLIC_IP</varname> on the configured public
 	interfaces <varname>CTDB_NATGW_PUBLIC_IFACE</varname> and acts as
 	a router, masquerading outgoing connections from slave nodes
-	via this IP address.  It also establishes a fallback default
-	route to the configured default gateway
-	<varname>CTDB_NATGW_DEFAULT_GATEWAY</varname> with a metric of 10.
-	A metric 10 route is used so it can co-exist with other
-	default routes that may be available.
+	via this IP address.  If
+	<varname>CTDB_NATGW_DEFAULT_GATEWAY</varname> is set then it
+	also establishes a fallback default route to the configured
+	this gateway with a metric of 10.  A metric 10 route is used
+	so it can co-exist with other default routes that may be
+	available.
       </para>
 
       <para>
@@ -654,9 +655,17 @@ CTDB_NATGW_DEFAULT_GATEWAY=10.0.0.1
       </para>
 
       <para>
+	<varname>CTDB_NATGW_STATIC_ROUTES</varname> can be used to
+	have NATGW create more specific routes instead of just default
+	routes.
+      </para>
+
+      <para>
 	This is implemented in the <filename>11.natgw</filename>
-	eventscript. Please see the eventscript file for the finer
-	details.
+	eventscript.  Please see the eventscript file and the
+	<citetitle>NAT GATEWAY</citetitle> section in
+	<citerefentry><refentrytitle>ctdbd.conf</refentrytitle>
+	<manvolnum>5</manvolnum></citerefentry> for more details.
       </para>
 
     </refsect2>
diff --git a/doc/ctdbd.conf.5.xml b/doc/ctdbd.conf.5.xml
index d80bda6..188a4df 100644
--- a/doc/ctdbd.conf.5.xml
+++ b/doc/ctdbd.conf.5.xml
@@ -458,11 +458,13 @@
 	  <listitem>
 	    <para>
 	      IPADDR is an alternate network gateway to use on the NAT
-	      gateway master node.  A fallback default route is added
-	      via this network gateway.
+	      gateway master node.  If set, a fallback default route
+	      is added via this network gateway.
 	    </para>
 	    <para>
-	      No default.
+	      No default.  Setting this variable is optional - if not
+	      set that no route is created on the NAT gateway master
+	      node.
 	    </para>
 	  </listitem>
 	</varlistentry>
@@ -543,6 +545,42 @@
 	  </listitem>
 	</varlistentry>
 
+	<varlistentry>
+	  <term>CTDB_NATGW_STATIC_ROUTES=<parameter>IPADDR/MASK[@GATEWAY]</parameter> ...</term>
+	  <listitem>
+	    <para>
+	      Each IPADDR/MASK identifies a network or host to which
+	      NATGW should create a fallback route, instead of
+	      creating a single default route.  This can be used when
+	      there is already a default route, via an interface that
+	      can not reach required infrastructure, that overrides
+	      the NAT gateway default route.
+	    </para>
+	    <para>
+	      If GATEWAY is specified then the corresponding route on
+	      the NATGW master node will be via GATEWAY.  Such routes
+	      are created even if
+	      <varname>CTDB_NATGW_DEFAULT_GATEWAY</varname> is not
+	      specified.  If GATEWAY is not specified for some
+	      networks then routes are only created on the NATGW
+	      master node for those networks if
+	      <varname>CTDB_NATGW_DEFAULT_GATEWAY</varname> is
+	      specified.
+	    </para>
+	    <para>
+	      This should be used with care to avoid causing traffic
+	      to unnecessarily double-hop through the NAT gateway
+	      master, even when a node is hosting public IP addresses.
+	      Each specified network or host should probably have a
+	      corresponding automatically created link route or static
+	      route to avoid this.
+	    </para>
+	    <para>
+	      No default.
+	    </para>
+	  </listitem>
+	</varlistentry>
+
       </variablelist>
 
       <refsect3>
@@ -554,6 +592,23 @@ CTDB_NATGW_DEFAULT_GATEWAY=10.0.0.1
 CTDB_NATGW_PUBLIC_IP=10.0.0.227/24
 CTDB_NATGW_PUBLIC_IFACE=eth0
 	</screen>
+
+	<para>
+	  A variation that ensures that infrastructure (ADS, DNS, ...)
+	  directly attached to the public network (10.0.0.0/24) is
+	  always reachable would look like this:
+	</para>
+	<screen>
+CTDB_NATGW_NODES=/etc/ctdb/natgw_nodes
+CTDB_NATGW_PRIVATE_NETWORK=192.168.1.0/24
+CTDB_NATGW_PUBLIC_IP=10.0.0.227/24
+CTDB_NATGW_PUBLIC_IFACE=eth0
+CTDB_NATGW_STATIC_ROUTES=10.0.0.0/24
+	</screen>
+	<para>
+	  Note that <varname>CTDB_NATGW_DEFAULT_GATEWAY</varname> is
+	  not specified.
+	</para>
       </refsect3>
 
     </refsect2>
diff --git a/tests/eventscripts/13.per_ip_routing.001.sh b/tests/eventscripts/11.natgw.001.sh
similarity index 79%
copy from tests/eventscripts/13.per_ip_routing.001.sh
copy to tests/eventscripts/11.natgw.001.sh
index 8523c10..afcc097 100755
--- a/tests/eventscripts/13.per_ip_routing.001.sh
+++ b/tests/eventscripts/11.natgw.001.sh
@@ -7,9 +7,6 @@ define_test "not configured"
 setup_ctdb
 
 ok_null
-simple_test_event "takeip"
-
-ok_null
 simple_test_event "ipreallocate"
 
 check_routes 0
diff --git a/tests/eventscripts/13.per_ip_routing.002.sh b/tests/eventscripts/11.natgw.002.sh
similarity index 52%
copy from tests/eventscripts/13.per_ip_routing.002.sh
copy to tests/eventscripts/11.natgw.002.sh
index d6320c6..8dbeeee 100755
--- a/tests/eventscripts/13.per_ip_routing.002.sh
+++ b/tests/eventscripts/11.natgw.002.sh
@@ -5,15 +5,19 @@
 define_test "missing config file"
 
 setup_ctdb
-setup_ctdb_policy_routing
+setup_ctdb_natgw <<EOF
+192.168.1.21 master
+192.168.1.22
+192.168.1.23
+192.168.1.24
+EOF
+
+rm -f "$CTDB_NATGW_NODES"
 
-# Error because policy routing is configured but the configuration
-# file is missing.
 required_result 1 <<EOF
-error: CTDB_PER_IP_ROUTING_CONF=${CTDB_BASE}/policy_routing file not found
+error: CTDB_NATGW_NODES=${CTDB_NATGW_NODES} unreadable
 EOF
 
 for i in "startup" "ipreallocated" "monitor" ; do
     simple_test_event "$i"
 done
-
diff --git a/tests/eventscripts/11.natgw.011.sh b/tests/eventscripts/11.natgw.011.sh
new file mode 100755
index 0000000..4c5a937
--- /dev/null
+++ b/tests/eventscripts/11.natgw.011.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "master node, basic configuration"
+
+setup_ctdb
+
+setup_ctdb_natgw <<EOF
+192.168.1.21 master
+192.168.1.22
+192.168.1.23
+192.168.1.24
+EOF
+
+ok_null
+simple_test_event "ipreallocated"
+
+ok "default via ${CTDB_NATGW_DEFAULT_GATEWAY} dev ethXXX  metric 10 "
+simple_test_command ip route show
+
+ok_natgw_master_ip_addr_show
+simple_test_command ip addr show "$CTDB_NATGW_PUBLIC_IFACE"
diff --git a/tests/eventscripts/11.natgw.012.sh b/tests/eventscripts/11.natgw.012.sh
new file mode 100755
index 0000000..6ec98a0
--- /dev/null
+++ b/tests/eventscripts/11.natgw.012.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "slave node, basic configuration"
+
+setup_ctdb
+
+setup_ctdb_natgw <<EOF
+192.168.1.21
+192.168.1.22 master
+192.168.1.23
+192.168.1.24
+EOF
+
+ok_null
+simple_test_event "ipreallocated"
+
+ok "default via ${FAKE_CTDB_NATGW_MASTER} dev ethXXX  metric 10 "
+simple_test_command ip route show
+
+ok_natgw_slave_ip_addr_show
+simple_test_command ip addr show "$CTDB_NATGW_PUBLIC_IFACE"
diff --git a/tests/eventscripts/11.natgw.013.sh b/tests/eventscripts/11.natgw.013.sh
new file mode 100755
index 0000000..16f0622
--- /dev/null
+++ b/tests/eventscripts/11.natgw.013.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "master node, no gateway"
+
+setup_ctdb
+
+setup_ctdb_natgw <<EOF
+192.168.1.21 master
+192.168.1.22
+192.168.1.23
+192.168.1.24
+EOF
+
+CTDB_NATGW_DEFAULT_GATEWAY=""
+
+ok_null
+simple_test_event "ipreallocated"
+
+ok_null
+simple_test_command ip route show
+
+ok_natgw_master_ip_addr_show
+simple_test_command ip addr show "$CTDB_NATGW_PUBLIC_IFACE"
diff --git a/tests/eventscripts/11.natgw.014.sh b/tests/eventscripts/11.natgw.014.sh
new file mode 100755
index 0000000..462756c
--- /dev/null
+++ b/tests/eventscripts/11.natgw.014.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "slave node, no gateway"
+
+setup_ctdb
+
+setup_ctdb_natgw <<EOF
+192.168.1.21
+192.168.1.22 master
+192.168.1.23
+192.168.1.24
+EOF
+
+CTDB_NATGW_DEFAULT_GATEWAY=""
+
+ok_null
+simple_test_event "ipreallocated"
+
+ok "default via ${FAKE_CTDB_NATGW_MASTER} dev ethXXX  metric 10 "
+simple_test_command ip route show
+
+ok_natgw_slave_ip_addr_show
+simple_test_command ip addr show "$CTDB_NATGW_PUBLIC_IFACE"
diff --git a/tests/eventscripts/11.natgw.015.sh b/tests/eventscripts/11.natgw.015.sh
new file mode 100755
index 0000000..691b363
--- /dev/null
+++ b/tests/eventscripts/11.natgw.015.sh
@@ -0,0 +1,61 @@
+#!/bin/sh
+


-- 
CTDB repository


More information about the samba-cvs mailing list