diff --git a/tools/switch.sh b/tools/switch.sh index 5b53a5b..2eefba4 100755 --- a/tools/switch.sh +++ b/tools/switch.sh @@ -132,6 +132,18 @@ getPAXTemperature() { PAX_TEMPERATURE=$(switchtec temp "$SWITCH_NAME") } +displayPAX() { + local SWITCH_NAME=$1 + getPAXID "$SWITCH_NAME" + + if [ "$VERBOSE" == "true" ]; then + getPAXTemperature "$SWITCH_NAME" + printf "DEVICE: %s PAX_ID: %d TEMP: %s\n\n" "$SWITCH_NAME" "$PAX_ID" "$PAX_TEMPERATURE" + else + printf "DEVICE: %s PAX_ID: %d\n\n" "$SWITCH_NAME" "$PAX_ID" + fi +} + setDeviceName() { DRIVES=() getDriveList @@ -174,16 +186,16 @@ displayDriveSlotStatus() { [48]=3 ) - getPAXID "$SWITCH_NAME" + # getPAXID "$SWITCH_NAME" # Associate serial number with its /dev/nvme device setDeviceName # Grab the attach status of each physical port mapfile -t physicalPortStatus < <(switchtec fabric gfms-dump "$SWITCH" | grep " Physical Port ID") + # displayPAX local physicalPortString - printf "DEVICE: %s PAX_ID: %d\n\n" "$SWITCH_NAME" "$PAX_ID" for physicalPortString in "${physicalPortStatus[@]}"; do local PHYSICAL_PORT_ID @@ -285,17 +297,12 @@ displayStatus() { [46]="Compute 15, ${CHASSIS}s7b1n0" ) - getPAXID "$SWITCH_NAME" + # getPAXID "$SWITCH_NAME" mapfile -t physicalPortIdStrings < <(switchtec status "$SWITCH_NAME" | grep "Phys Port ID:") + # displayPAX local physicalPortString - if [ "$VERBOSE" == "true" ]; then - getPAXTemperature "$SWITCH_NAME" - printf "DEVICE: %s PAX_ID: %d TEMP: %s\n\n" "$SWITCH_NAME" "$PAX_ID" "$PAX_TEMPERATURE" - else - printf "DEVICE: %s PAX_ID: %d\n\n" "$SWITCH_NAME" "$PAX_ID" - fi printf "Switch Connection \tStatus\n" printf "===========================\t======\n" for physicalPortString in "${physicalPortIdStrings[@]}"; @@ -369,7 +376,7 @@ case $1 in slot-info) function slot-info() { local SWITCH=$1 - echo "Execute slot-info on $SWITCH" + displayPAX "$SWITCH" TIME displayDriveSlotStatus "$SWITCH" } execute slot-info @@ -377,7 +384,7 @@ case $1 in info) function info() { local SWITCH=$1 - echo "Execute switch info on $SWITCH" + displayPAX "$SWITCH" TIME switchtec info "$SWITCH" } execute info @@ -385,7 +392,8 @@ case $1 in status) function status() { local SWITCH=$1 - echo "Execute switch status on $SWITCH" + # echo "Execute switch status on $SWITCH" + displayPAX "$SWITCH" TIME displayStatus "$SWITCH" } execute status @@ -393,7 +401,8 @@ case $1 in switchtec-status) function switchtec-status() { local SWITCH=$1 - echo "Execute switchtec status on $SWITCH" + # echo "Execute switchtec status on $SWITCH" + displayPAX "$SWITCH" TIME switchtec status "$SWITCH" } execute switchtec-status @@ -401,6 +410,7 @@ case $1 in ep-tunnel-status) function ep-tunnel-status() { local SWITCH=$1 + displayPAX "$SWITCH" ep-tunnel-command "$SWITCH" "status" } execute ep-tunnel-status @@ -408,6 +418,7 @@ case $1 in ep-tunnel-enable) function ep-tunnel-enable() { local SWITCH=$1 + displayPAX "$SWITCH" ep-tunnel-command "$SWITCH" "enable" } execute ep-tunnel-enable @@ -415,6 +426,7 @@ case $1 in ep-tunnel-disable) function ep-tunnel-disable() { local SWITCH=$1 + displayPAX "$SWITCH" ep-tunnel-command "$SWITCH" "disable" } execute ep-tunnel-disable @@ -422,7 +434,8 @@ case $1 in fabric) function fabric() { local SWITCH=$1 FABRIC_CMD=$2 ARGS=( "${@:3}" ) - echo "Execute switch fabric $FABRIC_CMD on $SWITCH" + if [ "$VERBOSE" == "true" ]; then echo "Execute switch fabric $FABRIC_CMD"; fi + displayPAX "$SWITCH" TIME switchtec fabric "$FABRIC_CMD" "$SWITCH" "${ARGS[@]}" } execute fabric "${2:-gfms-dump}" "${@:3}" @@ -430,7 +443,7 @@ case $1 in cmd) function cmd() { local SWITCH=$1 CMD=$2 ARGS=( "${@:3}" ) - echo "Execute on $SWITCH $CMD" "${ARGS[@]}" + displayPAX "$SWITCH" TIME switchtec "$CMD" "$SWITCH" "${ARGS[@]}" } execute cmd "${@:2}"