2a3635
From c6ee0973522268ed7b3241cf0ec2e06398444114 Mon Sep 17 00:00:00 2001
2a3635
From: Grace Chin <gchin@redhat.com>
2a3635
Date: Tue, 4 May 2021 12:02:17 -0400
2a3635
Subject: [PATCH 1/4] Remove deprecated attrd_options
2a3635
2a3635
---
2a3635
 extra/resources/ping | 11 +++--------
2a3635
 1 file changed, 3 insertions(+), 8 deletions(-)
2a3635
2a3635
diff --git a/extra/resources/ping b/extra/resources/ping
2a3635
index 3cf8dfe..2e93f22 100755
2a3635
--- a/extra/resources/ping
2a3635
+++ b/extra/resources/ping
2a3635
@@ -178,7 +178,7 @@ ping_stop() {
2a3635
 
2a3635
     rm -f "${OCF_RESKEY_pidfile}"
2a3635
 
2a3635
-    attrd_updater -D -n "$OCF_RESKEY_name" -d "$OCF_RESKEY_dampen" $attrd_options
2a3635
+    attrd_updater -D -n "$OCF_RESKEY_name" -d "$OCF_RESKEY_dampen"
2a3635
 
2a3635
     return $OCF_SUCCESS
2a3635
 }
2a3635
@@ -302,9 +302,9 @@ ping_update() {
2a3635
 
2a3635
     score=$(expr $active \* $OCF_RESKEY_multiplier)
2a3635
     if [ "$__OCF_ACTION" = "start" ] ; then
2a3635
-        attrd_updater -n "$OCF_RESKEY_name" -B "$score" -d "$OCF_RESKEY_dampen" $attrd_options
2a3635
+        attrd_updater -n "$OCF_RESKEY_name" -B "$score" -d "$OCF_RESKEY_dampen"
2a3635
     else
2a3635
-        attrd_updater -n "$OCF_RESKEY_name" -v "$score" -d "$OCF_RESKEY_dampen" $attrd_options
2a3635
+        attrd_updater -n "$OCF_RESKEY_name" -v "$score" -d "$OCF_RESKEY_dampen"
2a3635
     fi
2a3635
     rc=$?
2a3635
     case $rc in
2a3635
@@ -396,11 +396,6 @@ case "${OCF_RESKEY_debug}" in
2a3635
         ;;
2a3635
 esac
2a3635
 
2a3635
-attrd_options='-q'
2a3635
-if [ "${OCF_RESKEY_debug}" = "true" ]; then
2a3635
-    attrd_options=''
2a3635
-fi
2a3635
-
2a3635
 case "$__OCF_ACTION" in
2a3635
 meta-data)      meta_data
2a3635
                 exit $OCF_SUCCESS
2a3635
-- 
2a3635
1.8.3.1
2a3635
2a3635
2a3635
From 6d6c4691cf0970059689856c354daf9e098b4451 Mon Sep 17 00:00:00 2001
2a3635
From: Grace Chin <gchin@redhat.com>
2a3635
Date: Tue, 4 May 2021 14:50:37 -0400
2a3635
Subject: [PATCH 2/4] Replace debug values, true and false, with 0 and 1
2a3635
2a3635
---
2a3635
 extra/resources/ping | 8 ++++----
2a3635
 1 file changed, 4 insertions(+), 4 deletions(-)
2a3635
2a3635
diff --git a/extra/resources/ping b/extra/resources/ping
2a3635
index 2e93f22..fee019b 100755
2a3635
--- a/extra/resources/ping
2a3635
+++ b/extra/resources/ping
2a3635
@@ -24,7 +24,7 @@
2a3635
 : ${OCF_RESKEY_dampen:="5s"}
2a3635
 : ${OCF_RESKEY_attempts:="3"}
2a3635
 : ${OCF_RESKEY_multiplier:="1"}
2a3635
-: ${OCF_RESKEY_debug:="false"}
2a3635
+: ${OCF_RESKEY_debug:="0"}
2a3635
 : ${OCF_RESKEY_failure_score:="0"}
2a3635
 : ${OCF_RESKEY_use_fping:="1"}
2a3635
 : ${OCF_RESKEY_host_list:=""}
2a3635
@@ -152,7 +152,7 @@ END
2a3635
 
