5.19.2006

[Work] Its 8pm on a Friday and...

I'm at work. Singing the on call blues. The Netbackup environment post-switch firmware update. On a reconfiguration reboot of a media manager the tapes reassigned themselves to new /dev/rmt/X assignments, which I guess is not unexpected as we are using the dynamic qlogic drivers. The version of Netbackup we are using likes to know that tape drive /dev/rmt/Xcbn is a certain assignment, so me (and a co-worker) are re-doing the links. After a few hours of detective work I have whipped up a script to match the physical device assignment to the correct /dev/rmt/X* link. Here is my script:

#!/bin/ksh -x

# mk-tape_links.sh ##
#
#
###

###
# variables
###
TAPEOPTS="b bn c cb cbn cn h hb hbn hn l lb lbn ln m mb mbn mn n u ub ubn un"
TAPEDIR=/dev/rmt
TAPES=/var/tmp/tape-nums.txt
TAPEDRVS="0 1 2 3 4 5 6 7 8 9 10 11 12"
PATH=/usr/bin:/usr/sbin

export PATH TAPEOPTS TAPEDIR HATAPEDRVS

# for links to work correctly, must be in /dev/rmt
cd ${TAPEDIR}

# loop through all the tape drives to be defined
# the numbers correspond to /dev/rmt/X* links.
for x in ${TAPEDRVS}
do
# pull the drive physical path out of definition file
DEVICE=`/usr/bin/grep "^${x} " ${TAPES} | /usr/bin/awk '{print $2}'`
export DEVICE
/usr/bin/ln -s ${DEVICE}: ${x}
# loop through and create all the options
for y in ${TAPEOPTS}
do
/usr/bin/ln -s ${DEVICE}:${y} ${x}${y}
done
done


/var/tmp/tapes-num.txt is formated like this:

0 ../../devices/pci@23d,700000/SUNW,qlc@1,1/fp@0,0/st@w500104f000771e2a,0
1 ../../devices/pci@23d,700000/SUNW,qlc@1,1/fp@0,0/st@w500104f000771d4c,0
2 ../../devices/pci@23d,700000/SUNW,qlc@1,1/fp@0,0/st@w500104f000771e45,0
...



Probably an easier way to do it, but it works and is recreateable as I feel this will happen again.

No comments: