Skip to content

Commit

Permalink
Add device and PAX ID info to all commands and support a VERBOSE option
Browse files Browse the repository at this point in the history
Signed-off-by: Anthony Floeder <[email protected]>
  • Loading branch information
ajfloeder committed Dec 4, 2024
1 parent 14ec4a1 commit 5851fad
Showing 1 changed file with 28 additions and 15 deletions.
43 changes: 28 additions & 15 deletions tools/switch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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[@]}";
Expand Down Expand Up @@ -369,68 +376,74 @@ 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
;;
info)
function info() {
local SWITCH=$1
echo "Execute switch info on $SWITCH"
displayPAX "$SWITCH"
TIME switchtec info "$SWITCH"
}
execute info
;;
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
;;
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
;;
ep-tunnel-status)
function ep-tunnel-status() {
local SWITCH=$1
displayPAX "$SWITCH"
ep-tunnel-command "$SWITCH" "status"
}
execute ep-tunnel-status
;;
ep-tunnel-enable)
function ep-tunnel-enable() {
local SWITCH=$1
displayPAX "$SWITCH"
ep-tunnel-command "$SWITCH" "enable"
}
execute ep-tunnel-enable
;;
ep-tunnel-disable)
function ep-tunnel-disable() {
local SWITCH=$1
displayPAX "$SWITCH"
ep-tunnel-command "$SWITCH" "disable"
}
execute ep-tunnel-disable
;;
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}"
;;
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}"
Expand Down

0 comments on commit 5851fad

Please sign in to comment.