2a3635
 ping_conditional_log() {
2a3635
     level="$1"; shift
2a3635
-    if [ "${OCF_RESKEY_debug}" = "true" ]; then
2a3635
+    if [ $OCF_RESKEY_debug -gt 0 ]; then
2a3635
         ocf_log "$level" "$*"
2a3635
     fi
2a3635
 }
2a3635
@@ -388,8 +388,8 @@ fi
2a3635
 
2a3635
 # Check the debug option
2a3635
 case "${OCF_RESKEY_debug}" in
2a3635
-    true|True|TRUE|1)    OCF_RESKEY_debug=true;;
2a3635
-    false|False|FALSE|0) OCF_RESKEY_debug=false;;
2a3635
+    true|True|TRUE|1)    OCF_RESKEY_debug=0;;
2a3635
+    false|False|FALSE|0) OCF_RESKEY_debug=1;;
2a3635
     *)
2a3635
         ocf_log warn "Value for 'debug' is incorrect. Please specify 'true' or 'false' not: ${OCF_RESKEY_debug}"
2a3635
         OCF_RESKEY_debug=false
2a3635
-- 
2a3635
1.8.3.1
2a3635
2a3635
2a3635
From a886a31056b6aca764c6911f5432af2c5ebf51df Mon Sep 17 00:00:00 2001
2a3635
From: Grace Chin <gchin@redhat.com>
2a3635
Date: Tue, 11 May 2021 11:04:50 -0400
2a3635
Subject: [PATCH 3/4] Add verbose debug mode which logs ping and fping output
2a3635
 when set
2a3635
2a3635
---
2a3635
 extra/resources/ping | 19 ++++++++++++++-----
2a3635
 1 file changed, 14 insertions(+), 5 deletions(-)
2a3635
2a3635
diff --git a/extra/resources/ping b/extra/resources/ping
2a3635
index fee019b..cc796af 100755
2a3635
--- a/extra/resources/ping
2a3635
+++ b/extra/resources/ping
2a3635
@@ -249,10 +249,13 @@ fping_check() {
2a3635
 
2a3635
     case $rc in
2a3635
         0)
2a3635
+            if [ $OCF_RESKEY_debug -gt 1 ]; then
2a3635
+                ping_conditional_log info "$output"
2a3635
+            fi
2a3635
             ;;
2a3635
         1)
2a3635
             for h in $(echo "$output" | grep "is unreachable" | awk '{print $1}'); do
2a3635
-                ping_conditional_log warn "$h is inactive"
2a3635
+                ping_conditional_log warn "$h is inactive: $output"
2a3635
             done
2a3635
             ;;
2a3635
         *)
2a3635
@@ -282,7 +285,12 @@ ping_check() {
2a3635
         p_out=$($p_exe $p_args $OCF_RESKEY_options $host 2>&1;; rc=$?
2a3635
 
2a3635
         case $rc in
2a3635
-            0) active=$(expr $active + 1);;
2a3635
+            0)
2a3635
+                active=$(expr $active + 1)
2a3635
+                if [ $OCF_RESKEY_debug -gt 1 ]; then
2a3635
+                    ping_conditional_log info "$p_out"
2a3635
+                fi
2a3635
+                ;;
2a3635
             1) ping_conditional_log warn "$host is inactive: $p_out";;
2a3635
             *) ocf_log err "Unexpected result for '$p_exe $p_args $OCF_RESKEY_options $host' $rc: $p_out";;
2a3635
         esac
2a3635
@@ -388,10 +396,11 @@ fi
2a3635
 
2a3635
 # Check the debug option
2a3635
 case "${OCF_RESKEY_debug}" in
2a3635
-    true|True|TRUE|1)    OCF_RESKEY_debug=0;;
2a3635
-    false|False|FALSE|0) OCF_RESKEY_debug=1;;
2a3635
+    true|True|TRUE|1)    OCF_RESKEY_debug=1;;
2a3635
+    false|False|FALSE|0) OCF_RESKEY_debug=0;;
2a3635
+    verbose|Verbose|VERBOSE|2) OCF_RESKEY_debug=2;;
2a3635
     *)
