diff --git a/tools/_util.sh b/tools/_util.sh deleted file mode 100755 index 736666c..0000000 --- a/tools/_util.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/bash - -# Copyright 2023 Hewlett Packard Enterprise Development LP -# Other additional copyright holders may be indicated within. -# -# The entirety of this work is licensed under the Apache License, -# Version 2.0 (the "License"); you may not use this file except -# in compliance with the License. -# -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Retrieve the Physical Device Fabric IDs used to iterate through a list of nvme drives -function getPDFIDs() { - local SWITCH=$1 FUNCTION="${2:-0}" - - switchtec fabric gfms-dump "$SWITCH" | grep "Function $FUNCTION " -A2 | grep PDFID | awk '{print $2}' -} - -function getDriveList() { - # DRIVES=$1 - # for DRIVE in $(ls /dev/nvme* | grep -E "nvme[[:digit:]]+$"); - for DRIVE in /dev/nvme[0-9]*; - do - # shellcheck disable=SC2086 - if [ "$(nvme id-ctrl ${DRIVE} | grep -e KIOXIA -e 'SAMSUNG MZ3LO1T9HCJR')" != "" ]; - then - # SerialNumber=$(nvme id-ctrl ${DRIVE} | grep -E "^sn " | awk '{print $3}') - # Mfg=$(nvme id-ctrl ${DRIVE} | grep -E "^mn " | awk '{print $3}') - # FW=$(nvme id-ctrl ${DRIVE} | grep -E "^fr " | awk '{print $3}') - # printf "%s\t%s\t%s\t%s\n" "$DRIVE" "$Mfg" "$SerialNumber" "$FW" - - DRIVES+=("${DRIVE}") - fi - done - - DriveCount="${#DRIVES[@]}" - if ((DriveCount == 0)); - then - printf "No drives found: Did you run nnf-ec?\n" - fi -} diff --git a/tools/create-write-delete-namespaces.sh b/tools/create-write-delete-namespaces.sh index 559e2e0..94d5925 100755 --- a/tools/create-write-delete-namespaces.sh +++ b/tools/create-write-delete-namespaces.sh @@ -16,6 +16,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +set -euo pipefail DURATION=${1:-"30s"} OP=${2:-"randread"} @@ -48,8 +49,8 @@ shift $((OPTIND - 1)) SIZE=0 DELAY_FOR_DEVICES=2 -printf "duration %s\n" $DURATION -printf "operation %s\n" $OP +printf "duration %s\n" "$DURATION" +printf "operation %s\n" "$OP" # Ensure lvm.conf doesn't get in the way sed -i 's/use_lvmlockd = 1/use_lvmlockd = 0/g' /etc/lvm/lvm.conf diff --git a/tools/devices.sh b/tools/devices.sh deleted file mode 100755 index e3304b4..0000000 --- a/tools/devices.sh +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/bash - -# Copyright 2023 Hewlett Packard Enterprise Development LP -# Other additional copyright holders may be indicated within. -# -# The entirety of this work is licensed under the Apache License, -# Version 2.0 (the "License"); you may not use this file except -# in compliance with the License. -# -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -shopt -s expand_aliases - -# Pull in common utility functions -SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -# shellcheck source="$SCRIPT_DIR"/_util.sh -source "$SCRIPT_DIR"/_util.sh - -usage() { - cat < /dev/null && pwd ) -# shellcheck source="$SCRIPT_DIR"/_util.sh -source "$SCRIPT_DIR"/_util.sh - usage() { cat < $SESSION.log" + $SSHPASS ssh root@"$SYSTEM" "> $SESSION.log" done ;; get-logs) - $SSHPASS scp root@$SYSTEM:~/*.log ./ + $SSHPASS scp root@"$SYSTEM":~/*.log ./ ;; fabdbg-on) for SESSION in "${SESSIONS[@]}" do - $SSHPASS ssh root@$SYSTEM <<-EOF + $SSHPASS ssh root@"$SYSTEM" <<-EOF screen -S $SESSION -X stuff "fabdbg -s info\nfabdbg -s pax\nfabdbg -s gfms\nfabdbg -s hvm\nfabdbg -s sfm\nfabdbg -s fio\nfabdbg -s rule\n" EOF done @@ -113,7 +113,7 @@ EOF fabdbg-off) for SESSION in "${SESSIONS[@]}" do - $SSHPASS ssh root@$SYSTEM <<-EOF + $SSHPASS ssh root@"$SYSTEM" <<-EOF screen -S $SESSION -X stuff "fabdbg -c info\nfabdbg -c pax\nfabdbg -c gfms\nfabdbg -c hvm\nfabdbg -c sfm\nfabdbg -c fio\nfabdbg -c rule\n" EOF done @@ -121,7 +121,7 @@ EOF additional-logs) for SESSION in "${SESSIONS[@]}" do - $SSHPASS ssh root@$SYSTEM <<-EOF + $SSHPASS ssh root@"$SYSTEM" <<-EOF screen -S $SESSION -X stuff "log -t on\nlog -m 0x82 -s3\nlog -m 0x84 -s3\nlog -m 0x82 -s3 -p on\nlog -m 0x84 -s3 -p on\n" EOF done @@ -129,7 +129,7 @@ EOF additional-logs-off) for SESSION in "${SESSIONS[@]}" do - $SSHPASS ssh root@$SYSTEM <<-EOF + $SSHPASS ssh root@"$SYSTEM" <<-EOF screen -S $SESSION -X stuff "log -p off\nlog -m 0x84 -s3 -p off\nlog -m 0x82 -s3 -p off\nlog -m 0x84 -s3 -p off\n" EOF done @@ -137,7 +137,7 @@ EOF slow-drive-logs) for SESSION in "${SESSIONS[@]}" do - $SSHPASS ssh root@$SYSTEM <<-EOF + $SSHPASS ssh root@"$SYSTEM" <<-EOF screen -S $SESSION -X stuff "fabdbg -s pax\nfabdbg -s gfms\nfabdbg -s hvm\nfabdbg -s sfm\nlog -m 0x84 -s 3 -p on -t on\nlog -m 0x82 -s 3 -p on -t on\n" EOF done @@ -145,7 +145,7 @@ EOF switch-hang-logs) for SESSION in "${SESSIONS[@]}" do - $SSHPASS ssh root@$SYSTEM <<-EOF + $SSHPASS ssh root@"$SYSTEM" <<-EOF # screen -S $SESSION -X stuff "fabdbg -s pax\nfabdbg -s gfms\nfabdbg -s hvm\nfabdbg -s sfm\nlog -m 0x84 -s 3 -p on -t on\nlog -m 0x82 -s 3 -p on -t on\n" # New and improved settings based on https://customer-jira.microchip.com/browse/HPECRAY-23 @@ -176,7 +176,7 @@ EOF # > fabdbg -s fio # > fabdbg -s gfms - $SSHPASS ssh root@$SYSTEM <<-EOF + $SSHPASS ssh root@"$SYSTEM" <<-EOF screen -S $SESSION -X stuff "fabdbg -s pax\nfabdbg -s fio\nfabdbg -s gfms\nlog -m 0x81 -s 5\nlog -m 0x81 -s 5 -p on\nlog -m 0x82 -s 5\nlog -m 0x82 -s 5 -p on\nlog -m 0x84 -s 5\nlog -m 0x84 -s 5 -p on\nlog -m 0x54 -s 5\nlog -m 0x54 -s 5 -p on\n" EOF done @@ -191,7 +191,7 @@ EOF # log -m 0x82 -s 3 -p on # fabdbg -s fio # fabdbg -s gfms - $SSHPASS ssh root@$SYSTEM <<-EOF + $SSHPASS ssh root@"$SYSTEM" <<-EOF screen -S $SESSION -X stuff "log -m 0x82 -s 3\nlog -m 0x82 -s 3 -p on\nlog -m 0x84 -s 3\nlog -m 0x84 -s 3 -p on\nfabdbg -s gfms\nfabdbg -c rule" EOF done @@ -211,7 +211,7 @@ EOF # fabdbg -s fio # fabdbg -s gfms - $SSHPASS ssh root@$SYSTEM <<-EOF + $SSHPASS ssh root@"$SYSTEM" <<-EOF screen -S $SESSION -X stuff "fabdbg -s pax\nfabdbg -s fio\nfabdbg -s gfms\nlog -m 0x82 -s 3\nlog -m 0x82 -s 3 -p on\nlog -m 0x53 -s 3\nlog -m 0x53 -s 3 -p on\n" EOF done @@ -230,7 +230,7 @@ EOF # Turn on the logging for all modules # log -p on - $SSHPASS ssh root@$SYSTEM <<-EOF + $SSHPASS ssh root@"$SYSTEM" <<-EOF screen -S $SESSION -X stuff "fabdbg -s pax\nfabdbg -s fio\nfabdbg -s gfms\nlog -m 0x54 -s 3\nlog -m 0x54 -s 3 -p on\nlog -p on\n" EOF done @@ -239,13 +239,13 @@ EOF quit-sessions) for SESSION in "${SESSIONS[@]}" do - $SSHPASS ssh -T root@$SYSTEM "screen -S $SESSION -X quit" + $SSHPASS ssh -T root@"$SYSTEM" "screen -S $SESSION -X quit" done ;; lnkstat) for SESSION in "${SESSIONS[@]}" do - $SSHPASS ssh root@$SYSTEM <<-EOF + $SSHPASS ssh root@"$SYSTEM" <<-EOF screen -S $SESSION -X colon "wrap off^M" && screen -S $SESSION -X stuff "lnkstat\\n" && sleep 1 && diff --git a/tools/switch.sh b/tools/switch.sh index 5900f4a..962de8c 100755 --- a/tools/switch.sh +++ b/tools/switch.sh @@ -16,14 +16,9 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - +set -eo pipefail shopt -s expand_aliases -# Pull in common utility functions -SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -# shellcheck source="$SCRIPT_DIR"/_util.sh -source "$SCRIPT_DIR"/_util.sh - usage() { cat <= 0 && PAX_ID <= 1 )); then - echo "$PAX_ID not in range 0-1" - exit 1 + ret=$? + if [ ! $ret ]; then + echo "Unable to retrieve PAX ID" + exit $ret fi } getPAXTemperature() { local SWITCH_NAME=$1 - # Make sure we can get the PAX ID - if [ ! "$(switchtec temp "$SWITCH_NAME")" ]; then + PAX_TEMPERATURE=$(switchtec temp "$SWITCH_NAME") + ret=$? + if [ ! $ret ]; then echo "Unable to retrieve PAX Temperature" - exit $? + exit $ret fi - - PAX_TEMPERATURE=$(switchtec temp "$SWITCH_NAME") } displayPAX() {