ctdb-tests-eventscripts: Testing support for promote_secondaries
authorMartin Schwenke <martin@meltin.net>
Tue, 28 Jan 2014 05:08:50 +0000 (16:08 +1100)
committerAmitay Isaacs <amitay@samba.org>
Thu, 13 Feb 2014 01:03:24 +0000 (02:03 +0100)
Just enable this behaviour by default in the ip command stub, since
10.interface assumes/sets it.  The rc.local replacement for set_proc()
doesn't do anything...

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/tests/eventscripts/etc-ctdb/rc.local
ctdb/tests/eventscripts/stubs/ip

index 6052d87f130335febd62d26f45e6cd994cc1431f..0dc531f8288a7bbaf9d71b3ce52c171814c9ea8b 100755 (executable)
@@ -33,6 +33,9 @@ get_proc ()
        sys/net/ipv4/conf/all/arp_filter)
            echo 1
            ;;
+       sys/net/ipv4/conf/all/promote_secondaries)
+           echo 1
+           ;;
        fs/nfsd/threads)
            echo "$FAKE_NFSD_THREAD_PIDS" | wc -w
            ;;
index f076cb9b5f1212834746b11020a1d013904afff2..860f6a54089a9ff6e2d63e811d836fa2e193a9f5 100755 (executable)
@@ -1,5 +1,7 @@
 #!/bin/sh
 
+promote_secondaries=true
+
 not_implemented ()
 {
     echo "ip stub command: \"$1\" not implemented"
@@ -305,8 +307,13 @@ ip_addr_del ()
        echo "RTNETLINK answers: Cannot assign requested address" >&2
        exit 254
     elif grep -Fq "$local" "$pf" ; then
-       # Remove primaries AND SECONDARIES.
-       rm -f "$pf" "$sf"
+       if $promote_secondaries && [ -s "$sf" ] ; then
+           head -n 1 "$sf" >"$pf"
+           sed -i -e '1d' "$sf"
+       else
+           # Remove primaries AND SECONDARIES.
+           rm -f "$pf" "$sf"
+       fi
     elif [ -f "$sf" ] && grep -Fq "$local" "$sf" ; then 
        grep -Fv "$local" "$sf" >"${sf}.new"
        mv "${sf}.new" "$sf"