ctdb-tests: Create 13.per_ip_routing.sh
authorMartin Schwenke <martin@meltin.net>
Mon, 19 Mar 2018 09:39:27 +0000 (20:39 +1100)
committerAmitay Isaacs <amitay@samba.org>
Wed, 28 Mar 2018 00:57:17 +0000 (02:57 +0200)
Contains testing support used only by tests for 13.per_ip_routing
event script.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/tests/eventscripts/scripts/13.per_ip_routing.sh [new file with mode: 0644]
ctdb/tests/eventscripts/scripts/local.sh

diff --git a/ctdb/tests/eventscripts/scripts/13.per_ip_routing.sh b/ctdb/tests/eventscripts/scripts/13.per_ip_routing.sh
new file mode 100644 (file)
index 0000000..557fcb6
--- /dev/null
@@ -0,0 +1,38 @@
+setup_ctdb_policy_routing ()
+{
+       service_name="per_ip_routing"
+
+       export CTDB_PER_IP_ROUTING_CONF="$CTDB_BASE/policy_routing"
+       export CTDB_PER_IP_ROUTING_RULE_PREF=100
+       export CTDB_PER_IP_ROUTING_TABLE_ID_LOW=1000
+       export CTDB_PER_IP_ROUTING_TABLE_ID_HIGH=2000
+
+       # Tests need to create and populate this file
+       rm -f "$CTDB_PER_IP_ROUTING_CONF"
+}
+
+# Create policy routing configuration in $CTDB_PER_IP_ROUTING_CONF.
+# $1 is the number of assigned IPs to use (<num>, all), defaulting to
+# 1.  If $2 is "default" then a default route is also added.
+create_policy_routing_config ()
+{
+       _num_ips="${1:-1}"
+       _should_add_default="$2"
+
+       ctdb_get_my_public_addresses |
+       if [ "$_num_ips" = "all" ] ; then
+               cat
+       else
+               { head -n "$_num_ips" ; cat >/dev/null ; }
+       fi |
+       while read _dev _ip _bits ; do
+               _net=$(ipv4_host_addr_to_net "$_ip" "$_bits")
+               _gw="${_net%.*}.254" # a dumb, calculated default
+
+               echo "$_ip $_net"
+
+               if [ "$_should_add_default" = "default" ] ; then
+                       echo "$_ip 0.0.0.0/0 $_gw"
+               fi
+       done >"$CTDB_PER_IP_ROUTING_CONF"
+}
index ae0d3f88a50318d480c46cea088930cf0b38f629..d9457420e84c71267c95790b7b465ff1a87d8e2b 100644 (file)
@@ -363,47 +363,6 @@ ctdb_not_implemented ()
 DEBUG: ctdb: command \"$1\" not implemented in stub"
 }
 
-######################################################################
-
-setup_ctdb_policy_routing ()
-{
-    service_name="per_ip_routing"
-
-    export CTDB_PER_IP_ROUTING_CONF="$CTDB_BASE/policy_routing"
-    export CTDB_PER_IP_ROUTING_RULE_PREF=100
-    export CTDB_PER_IP_ROUTING_TABLE_ID_LOW=1000
-    export CTDB_PER_IP_ROUTING_TABLE_ID_HIGH=2000
-
-    # Tests need to create and populate this file
-    rm -f "$CTDB_PER_IP_ROUTING_CONF"
-}
-
-# Create policy routing configuration in $CTDB_PER_IP_ROUTING_CONF.
-# $1 is the number of assigned IPs to use (<num>, all), defaulting to
-# 1.  If $2 is "default" then a default route is also added.
-create_policy_routing_config ()
-{
-    _num_ips="${1:-1}"
-    _should_add_default="$2"
-
-    ctdb_get_my_public_addresses |
-    if [ "$_num_ips" = "all" ] ; then
-       cat
-    else
-       { head -n "$_num_ips" ; cat >/dev/null ; }
-    fi |
-    while read _dev _ip _bits ; do
-       _net=$(ipv4_host_addr_to_net "$_ip" "$_bits")
-       _gw="${_net%.*}.254" # a dumb, calculated default
-
-       echo "$_ip $_net"
-
-       if [ "$_should_add_default" = "default" ] ; then
-           echo "$_ip 0.0.0.0/0 $_gw"
-       fi
-    done >"$CTDB_PER_IP_ROUTING_CONF"
-}
-
 # Check the routes against those that are expected.  $1 is the number
 # of assigned IPs to use (<num>, all), defaulting to 1.  If $2 is
 # "default" then expect default routes to have been added.