Showing posts with label paths. Show all posts
Showing posts with label paths. Show all posts

Tuesday, June 14, 2011

Drive Matching

While working with a VTL I realized how much I hated matching drive definitions on a LAN-Free client or remote library client and decided to do something about it. So after searching the web and finding a helpful script to pull rmt and serial numbers from the tape drives discovered on the LAN-Free or Lib-Client I worked it into an AIX shell script that will match the drives rmt with the correct drive definition on the library manager. The key to this working is to have the library manager listed in the lib-clients dsm.sys and to define the following TSM script on the library manager.


-=-=-=-=-=-=-TSM Server Script-=-=-=-=-=-=-=-


def script drive_match desc="This script is used by a shell script to match drives to rmts to help create DEFINE PATH statements"
upd script drive_match "select 'define path $1 ' || drive_name || ' srct=server destt=drive libr=' || library_name || ' device=/dev/$2 -"
upd script drive_match " online=yes' from drives where DRIVE_SERIAL='$3' "


-=-=-=-=-=-=-UNIX Shell Script-=-=-=-=-=-=-=-


#!/bin/ksh
ID=`cat /home/tsmadmin/VARS/ADSMID`
PA=`cat /home/tsmadmin/VARS/ADSMPA`
touch ./drv_match.mac
cat /dev/null > ./drv_match.mac
clear
echo "This script will build the DEFINE PATH statements for a server"
echo ""
echo "Enter the Library Manager Name: \c"
read SERV
echo ""
echo "What is the TSM server name these paths are going to be generated for: \c"
read TSMSRV
echo ""
lsdev |grep fscsi | while read FSCS rest
 do
   TAPES=$(lsdev -p $FSCS | grep rmt | grep -v ALT |cut -f1 -d" ")
     for TAPE in $TAPES
       do
         SERIAL=$(lscfg -vl $TAPE | grep Serial | awk -F"." '{printf "%d", $NF}')
         FCS=$(echo $FSCS | sed 's/fscsi/fcs/')
         dsmadmc -id=$ID -pa=$PA -dataonly=yes -commadelimited -servern=$SERV run drive_match $TSMSRV $TAPE $SERIAL | grep -v ANR >> ./drv_match.mac
        done
 done
cat ./drv_match.mac


-=-=-=-=-End Script-=-=-=-=-=-

You'll notice I save the output as a macro so it can be reviewed before executed. If you'd like to run the macro automatically then just add a dsmadmc line at the end.

The following is some sample output:


define path tsm8 VTL3_00332 srct=server destt=drive libr=VTL3 device=/dev/rmt88 online=yes
define path tsm8 VTL3_00336 srct=server destt=drive libr=VTL3 device=/dev/rmt89 online=yes
define path tsm8 VTL3_00340 srct=server destt=drive libr=VTL3 device=/dev/rmt90 online=yes
define path tsm8 VTL4_00444 srct=server destt=drive libr=VTL4 device=/dev/rmt91 online=yes