2a3635
-        ocf_log warn "Value for 'debug' is incorrect. Please specify 'true' or 'false' not: ${OCF_RESKEY_debug}"
2a3635
+        ocf_log warn "Value for 'debug' is incorrect. Please specify 'true', 'false', or 'verbose', not: ${OCF_RESKEY_debug}"
2a3635
         OCF_RESKEY_debug=false
2a3635
         ;;
2a3635
 esac
2a3635
-- 
2a3635
1.8.3.1
2a3635
2a3635
2a3635
From 460043f133ced80e923b1290af70502a72deb7f8 Mon Sep 17 00:00:00 2001
2a3635
From: Grace Chin <gchin@redhat.com>
2a3635
Date: Tue, 11 May 2021 11:07:05 -0400
2a3635
Subject: [PATCH 4/4] Improve variable names
2a3635
2a3635
---
2a3635
 extra/resources/ping | 20 ++++++++++----------
2a3635
 1 file changed, 10 insertions(+), 10 deletions(-)
2a3635
2a3635
diff --git a/extra/resources/ping b/extra/resources/ping
2a3635
index cc796af..9763b60 100755
2a3635
--- a/extra/resources/ping
2a3635
+++ b/extra/resources/ping
2a3635
@@ -244,22 +244,22 @@ fping_check() {
2a3635
     timeout=$(expr $OCF_RESKEY_timeout \* 1000 / $OCF_RESKEY_attempts)
2a3635
 
2a3635
     cmd="$p_exe -r $OCF_RESKEY_attempts -t $timeout -B 1.0 $OCF_RESKEY_options $OCF_RESKEY_host_list"
2a3635
-    output=$($cmd 2>&1;; rc=$?
2a3635
-    active=$(echo "$output" | grep "is alive" | wc -l)
2a3635
+    fping_output=$($cmd 2>&1;; rc=$?
2a3635
+    active=$(echo "$fping_output" | grep "is alive" | wc -l)
2a3635
 
2a3635
     case $rc in
2a3635
         0)
2a3635
             if [ $OCF_RESKEY_debug -gt 1 ]; then
2a3635
-                ping_conditional_log info "$output"
2a3635
+                ping_conditional_log info "$fping_output"
2a3635
             fi
2a3635
             ;;
2a3635
         1)
2a3635
-            for h in $(echo "$output" | grep "is unreachable" | awk '{print $1}'); do
2a3635
-                ping_conditional_log warn "$h is inactive: $output"
2a3635
+            for h in $(echo "$fping_output" | grep "is unreachable" | awk '{print $1}'); do
2a3635
+                ping_conditional_log warn "$h is inactive: $fping_output"
2a3635
             done
2a3635
             ;;
2a3635
         *)
2a3635
-            ocf_log err "Unexpected result for '$cmd' $rc: $(echo "$output" | tr '\n' ';')"
2a3635
+            ocf_log err "Unexpected result for '$cmd' $rc: $(echo "$fping_output" | tr '\n' ';')"
2a3635
             ;;
2a3635
     esac
2a3635
 
2a3635
@@ -282,17 +282,17 @@ ping_check() {
2a3635
             *:*) p_exe=ping6
2a3635
         esac
2a3635
 
2a3635
-        p_out=$($p_exe $p_args $OCF_RESKEY_options $host 2>&1;; rc=$?
2a3635
+        ping_output=$($p_exe $p_args $OCF_RESKEY_options $host 2>&1;; rc=$?
2a3635
 
2a3635
         case $rc in
2a3635
             0)
2a3635
                 active=$(expr $active + 1)
2a3635
                 if [ $OCF_RESKEY_debug -gt 1 ]; then
2a3635
-                    ping_conditional_log info "$p_out"
2a3635
+                    ping_conditional_log info "$ping_output"
2a3635
                 fi
2a3635
                 ;;
2a3635
-            1) ping_conditional_log warn "$host is inactive: $p_out";;
2a3635
-            *) ocf_log err "Unexpected result for '$p_exe $p_args $OCF_RESKEY_options $host' $rc: $p_out";;
2a3635
+            1) ping_conditional_log warn "$host is inactive: $ping_output";;
2a3635
+            *) ocf_log err "Unexpected result for '$p_exe $p_args $OCF_RESKEY_options $host' $rc: $ping_output";;
2a3635
         esac
2a3635
     done
2a3635
     return $active
2a3635
-- 
2a3635
1.8.3.1
2a3635