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