Blame SOURCES/bz2103370-ocf-tester-2-remove-deprecated-lrmd-lrmadmin-code.patch

f065e8
From 687aa646852d5fd5d4e811b2ec562ebffa15e23d Mon Sep 17 00:00:00 2001
f065e8
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
f065e8
Date: Thu, 14 Jul 2022 14:52:07 +0200
f065e8
Subject: [PATCH] ocf-tester: remove deprecated lrmd/lrmadmin code that hasnt
f065e8
 worked since pre-pacemaker days
f065e8
f065e8
---
f065e8
 tools/ocf-tester.8  | 12 ++-----
f065e8
 tools/ocf-tester.in | 81 ---------------------------------------------
f065e8
 2 files changed, 2 insertions(+), 91 deletions(-)
f065e8
f065e8
diff --git a/tools/ocf-tester.8 b/tools/ocf-tester.8
f065e8
index 850ec0be04..3f398282d2 100644
f065e8
--- a/tools/ocf-tester.8
f065e8
+++ b/tools/ocf-tester.8
f065e8
@@ -1,9 +1,9 @@
f065e8
-.TH OCF-TESTER "8" "January 2012" "Tool for testing if a cluster resource is OCF compliant" "System Administration Utilities"
f065e8
+.TH OCF-TESTER "8" "July 2022" "Tool for testing if a cluster resource is OCF compliant" "System Administration Utilities"
f065e8
 .SH NAME
f065e8
 ocf-tester \- Part of the Linux-HA project
f065e8
 .SH SYNOPSIS
f065e8
 .B ocf-tester
f065e8
-[\fI-LhvqdX\fR] \fI-n resource_name \fR[\fI-o name=value\fR]\fI* /full/path/to/resource/agent\fR
f065e8
+[\fI-hvqdX\fR] \fI-n resource_name \fR[\fI-o name=value\fR]\fI* /full/path/to/resource/agent\fR
f065e8
 .SH DESCRIPTION
f065e8
 Tool for testing if a cluster resource is OCF compliant
f065e8
 .SH OPTIONS
f065e8
@@ -26,11 +26,6 @@ Name of the resource
f065e8
 \fB\-o\fR name=value
f065e8
 Name and value of any parameters required by the agent
f065e8
 .TP
f065e8
-\fB\-L\fR
f065e8
-Use lrmadmin/lrmd for tests
f065e8
-.PP
f065e8
-Usage: ocf\-tester [\-Lh] \fB\-n\fR resource_name [\-o name=value]* /full/path/to/resource/agent
f065e8
-.TP
f065e8
 \fB\-h\fR
f065e8
 This text
f065e8
 .TP
f065e8
@@ -51,6 +46,3 @@ Name of the resource
f065e8
 .TP
f065e8
 \fB\-o\fR name=value
f065e8
 Name and value of any parameters required by the agent
f065e8
-.TP
f065e8
-\fB\-L\fR
f065e8
-Use lrmadmin/lrmd for tests
f065e8
diff --git a/tools/ocf-tester.in b/tools/ocf-tester.in
f065e8
index 10822a5a06..15b14e51ea 100755
f065e8
--- a/tools/ocf-tester.in
f065e8
+++ b/tools/ocf-tester.in
f065e8
@@ -25,8 +25,6 @@
f065e8
 # Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
f065e8
 #
f065e8
 
f065e8
-LRMD=@libdir@/heartbeat/lrmd
f065e8
-LRMADMIN=@sbindir@/lrmadmin
f065e8
 DATADIR=@datadir@
f065e8
 METADATA_LINT="xmllint --noout --valid -"
f065e8
 
f065e8
@@ -61,7 +59,6 @@ usage() {
f065e8
     echo "  -X       		Turn on RA tracing (expect large output)"
f065e8
     echo "  -n name		Name of the resource"	
f065e8
     echo "  -o name=value		Name and value of any parameters required by the agent"
f065e8
-    echo "  -L			Use lrmadmin/lrmd for tests"
f065e8
     exit $1
f065e8
 }
f065e8
 
f065e8
@@ -104,7 +101,6 @@ while test "$done" = "0"; do
f065e8
 	-o) name=${2%%=*}; value=${2#*=}; 
f065e8
 		lrm_ra_args="$lrm_ra_args $2";
f065e8
 		ra_args="$ra_args OCF_RESKEY_$name='$value'"; shift; shift;;
f065e8
-	-L) use_lrmd=1; shift;;
f065e8
 	-v) verbose=1; shift;;
