From e5a812082ae033afb1eed82c0f2df3d0f6bdc93f Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 08:53:20 +0200 Subject: Adding upstream version 2.1.6. Signed-off-by: Daniel Baumann --- cts/lab/cts.in | 262 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 262 insertions(+) create mode 100755 cts/lab/cts.in (limited to 'cts/lab/cts.in') diff --git a/cts/lab/cts.in b/cts/lab/cts.in new file mode 100755 index 0000000..5b3aaab --- /dev/null +++ b/cts/lab/cts.in @@ -0,0 +1,262 @@ +#!@BASH_PATH@ +# +# Copyright 2012-2023 the Pacemaker project contributors +# +# The version control history for this file may have further details. +# +# This source code is licensed under the GNU General Public License version 2 +# or later (GPLv2+) WITHOUT ANY WARRANTY. +# + +# e.g. /etc/sysconfig or /etc/default +CONFIG_DIR=@CONFIGDIR@ + +cts_root=`dirname $0` + +logfile=0 +summary=0 +verbose=0 +watch=0 +saved=0 +tests="" + +install=0 +clean=0 +kill=0 +run=0 +boot=0 +setup=0 +target=rhel-7 +cmd="" +trace="" + +custom_log="" +patterns="-e CTS:" + + +helpmsg=$(cat </dev/null +if [ $? != 0 ]; then + echo $0 needs the cluster-helper script to be in your path + exit 1 +fi + +which cluster-clean &>/dev/null +if [ $? != 0 ]; then + echo $0 needs the cluster-clean script to be in your path + exit 1 +fi + +if [ "x$cluster_name" = x ] || [ "x$cluster_name" = xpick ]; then + clusters=`ls -1 ~/.dsh/group/[a-z]+[0-9] | sed s/.*group.// | tr '\n' ' ' ` + + echo "custom) interactively define a cluster" + for i in $clusters; do + echo "$i) `cluster-helper --list short -g $i`" + done + + read -p "Choose a cluster [custom]: " cluster_name + echo +fi + +if [ -z $cluster_name ]; then + cluster_name=custom +fi + + +case $cluster_name in + custom) + read -p "Cluster name: " cluster_name + read -p "Cluster hosts: " cluster_hosts + read -p "Cluster log file: " cluster_log + cluster-helper add -g "$cluster_name" -w "$cluster_hosts" + ;; + *) + cluster_hosts=`cluster-helper --list short -g $cluster_name` + cluster_log=~/cluster-$cluster_name.log; + ;; +esac + +if [ x$cmd != x ]; then + config="${CONFIG_DIR}/pacemaker" + case $cmd in + trace-ls|tls) + cluster-helper -g $cluster_name -- grep PCMK_trace_functions $config + ;; + trace-add|tadd) + echo "Adding $trace to PCMK_trace_functions" + cluster-helper -g $cluster_name -- sed -i "s/.*PCMK_trace_functions=/PCMK_trace_functions=$trace,/" $config + ;; + trace-rm|trm) + echo "Removing $trace from PCMK_trace_functions" + cluster-helper -g $cluster_name -- sed -i "s/.*PCMK_trace_functions=\\\\\\(.*\\\\\\)$trace,\\\\\\(.*\\\\\\)/PCMK_trace_functions=\\\\\\1\\\\\\2/" $config + ;; + trace-set|tset) + echo "Setting PCMK_trace_functions to '$trace'" + cluster-helper -g $cluster_name -- sed -i "s/.*PCMK_trace_functions.*/PCMK_trace_functions=$trace/" $config + ;; + esac + exit 0 +fi + +if [ $run = 1 ]; then + install=1 + clean=1 +fi + +if [ $clean = 1 ]; then + rm -f $cluster_log; cluster-clean -g $cluster_name --kill +elif [ $kill = 1 ]; then + cluster-clean -g $cluster_name --kill-only + exit 0 +fi + +if [ $install = 1 ]; then + cluster-helper -g $cluster_name -- yum install -y pacemaker pacemaker-debuginfo pacemaker-cts libqb libqb-debuginfo +fi + +if [ $setup = 1 ]; then + cluster-init -g $cluster_name $target -u --test + exit 0 + +elif [ $boot = 1 ]; then + $cts_root/CTSlab.py -r -c -g $cluster_name --boot + rc=$? + if [ $rc = 0 ]; then + echo "The cluster is ready..." + fi + exit $rc + +elif [ $run = 1 ]; then + $cts_root/CTSlab.py -r -c -g $cluster_name 500 "$@" + exit $? + +elif [ $clean = 1 ]; then + exit 0 +fi + +screen -ls | grep cts-$cluster_name &>/dev/null +active=$? + +if [ ! -z $custom_log ]; then + cluster_log=$custom_log +fi + +if [ "x$tests" != x ] && [ "x$tests" != "x " ]; then + for t in $tests; do + echo "crm_report --cts-log $cluster_log -d -T $t" + crm_report --cts-log $cluster_log -d -T $t + done + +elif [ $logfile = 1 ]; then + echo $cluster_log + +elif [ $summary = 1 ]; then + files=$cluster_log + if [ $saved = 1 ]; then + files=`ls -1tr ~/CTS-*/cluster-log.txt` + fi + for f in $files; do + echo $f + case $verbose in + 0) cat -n $f | grep $patterns | grep -v "CTS: debug:" + ;; + 1) cat -n $f | grep $patterns | grep -v "CTS:.* cmd:" + ;; + *) cat -n $f | grep $patterns + ;; + esac + echo "" + done + +elif [ $watch = 1 ]; then + case $verbose in + 0) tail -F $cluster_log | grep $patterns | grep -v "CTS: debug:" + ;; + 1) tail -F $cluster_log | grep $patterns | grep -v "CTS:.* cmd:" + ;; + *) tail -F $cluster_log | grep $patterns + ;; + esac + +elif [ $active = 0 ]; then + screen -x cts-$cluster_name + +else + touch $cluster_log + +# . ~/.bashrc + export cluster_name cluster_hosts cluster_log + screen -S cts-$cluster_name bash +fi -- cgit v1.2.3