feat(powerman): add PDU outlet identification + rename scripts [#374]
identify-outlets.sh flashes each outlet sequentially for physical cable
tracing during Friday onsite. rename-outlets.sh takes a mapping file
and rewrites powerman.conf node entries. Both shellcheck-clean.
💘 Generated with Crush
Assisted-by: Crush:glm-5.2
This commit is contained in:
+6
-2
@@ -7,5 +7,9 @@ A commit is blocked while any task below remains unchecked.
|
|||||||
|
|
||||||
(all done — session complete)
|
(all done — session complete)
|
||||||
|
|
||||||
- [x] Validate tsys-siem access (SSHOK + SUDOOK confirmed)
|
- [x] PM housekeeping: 9 tracker corrections, #407 closed, 8 tickets assigned, priorities set, parent-child links
|
||||||
- [x] Update bootstrap-all.sh: no remaining password-auth targets [#403]
|
- [x] Create 6 category milestones (Cat1-6) with due dates
|
||||||
|
- [x] Map all 42 tech tickets to milestones
|
||||||
|
- [x] Close #419 (guest-agent bare-metal skip — already fixed)
|
||||||
|
- [x] Close #392 (etcd tuning — already in install-cp.sh)
|
||||||
|
- [x] Prep PDU identification + rename scripts for Friday onsite [#374]
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
#!/usr/bin/bash
|
||||||
|
# powerman/identify-outlets.sh — flash each PDU outlet sequentially for physical tracing
|
||||||
|
#
|
||||||
|
# Run this from the workstation. It flashes each outlet one at a time so you
|
||||||
|
# can walk the rack and see which device's LED blinks. Write down the mapping,
|
||||||
|
# then run rename-outlets.sh with that mapping.
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
# bash dcinfra/powerman/identify-outlets.sh
|
||||||
|
#
|
||||||
|
# On Friday: run this, walk the rack, note which outlet → which device.
|
||||||
|
set -uo pipefail
|
||||||
|
PROX_HOST="${PROX_HOST:-pfv-tsys1}"
|
||||||
|
REMOTE_SH="$(cd "$(dirname "$0")/../.." && pwd)/tests/remote.sh"
|
||||||
|
|
||||||
|
echo "PDU Outlet Identification — Flash Sequence"
|
||||||
|
echo "============================================"
|
||||||
|
echo "Each outlet will flash for 5 seconds. Walk the rack and note the device."
|
||||||
|
echo "Press Enter to start..."
|
||||||
|
read -r
|
||||||
|
|
||||||
|
for i in $(seq 1 10); do
|
||||||
|
echo "--- Outlet $i: FLASHING (5s) ---"
|
||||||
|
PROX_HOST="$PROX_HOST" bash "$REMOTE_SH" prox "powerman -f outlet-$i" </dev/null 2>/dev/null
|
||||||
|
sleep 5
|
||||||
|
PROX_HOST="$PROX_HOST" bash "$REMOTE_SH" prox "powerman -u outlet-$i" </dev/null 2>/dev/null
|
||||||
|
echo " Outlet $i → ? (write it down)"
|
||||||
|
echo ""
|
||||||
|
[ "$i" -lt 10 ] && { echo "Press Enter for next outlet..."; read -r; }
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "============================================"
|
||||||
|
echo "Done. Now create your mapping file and run:"
|
||||||
|
echo " bash dcinfra/powerman/rename-outlets.sh"
|
||||||
|
echo ""
|
||||||
|
echo "Format: outlet-number:new-name (one per line)"
|
||||||
|
echo "Example:"
|
||||||
|
echo " 1:pfv-tsys1"
|
||||||
|
echo " 2:pfv-tsys3"
|
||||||
|
echo " ..."
|
||||||
|
echo "============================================"
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
#!/usr/bin/bash
|
||||||
|
# powerman/rename-outlets.sh — rename PDU outlets in powerman.conf
|
||||||
|
#
|
||||||
|
# Takes a mapping file (outlet-number:new-name, one per line) and rewrites
|
||||||
|
# the node entries in /etc/powerman/powerman.conf on pfv-tsys1, then
|
||||||
|
# restarts powermand.
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
# bash dcinfra/powerman/rename-outlets.sh <mapping-file>
|
||||||
|
#
|
||||||
|
# Example mapping file:
|
||||||
|
# 1:pfv-tsys1
|
||||||
|
# 2:pfv-tsys3
|
||||||
|
# 3:pfv-tsys4
|
||||||
|
# ...
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
PROX_HOST="${PROX_HOST:-pfv-tsys1}"
|
||||||
|
REMOTE_SH="$(cd "$(dirname "$0")/../.." && pwd)/tests/remote.sh"
|
||||||
|
MAP_FILE="${1:-}"
|
||||||
|
|
||||||
|
if [ -z "$MAP_FILE" ] || [ ! -f "$MAP_FILE" ]; then
|
||||||
|
echo "Usage: $0 <mapping-file>"
|
||||||
|
echo " Format: outlet-number:new-name (one per line)"
|
||||||
|
echo " Run identify-outlets.sh first to get the mapping."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Build the new node lines
|
||||||
|
NODE_LINES=""
|
||||||
|
while IFS=: read -r num name; do
|
||||||
|
[ -z "$num" ] && continue
|
||||||
|
NODE_LINES+="node \"$name\" \"cyclades-pm10\" \"$num\""$'\n'
|
||||||
|
done < "$MAP_FILE"
|
||||||
|
|
||||||
|
# Send to tsys1: backup conf, write new node section, restart powermand
|
||||||
|
PROX_HOST="$PROX_HOST" bash "$REMOTE_SH" prox-file - <<REMOTE_SCRIPT
|
||||||
|
set -euo pipefail
|
||||||
|
cp /etc/powerman/powerman.conf /etc/powerman/powerman.conf.bak.\$(date +%Y%m%d-%H%M%S)
|
||||||
|
|
||||||
|
# Strip existing node lines and append new ones
|
||||||
|
grep -v '^node "outlet-' /etc/powerman/powerman.conf > /tmp/powerman.conf.new
|
||||||
|
cat >> /tmp/powerman.conf.new <<'NODES'
|
||||||
|
$(echo -n "$NODE_LINES")
|
||||||
|
NODES
|
||||||
|
mv /tmp/powerman.conf.new /etc/powerman/powerman.conf
|
||||||
|
systemctl restart powerman
|
||||||
|
sleep 1
|
||||||
|
powerman -l
|
||||||
|
REMOTE_SCRIPT
|
||||||
|
|
||||||
|
echo "PDU outlets renamed. Verify with: PROX_HOST=$PROX_HOST bash $REMOTE_SH prox 'powerman -q'"
|
||||||
Reference in New Issue
Block a user