f065e8
 	-d) export HA_debug=1; shift;;
f065e8
 	-X) export OCF_TRACE_RA=1; verbose=1; shift;;
f065e8
@@ -140,79 +136,6 @@ stopped_rc=7
f065e8
 has_demote=1
f065e8
 has_promote=1
f065e8
 
f065e8
-start_lrmd() {
f065e8
-	lrmd_timeout=0
f065e8
-	lrmd_interval=0
f065e8
-	lrmd_target_rc=EVERYTIME
f065e8
-	lrmd_started=""
f065e8
-	$LRMD -s 2>/dev/null
f065e8
-	rc=$?
f065e8
-	if [ $rc -eq 3 ]; then
f065e8
-		lrmd_started=1
f065e8
-		$LRMD &
f065e8
-		sleep 1
f065e8
-		$LRMD -s 2>/dev/null
f065e8
-	else
f065e8
-		return $rc
f065e8
-	fi
f065e8
-}
f065e8
-add_resource() {
f065e8
-	$LRMADMIN -A $OCF_RESOURCE_INSTANCE \
f065e8
-		ocf \
f065e8
-		`basename $agent` \
f065e8
-		$(basename `dirname $agent`) \
f065e8
-		$lrm_ra_args > /dev/null
f065e8
-}
f065e8
-del_resource() {
f065e8
-	$LRMADMIN -D $OCF_RESOURCE_INSTANCE
f065e8
-}
f065e8
-parse_lrmadmin_output() {
f065e8
-	awk '
f065e8
-BEGIN{ rc=1; }
f065e8
-/Waiting for lrmd to callback.../ { n=1; next; }
f065e8
-n==1 && /----------------operation--------------/ { n++; next; }
f065e8
-n==2 && /return code:/ { rc=$0; sub("return code: *","",rc); next }
f065e8
-n==2 && /---------------------------------------/ {
f065e8
-        n++;
f065e8
-        next;
f065e8
-}
f065e8
-END{
f065e8
-	if( n!=3 ) exit 1;
f065e8
-	else exit rc;
f065e8
-}
f065e8
-'
f065e8
-}
f065e8
-exec_resource() {
f065e8
-	op="$1"
f065e8
-	args="$2"
f065e8
-	$LRMADMIN -E $OCF_RESOURCE_INSTANCE \
f065e8
-		$op $lrmd_timeout $lrmd_interval \
f065e8
-		$lrmd_target_rc \
f065e8
-		$args | parse_lrmadmin_output
f065e8
-}
f065e8
-
f065e8
-if [ "$use_lrmd" = 1 ]; then
f065e8
-	echo "Using lrmd/lrmadmin for all tests"
f065e8
-	start_lrmd || {
f065e8
-		echo "could not start lrmd" >&2
f065e8
-		exit 1
f065e8
-	}
f065e8
-	trap '
f065e8
-		[ "$lrmd_started" = 1 ] && $LRMD -k
f065e8
-	' EXIT
f065e8
-	add_resource || {
f065e8
-		echo "failed to add resource to lrmd" >&2
f065e8
-		exit 1
f065e8
-	}
f065e8
-fi
f065e8
-
f065e8
-lrm_test_command() {
f065e8
-	action="$1"
f065e8
-	msg="$2"
f065e8
-	debug "$msg"
f065e8
-	exec_resource $action "$lrm_ra_args"
f065e8
-}
f065e8
-
f065e8
 test_permissions() {
f065e8
     action=meta-data
f065e8
     debug ${1:-"Testing permissions with uid nobody"}
f065e8
@@ -233,10 +156,6 @@ test_command() {
f065e8
     action=$1; shift
f065e8
     export __OCF_ACTION=$action
f065e8
     msg=${1:-"Testing: $action"}
f065e8
-    if [ "$use_lrmd" = 1 ]; then
f065e8
-    	lrm_test_command $action "$msg"
f065e8
-    	return $?
f065e8
-    fi
f065e8
     #echo Running: "export $ra_args; $agent $action 2>&1 > /dev/null"
f065e8
     if [ $verbose -eq 0 ]; then
f065e8
 	command_output=`$agent $action 2>&1`