ctdb-scripts: Move ctdb_get_ip_address() to functions file
authorMartin Schwenke <martin@meltin.net>
Fri, 8 Apr 2016 05:53:47 +0000 (15:53 +1000)
committerAmitay Isaacs <amitay@samba.org>
Fri, 15 Apr 2016 03:57:17 +0000 (05:57 +0200)
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/config/events.d/11.natgw
ctdb/config/functions

index 25cf27fa202d048053450bd89235862653866153..bc00788e7b7451c3ceb071ec9c73cd4854f9dac6 100755 (executable)
@@ -23,19 +23,6 @@ natgw_cfg_new="${service_state_dir}/cfg_new"
 natgw_cfg_old="${service_state_dir}/cfg_old"
 natgw_master_old="${service_state_dir}/master_old"
 
-# Cached retrieval of private IP address from local node.  This never
-# changes.  Sets $ip_address to avoid an unnecessary subprocess.
-ctdb_get_ip_address ()
-{
-    _ip_addr_file="${service_state_dir}/my-ip-address"
-    if [ ! -f "$_ip_addr_file" ] ; then
-       ctdb -X nodestatus |
-           awk -F '|' 'NR == 2 { print $3 }' >"$_ip_addr_file"
-    fi
-
-    read ip_address <"$_ip_addr_file"
-}
-
 ctdb_natgw_slave_only ()
 {
     ctdb_get_ip_address
index 8d3e344721545d1dce9350da3c5bd38b781cc1a1..782978dad842833608460a2c904b29bbfb1739c3 100755 (executable)
@@ -247,6 +247,19 @@ ctdb_get_pnn ()
     read pnn <"$_pnn_file"
 }
 
+# Cached retrieval of private IP address from local node.  This never
+# changes.  Sets $ip_address to avoid an unnecessary subprocess.
+ctdb_get_ip_address ()
+{
+    _ip_addr_file="${CTDB_SCRIPT_VARDIR}/my-ip-address"
+    if [ ! -f "$_ip_addr_file" ] ; then
+       ctdb -X nodestatus |
+           awk -F '|' 'NR == 2 { print $3 }' >"$_ip_addr_file"
+    fi
+
+    read ip_address <"$_ip_addr_file"
+}
+
 ######################################################
 # wrapper around /proc/ settings to allow them to be hooked
 # for testing