tapes have blank EVSN - Veritas Net Backup

This is a discussion on tapes have blank EVSN - Veritas Net Backup ; I am having problems with 4 tapes that were previously used. They all have a blank EVSN and an RVSN that is currently used by another tape. How can I erase these tapes or the labels for the tapes? Also, ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: tapes have blank EVSN

  1. tapes have blank EVSN

    I am having problems with 4 tapes that were previously used. They all have
    a blank EVSN and an RVSN that is currently used by another tape. How can I
    erase these tapes or the labels for the tapes? Also, how can I find the
    mediaID or barCode just by reading what is in the drive?

    ------------------------------------

    Jeremy Aldrich
    Data Technology Services, Inc.
    10920 W Alameda Ave
    Lakewood, CO 80226
    (303)989-1446 x123
    www.DTSiNETadvantage.com
    www.dtsisoftware.com




  2. Re: tapes have blank EVSN

    1) ./bplabel -h ( relabelisation of media )
    2) reading the rvsn and evsn of media
    read long time ago about a great script :


    #!/bin/ksh
    # set -x -v
    #
    #
    ################################################## ####################
    # Invocation By Operator from Command Line
    #
    # Inputs None
    #
    # Termination =20
    #
    ################################################## ####################

    ################################################## ####################
    #
    # Pseudo code description of program execution
    #=20
    # 1. Set up globals; define functions
    # 2. Check environment
    # 3. Get list of available robots (robid[] robpath[] robtype[])
    # 4. Loop over robots
    # 5. Get old labels from volume db (oldslots[] oldlabels[])
    # 6. Move old labels out of volume db
    # 7. Get currently occupied slots (newslots[])
    # 8. Add dummy media ids to volume db (dummylabels[])
    # 9. Loop over occupied slots
    # 10. Get real labels from tapes (newlabels[])
    # 11. Delete dummy media ids
    # 12. End loop over slots
    # 13. Confirm desire to make changes
    # 14. Move real labels into robot in volume db
    # 15. End loop over robots
    #
    ################################################## ####################

    ################################################## ####################
    # 1. Set up Globals; define functions
    ################################################## ####################

    ################################################## ####################
    # Global constants
    ################################################## ####################

    # Set TESTING to "true" if you want debug info printed

    TESTING=3D"true"

    SCRIPTNAME=3D`basename $0`
    DATESTAMP=3D`date '+%y%m%d_%H:%M:%S'`
    PROCID=3D$$

    NBHOME=3D/usr/openv/netbackup/bin
    VMHOME=3D/usr/openv/volmgr/bin

    TMP1=3D/tmp/$SCRIPTNAME.$PROCID.1
    TMP2=3D/tmp/$SCRIPTNAME.$PROCID.2

    TMPFILES=3D"$TMP1 $TMP2"

    LOGMESSAGES=3D"true"
    LOGTOSTDOUT=3D"true"
    LOGTOFILE=3D"true"

    LOGDIR=3D/tmp
    LOGFILE=3D$LOGDIR/$SCRIPTNAME.$DATESTAMP.log
    CRONLOG=3D$LOGDIR/$SCRIPTNAME.$DATESTAMP.cron.log

    # Volume Group name must be 10 chars or less.
    # 1234567890
    NONROBOTICVG=3D"Moved_Out"

    MASTERSERVER=3D""

    ################################################## ####################
    # Global variables
    ################################################## ####################

    maxrobots=3D0
    robid[$maxrobots]=3D0
    robtype[$maxrobots]=3D""
    robpath[$maxrobots]=3D""
    robvdh[$maxrobots]=3D""
    robdens[$maxrobots]=3D""

    maxslots=3D0

    oldcarts=3D0
    oldlabels[$oldcarts]=3D""
    oldslots[$oldcarts]=3D""
    oldmedia[$oldcarts]=3D""

    filledslots=3D0
    newslots[$filledslots]=3D""
    newlabels[$filledslots]=3D""
    newwriteable[$filledslots]=3D""
    newmediatype[$filledslots]=3D""

    maxdummy=3D0
    fakelabel[$maxdummy]=3D""

    ################################################## ####################
    # Function declarations
    ################################################## ####################

    # ensure that we clean up after ourselves nicely.
    trap 'CleanUp' 0
    trap 'Fatal 998 "Stopped by signal" trap routine' 1 2 3 15=20

    CheckEnv()
    {
    # Check environment we're running in.
    #
    # Globals: NBHOME=20
    # =20
    # Inputs: None
    #
    # Outputs: None

    # set -x -v

    gotparms=3D"false"
    TESTING=3D"false"

    while [ $# -gt 0 ]
    do
    case "$1" in
    "-cron")
    if [ "$gotparms" !=3D "false" ]
    then
    # Already got the -term argument so error
    Usage
    Fatal 900 "Incorrect parameters!" CheckEnv
    fi

    # Redirect /dev/null to StdIn so we need no input
    exec 0
    # Redirect StdOut & StdErr to the cron logfile so we=20
    # generate no output.
    exec 1>$CRONLOG
    exec 2>$CRONLOG

    LOGTOSTDOUT=3D"false"
    =20
    gotparms=3D"true";;

    "-term")
    if [ "$gotparms" !=3D "false" ]
    then
    # Already got the -cron argument so error
    Usage
    Fatal 900 "Incorrect parameters!" CheckEnv
    fi

    LOGTOSTDOUT=3D"true"

    gotparms=3D"true";;

    "-test")
    TESTING=3D"true";;

    "-?")
    Usage
    exit 1;;
    *)
    Usage
    Fatal 900 "Incorrect parameters!" CheckEnv;;
    esac=20
    shift
    done

    if [ "$gotparms" !=3D "true" ]
    then
    Usage
    Fatal 975 "Not enough parameters!" CheckEnv
    fi

    if ! CheckRoot
    then
    Fatal 1 'You must be root to run this script.' 'CheckEnv'
    fi

    SetupTmpLog

    CheckIfMasterServer

    ##### Check we can find the admincmd directory #####
    if [ ! -d $NBHOME/admincmd ] ; then
    Fatal 101 "Cannot find NetBackup's admin directory =
    ($NBHOME/admincmd)" CheckEnv
    fi

    ##### Check we can access the admin commands #####
    if [ ! -x $NBHOME/admincmd/bpcllist ] ; then
    Fatal 101 "Cannot execute NetBackup admin commands (i.e. =
    bpcllist)" CheckEnv
    fi

    ps -e | awk '{print $NF}' > $TMP1
    =20
    ##### Check NetBackup processes are running #####

    if [[ ""$MASTERSERVER =3D "" ]]
    then
    if grep bprd $TMP1 >/dev/null ; then
    if ! grep bpdbm $TMP1 >/dev/null ; then
    Fatal 101 "NetBackup process (bpdbm) not found" CheckEnv
    fi
    else
    Fatal 101 "NetBackup process (bprd) not found" CheckEnv
    fi
    fi
    =20
    #### Check Volume Manager processes are running #####
    if grep avrd $TMP1 >/dev/null ; then
    if grep ltid $TMP1 >/dev/null ; then
    if ! grep vmd $TMP1 >/dev/null ; then
    Fatal 101 "Volume Manager process \"vmd\" not found" =
    "CheckEnv"
    fi
    else
    Fatal 101 "Volume Manager process \"ltid\" not found" =
    "CheckEnv"
    fi
    else
    Fatal 101 "Volume Manager process \"avrd\" not found" "CheckEnv"
    fi

    return
    }

    Message()
    {
    # Print message to stdout and/or log file
    #
    # Globals: LOGMESSAGES, LOGTOFILE, LOGTOSTDOUT, LOGFILE
    # =20
    # Inputs: 1 - Message to print to screen / log / both / neither
    #
    # Outputs: 1 - echo to screen / log / both / neither

    if [[ ""$LOGMESSAGES =3D "true" ]]
    then
    if [[ ""$LOGTOFILE =3D "true" ]]
    then
    echo "$1" >> $LOGFILE
    fi
    if [[ ""$LOGTOSTDOUT =3D "true" ]]
    then
    echo "$1" >&3
    fi
    fi
    }

    Fatal()
    {
    # Function to handle unexpected exit conditions in the script
    # Print error condition, then clean up.
    #
    # Globals: None
    # =20
    # Inputs: 1 - Error code
    # 2 - Error Message
    # 3 - Function that generated the error
    #
    # Outputs: None

    if [[ ""$1 !=3D "" ]]
    then
    errcode=3D$1
    else
    errcode=3D"???"
    fi

    if [[ ""$2 !=3D "" ]]
    then
    message=3D$2
    else
    message=3D"Error description not specified"
    fi

    if [[ ""$3 !=3D "" ]]
    then
    source=3D$3
    else
    source=3D"Function that caused the error was not specified"
    fi

    Message "*** FATAL ERROR: $errcode in $source"
    Message "$message"

    CleanUp

    exit $1
    }

    CleanUp()
    {
    # Tidy up before exiting script
    #
    # Globals: TMPFILES, NBHOME
    #
    # Inputs: None
    #
    # Outputs: None

    rm $TMPFILES >/dev/null 2>&1

    if [[ ""$MASTERSERVER =3D "" ]]
    then
    $NBHOME/initbprd
    fi
    }

    Usage()
    {
    # Print usage message - exit
    #
    # Globals: SCRIPTNAME
    # =20
    # Inputs: None
    #
    # Outputs: 1 - Usage message for display

    Message "USAGE: $SCRIPTNAME -term|-cron [-test]"
    Message " This script checks the header information for tapes =
    in"
    Message " locally attached robotic tape devices."
    Message " -term : Running on a tty terminal - can use =
    stdin/stdout/stderr"
    Message " -cron : No tty attached - do not use =
    stdin/stdout/stderr"
    Message " -test : Testing - show additional debug output"
    }

    CheckRoot()
    {
    # Check that we're running this script as root
    #
    # Globals: None
    # =20
    # Inputs: None
    #
    # Outputs: 1 - return code ( 0 - running as root; 1 - NOT running as =
    root )

    if [ "`whoami`" !=3D "root" ]
    then
    return 1
    fi
    return 0
    }

    SetupTmpLog()
    {
    # Setup tmp and log files. Delete any > 1 week old
    #
    # Globals: SCRIPTNAME, TMPFILES, LOGDIR, LOGFILE, LOGTOFILE=20
    # =20
    # Inputs: None
    #
    # Outputs: Initialised (and cleaned) log files & tmp files

    for file in $TMPFILES $LOGFILE
    do
    if [ -f $file ]
    then
    rm $file >/dev/null 2>&1
    if [[ $? !=3D 0 ]]
    then
    CleanUp
    LOGTOFILE=3D"FALSE"
    Fatal 999 "Cannot remove file $file" SetupTmpLog
    fi
    fi
    =20
    cat /dev/null > $file >/dev/null 2>&1
    if [[ $? !=3D 0 ]]
    then
    CleanUp
    LOGTOFILE=3D"FALSE"
    Fatal 999 "Cannot create file $file" SetupTmpLog
    fi
    done

    Message "Log of $SCRIPTNAME started at `date`"

    find $LOGDIR -name "$SCRIPTNAME.log.*" -mtime +7 -exec ls {} \; > =
    $TMP1
    while read file
    do
    rm $file >/dev/null 2>&1
    if [[ $? !=3D 0 ]]
    then
    Message "*** Warning *** Could not delete old log file =
    $LOGDIR/$file."
    fi
    done <$TMP1

    return
    }

    CheckIfMasterServer()
    {
    # set -x -v
    # Check if this is the master server for the cluster
    #
    # Globals: NBHOME=20
    # =20
    # Inputs: None
    #
    # Outputs: None
    master=3D`head -1 $NBHOME/../bp.conf | awk '{print $NF}'`
    thismc=3D`uname -n`.`domainname`

    if [[ ""$thismc =3D ""$master ]]
    then
    MASTERSERVER=3D""
    else
    MASTERSERVER=3D$master
    fi

    if [[ ""$TESTING =3D "true" ]]
    then
    Message "\nMaster Server is: $master"
    fi

    }


    CheckNoJobsActive()
    {
    # Ensure we're not interfering / that we're not interfered with
    #
    # Globals: NBHOME
    # =20
    # Inputs: None
    #
    # Outputs: None

    ActiveProcess=3Dbptm

    ps -e | grep $ActiveProcess >/dev/null 2>&1
    if [ $? =3D 0 ];then
    Fatal 200 "Tapes cannot be loaded when jobs are running" =
    CheckNoJobsActive
    fi

    # We stop bprd if we're the master server, so we need to ensure=20
    # that the bprd daemon is restarted when we exit (in *ALL* cases!)
    if [[ ""$MASTERSERVER =3D "" ]]
    then
    $NBHOME/admincmd/bprdreq -terminate
    fi

    return
    }

    SelectDensity()
    {
    # Detect (or choose) media density
    #
    # Note different argument to tpconfig (-data)
    # The idea is to pass the robot number we care about (rn).
    #
    # When the robot is found, read the drive lines until
    # you hit a non-robotic drive or another robot. ($5=3D"-")
    #
    # Output the drive density ($4)

    # set -x -v=20

    Index=3D$1
    RobotNumber=3D${robid[$Index]}

    $VMHOME/tpconfig -data | nawk -v rn=3D$RobotNumber '
    {
    if ( $2 =3D=3D rn )
    {
    getline
    while ( $5 !=3D "-" && $5 !=3D "" )
    {
    print $4
    getline
    }
    }
    }' | sort -u > $TMP2

    # How many densities are there in this robot?
    # (Can't use wc -l as that includes the filename)
    choices=3D$((0 + `cat $TMP2 | wc -l`))

    case $choices in
    0)
    Message "Robot number $RobotNumber has no drives configured!"
    return 1;;
    1)
    robdens[$Index]=3D`cat $TMP2`;;
    *)
    # We should never have a non-barcode scanning robot with multiple
    # media densities, but I'm a cautious man...

    if [[ ""$LOGTOSTDOUT =3D "true" ]]
    then
    Message "\nRobot number $RobotNumber has the following drive densities =
    available:"
    maxchoices=3D0;
    cat $TMP2 | while read dens
    do
    maxchoices=3D$((maxchoices + 1));
    Message " $maxchoices: $dens";
    densities[$maxchoices]=3D$dens;
    done;
    Message "\n Please select the density of tapes you wish to inventory =
    (1 - $maxchoices)";
    selected=3D"false";

    while [[ ""$selected =3D "false" ]]
    do
    read selection <&4 ;
    if [ "$selection" -ge 1 ] && [ "$selection" -le $maxchoices ]
    then
    robdens[$Index]=3D${densities[$selection]};
    selected=3D"true"
    else
    Message "Invalid selection. Please enter a number between 1 and =
    $maxchoices."
    fi
    done
    else
    # We're running without a console - so just pick the first one.
    robdens[$Index]=3D`cat $TMP2 | head -1`
    fi;;
    esac
    return 0
    }

    CheckRobotHasNoBarcodeReader()
    {
    # Check whether this robot can sense barcodes
    #
    # Globals: VMHOME
    # =20
    # Inputs: 1 - Robot Number
    # 2 - Robot Type
    #
    # Outputs: 0 - Robot cannot sense barcodes
    # 1 - Robot can sense barcodes

    # set -x -v=20

    RobotNumber=3D$1
    RobotType=3D$2

    case $RobotType in
    tld)
    scsicmd=3Dtldtest;;
    tsd)
    scsicmd=3Dtsdtest;;
    tl8)=20
    scsicmd=3Dtl8test;;
    ts8)
    scsicmd=3Dts8test;;
    acs | odl | tc4 | tc8 | tl4 | tlh | tlm | tsh)=20
    Message "WARNING: Skipping robot $RobotNumber: Script doesn't =
    understand robot type $RobotType";
    return 1;;
    *) ;; =20
    esac

    # We MUST include the blank lines in the here document, as the =
    command pauses
    # after 11 slots and requires a to continue.
    # DON'T delete the blank lines in the here doc below!

    $VMHOME/${scsicmd} -r ${robpath} > $TMP1 2>&1 <<-!EOD
    s s
















    q
    !EOD
    # DON'T delete the blank lines in the here doc above!

    if egrep -i 'Sense Key:.*5h' $TMP1 > /dev/null 2>&1
    then=20
    Message "WARNING: Cannot connect to $RobotNumber (Wrong Device ?)"
    return 1
    elif egrep -i 'Sense Key:.*3h' $TMP1 > /dev/null 2>&1
    then
    Message "WARNING: Cannot connect to $RobotNumber (Robot not ready =
    ?)"
    return 1
    elif egrep -i 'barcode' $TMP1 > /dev/null 2>&1
    then
    Message "WARNING: Skipping robot $RobotNumber: it can read =
    barcodes."
    return 1
    else
    return 0
    fi
    }

    GetAvailableRobotInfo()
    {
    # Get information about locally controlled robotic devices.
    #
    # Globals: VMHOME, NBHOME
    # =20
    # Inputs: None
    #
    # Outputs: robid[] robpath[] robtype[] maxrobots

    # set -x -v=20

    maxrobots=3D0

    $VMHOME/tpconfig -d | awk 'BEGIN =
    {robid=3D"x";robpath=3D"x";robvdh=3D"x"}
    /robotic path/ {
    robotid=3D$1;
    robotpath=3D$5;
    robotvdh=3D$NF;
    if (robotid !=3D "x" && robotpath !=3D "x" && robotvdh !=3D =
    "x")
    {
    print robotid, robotpath, robotvdh;
    robid=3D"x";robpath=3D"x";robvdh=3D"x";
    }
    }
    ' | sort | while read robotid robotpath rvdh
    do
    # robotid is of the form xxx(yy) where xxx is the robot type=20
    # and yy is the robot number. We slice & dice below.

    # Strip closing bracket ')'
    tm=3D${robotid%\)}
    =20
    # Robot number is anything after the open bracket '('
    rn=3D${tm#*\(}

    # Robot type is anything before the open bracket '('
    # We convert to lower case to save work later.
    rt=3D`echo ${tm%\(*} | tr '[A-Z]' '[a-z]'`

    # Strip trailing comma from the robotic path
    rp=3D${robotpath%,}

    # If the robotic path starts with /, it's a local robotic
    # so we care, else forget about it.
    if echo $robotpath | grep '^/' >/dev/null ; then
    robid[$maxrobots]=3D$rn
    robtype[$maxrobots]=3D$rt
    robpath[$maxrobots]=3D$rp
    robvdh[$maxrobots]=3D$rvdh
    CheckRobotHasNoBarcodeReader $rn $rt
    if [ $? =3D 0 ]
    then
    SelectDensity $maxrobots
    if [ $? =3D 0 ]
    then
    maxrobots=3D$((maxrobots + 1))
    fi
    fi
    fi
    done > $TMP1
    =20
    if [[ $maxrobots =3D 0 ]]
    then
    Fatal 123 "No suitable robotic devices found." =
    GetAvailableRobotInfo
    else
    Message "\nCollected Robotic information:"
    i=3D0
    while [[ $i -lt $maxrobots ]]
    do
    Message " Robot ID: ${robid[$i]}"
    Message " Robot Type: ${robtype[$i]}"
    Message " Robot Path: ${robpath[$i]}"
    Message " Vol DB host: ${robvdh[$i]}"
    Message "Media Density: ${robdens[$i]}"
    Message ""
    i=3D$((i + 1))
    done
    fi

    return
    }

    GetSlotsWithTapes()
    {
    # set -x -v
    # Get the filled slot list from the active robot
    #
    # Globals: NONE
    # =20
    # Inputs: 1 - Robot number
    # 2 - Robot type
    #
    # Outputs:=20

    RobotNumber=3D$1=20
    RobotType=3D$2=20

    case $RobotType in
    tld)
    scsicmd=3Dtldtest;;
    tsd)
    scsicmd=3Dtsdtest;;
    tl8)=20
    scsicmd=3Dtl8test;;
    ts8)
    scsicmd=3Dts8test;;
    acs | odl | tc4 | tc8 | tl4 | tlh | tlm | tsh)=20
    Fatal 995 "This script cannot handle robots of type =
    ${robtype[$RobotNumber]}" GetSlotsWithTapes;;
    *) ;; =20
    esac

    # We MUST include the blank lines in the here document, as the =
    command pauses
    # after 11 slots and requires a to continue.
    # DON'T delete the blank lines in the here doc below!

    $VMHOME/${scsicmd} -r ${robpath} 2>&1 > $TMP1 <<-!EOD
    s s
















    q
    !EOD
    # DON'T delete the blank lines in the here doc above!

    # Probably don't need to check for Sense Key errors as we did that
    # earlier. Better safe than sorry!

    if egrep -i 'Sense Key:.*5h' $TMP1 >/dev/null 2>&1
    then=20
    Fatal 993 "Cannot Connect to Robot (Wrong Device ?)" =
    GetSlotsWithTapes
    elif egrep -i 'Sense Key:.*3h' $TMP1 >/dev/null 2>&1
    then=20
    Fatal 993 "Cannot Connect to Robot (Robot not ready?)" =
    GetSlotsWithTapes
    fi

    maxslots=3D0
    filledslots=3D0
    cat $TMP1 | tr '[A-Z]' '[a-z]' | grep =3D | awk '
    /^slot/ { print $2" "$NF }' | while read newslots[$maxslots] =
    hascart
    do
    if [[ ""$hascart =3D "yes" ]]
    then
    # Should check whether there's a slot reserved for cleaning tape
    # otherwise we'll clean this drive a lot!
    newlabels[$maxslots]=3D"+HasTape+"
    filledslots=3D$((filledslots + 1 ))
    else
    newlabels[$maxslots]=3D"+Empty+"
    fi
    maxslots=3D$((maxslots + 1))
    done

    if [[ ""$TESTING =3D "true" ]]
    then
    Message "\nListing filled and empty slots in robot"
    i=3D0
    while [[ $i -lt $maxslots ]]
    do
    Message "Index $i: Slot ID: ${newslots[$i]} Status : =
    ${newlabels[$i]}"
    i=3D$((i + 1))
    done
    Message "Max slots in robot =3D $maxslots"
    fi

    return
    }

    GetMediaInRobotFromVMDB()
    {
    # Get any Media that's supposed to be in the active robot
    #
    # Globals: VMHOME
    # =20
    # Inputs: 1 - Robot number
    #
    # Outputs: oldlabels[] oldcarts[] maxslots

    RobotNumber=3D$1

    if [[ ""$MASTERSERVER =3D "" ]]
    then
    $VMHOME/vmquery -rn $RobotNumber -b >$TMP1 2>/dev/null
    else
    $VMHOME/vmquery -rn $RobotNumber -b -M $MASTERSERVER >$TMP1 =
    2>/dev/null
    fi

    oldcarts=3D0
    cat $TMP1 | nawk -v rn=3D$RobotNumber '
    {=20
    if ( $4 =3D=3D rn ) { print $5 " " $1 " " $2 }=20
    }' | while read slot mediaid mtype
    do
    oldslots[$oldcarts]=3D$slot
    oldlabels[$oldcarts]=3D$mediaid
    oldmedia[$oldcarts]=3D`echo $mtype | tr '[A-Z]' '[a-z]'`
    oldcarts=3D$((oldcarts + 1))
    done

    if [[ ""$TESTING =3D "true" ]]
    then
    Message "\nExisting entries in volume database for this robot"
    i=3D0
    while [[ $i -lt $oldcarts ]]
    do
    Message "Index $i: Slot ID: ${oldslots[$i]} Status : =
    ${oldlabels[$i]} Media: ${oldmedia[$i]}"
    i=3D$((i + 1))
    done
    Message "No. of old filled slots =3D $oldcarts"
    fi

    return
    }

    MoveMediaFromRobot()
    {
    # Move media out of this robot in the VMDB
    #
    # Globals: VMHOME, NONROBOTICVG
    # =20
    # Inputs: 1 - Robot number
    #
    # Outputs: None

    RobotNumber=3D$1

    if [[ ""$TESTING =3D "true" ]]
    then
    Message "\nMoving old volume db entries out of robot $RobotNumber"
    fi
    i=3D0
    while [[ $i -lt $oldcarts ]]
    do
    if [[ ""$TESTING =3D "true" ]]
    then
    Message "Moving MediaID ${oldlabels[$i]} to VG $NONROBOTICVG in =
    volume database"
    fi

    if [[ ""$MASTERSERVER =3D "" ]]
    then
    $VMHOME/vmchange -res -m ${oldlabels[$i]} -mt ${oldmedia[$i]} -rt none =
    -rc1 ${oldslots[$i]} -rc2 0 -v $NONROBOTICVG
    else
    $VMHOME/vmchange -M $MASTERSERVER -res -m ${oldlabels[$i]} -mt =
    ${oldmedia[$i]} -rt none -rc1 ${oldslots[$i]} -rc2 0 -v $NONROBOTICVG
    fi
    if [ $? !=3D 0 ]
    then
    Fatal 991 "vmchange failed to move tape ${oldlabels[$i]} out of =
    robot $RobotNumber" MoveMediaFromRobot
    fi
    i=3D$((i + 1))
    done
    return
    }

    CreateDummyMediaInRobot()
    {
    # Create a new dummy tape in the VMDB or moves it if it exists.
    #
    # Globals: VMHOME, NONROBOTICVG
    #
    # Inputs: 1 - Robot number
    # 2 - Robot type
    #
    # Outputs: maxdummy, fakelabel[]

    RobotNumber=3D$1
    RobotType=3D$2
    RobotDensity=3D$3

    case $RobotType in
    tld | TLD | tsd | TSD) MediaType=3D"dlt";;
    tl8 | TL8 | ts8 | TS8) MediaType=3D"8mm";;
    *) Fatal 990 "This script can only handle DLT or 8mm devices" =
    CreateDummyMediaInRobot ;;
    esac

    if [[ ""$TESTING =3D "true" ]]
    then
    Message "\nMoving fake mediaID entries into robot $RobotNumber"
    fi
    maxdummy=3D0
    i=3D0
    while [[ $i -lt $maxslots ]]
    do
    if [[ ""${newlabels[$i]} =3D "+HasTape+" ]]
    then
    fakelabel[$maxdummy]=3D`printf "%02sZ%03s" $RobotNumber =
    $maxdummy`
    if [[ ""$MASTERSERVER =3D "" ]]
    then
    cmd=3D"vmquery -m ${fakelabel[$maxdummy]}"
    else
    cmd=3D"vmquery -M $MASTERSERVER -m ${fakelabel[$maxdummy]}"
    fi
    if $cmd >/dev/null 2>&1
    then
    if [[ ""$TESTING =3D "true" ]]
    then
    Message "Moving pre-existing MediaID ${fakelabel[$maxdummy]} =
    into robot $RobotNumber slot ${newslots[$i]}."
    fi
    if [[ ""$MASTERSERVER =3D "" ]]
    then
    $VMHOME/vmchange -res -m ${fakelabel[$maxdummy]} -mt $RobotDensity =
    -rt $RobotType -rn $RobotNumber -rc1 ${newslots[$i]}
    else
    $VMHOME/vmchange -M $MASTERSERVER -res -m ${fakelabel[$maxdummy]} =
    -mt $RobotDensity -rt $RobotType -rn $RobotNumber -rc1 ${newslots[$i]}
    fi
    else
    if [[ ""$TESTING =3D "true" ]]
    then
    Message "Creating MediaID ${fakelabel[$maxdummy]} in robot =
    $RobotNumber slot ${newslots[$i]}"
    fi
    if [[ ""$MASTERSERVER =3D "" ]]
    then
    $VMHOME/vmadd -m ${fakelabel[$maxdummy]} -mt $RobotDensity -rt =
    $RobotType -rn $RobotNumber -rc1 ${newslots[$i]}=20
    else
    $VMHOME/vmadd -M $MASTERSERVER -m ${fakelabel[$maxdummy]} -mt =
    $RobotDensity -rt $RobotType -rn $RobotNumber -rc1 ${newslots[$i]}=20
    fi
    if [ $? !=3D 0 ]
    then
    Fatal 991 "vmadd failed to create tape =
    ${fakelabel[$maxdummy]}in robot $RobotNumber" CreateDummyMediaInRobot
    fi
    fi
    maxdummy=3D$((maxdummy + 1))
    fi
    i=3D$((i + 1))
    done
    return
    }

    DeleteDummyMedia()
    {
    # Delete a dummy mediaID from the VMDB
    #
    # Globals: VMHOME
    # =20
    # Inputs: 1 - MediaID
    #
    # Outputs: None

    MediaID=3D$1

    if [[ ""$TESTING =3D "true" ]]
    then
    Message "Deleting fake MediaID $MediaID at `date`"
    fi
    if [[ ""$MASTERSERVER =3D "" ]]
    then
    $VMHOME/vmdelete -m $MediaID
    else
    $VMHOME/vmdelete -M $MASTERSERVER -m $MediaID
    fi
    if [[ $? !=3D 0 ]]
    then
    Fatal 886 "Failed to delete MediaID $MediaID" DeleteDummyMedia
    fi
    return
    }

    GetRVSNFromTapes()
    {
    # Load tapes, read RVSN, unload tapes
    #
    # Globals: VMHOME, maxdummy, fakelabel[]
    # =20
    # Inputs: 1 - Robot number
    # 2 - Robot type
    #
    # Outputs: newlabels[]

    RobotNumber=3D$1
    RobotType=3D$2
    RobotDensity=3D$3

    Message "\nScanning tape headers in robot number $RobotNumber"

    i=3D0
    while [[ $i -lt $maxdummy ]]
    do
    (
    cat /dev/null > $TMP1
    Message "Queued request for tape in slot ${newslots[$i]} at =
    `date`"
    $VMHOME/tpreq -ev ${fakelabel[$i]} -d $RobotDensity =
    /tmp/${fakelabel[$i]} >/dev/null 2>&1
    if [ $? !=3D 0 ];then
    Message "tpreq failed to load tape ${fakelabel[$i]} in robot =
    $RobotNumber (Function GetRVSNFromTapes)"
    fi
    if [[ ""$TESTING =3D "true" ]]
    then
    Message "\nLoaded fake tape ${fakelabel[$i]} at `date`"
    fi
    =20
    # Check what the avrd process says about the fake tape:
    evsn=3D""; rvsn=3D""; writeable=3D""
    retcode=3D"1"
    $VMHOME/vmoprcmd -d ds | nawk '
    {
    evsn=3Dsubstr($0,46,9);
    rvsn=3Dsubstr($0,38,8);
    writeable=3Dsubstr($0,63,4);
    print evsn, rvsn, writeable
    }' | while read evsn rvsn writeable
    do
    if [[ ""$evsn =3D ""${fakelabel[$i]} ]]
    then
    printf "%2s %4s %6s %6s %4s\n" $RobotNumber ${newslots[$i]} =
    $writeable $evsn $rvsn >> $TMP1
    retcode=3D"0"
    fi
    done
    if [[ $retcode !=3D 0 ]]
    then
    Message "Fake tape ${fakelabel[$i]} not found in vmoprcmd =
    output (Function GetRVSNFromTapes)"
    fi
    $VMHOME/tpunmount /tmp/${fakelabel[$i]}
    if [ $? !=3D 0 ]
    then
    Message "tpreq failed to unmount tape ${fakelabel[$i]} in robot =
    $RobotNumber (Function GetRVSNFromTapes)"
    else
    if [[ ""$TESTING =3D "true" ]]
    then
    Message "Unmounted fake tape ${fakelabel[$i]} at `date`"
    fi=20
    DeleteDummyMedia ${fakelabel[$i]}
    fi
    Message "Finished scanning tape in slot ${newslots[$i]} at =
    `date`"
    ) &
    i=3D$((i + 1))
    done

    # Wait for all background jobs to complete
    wait

    if [[ ""$TESTING =3D "true" ]]
    then
    Message "\nResult of parallel tape query:"
    cat $TMP1 | while read line
    do
    Message "$line"
    done
    fi

    sort -o $TMP1 $TMP1

    Message "\nProcessing Tape information gathered above."

    i=3D0;
    cat $TMP1 | while read RN SlotNumber Writeable EVSN RVSN=20
    do
    SkipMedia=3D"false"

    # Check tape actually has a label (RVSN)
    if [[ ""$RVSN =3D "" ]]
    then
    Message "WARNING: Media in slot $SlotNumber of robot $RN has NO =
    LABEL!"
    SkipMedia=3D"true"
    else
    # Check tapes are writeable
    if [[ ""$Writeable !=3D "Yes" ]]
    then
    Message "WARNING: MediaID $RVSN in slot $SlotNumber of robot $RN is =
    WRITE PROTECTED!"
    SkipMedia=3D"true"
    fi

    # Check RVSN exists in the database
    if [[ ""$MASTERSERVER =3D "" ]]
    then
    $VMHOME/vmquery -m $RVSN -bx 2>/dev/null > $TMP2
    else
    $VMHOME/vmquery -M $MASTERSERVER -m $RVSN -bx 2>/dev/null > $TMP2
    fi
    if [[ $? !=3D 0 ]]
    then
    Message "WARNING: MediaID $RVSN in slot $SlotNumber of robot $RN was =
    not found in volume database"
    SkipMedia=3D"true"
    else
    # Get media type for RVSN
    nawk -v rvsn=3D$RVSN '
    {
    if ($1 =3D=3D rvsn) {print tolower($2) " " $12 " " $13}
    }' $TMP2 | read MediaType Assigned Expires

    # Check no images on RVSN (Warning)
    if [ "$Assigned" !=3D "---" ] || [ "$Expires" !=3D "---" ]
    then
    Message "WARNING: MediaID $RVSN in slot $SlotNumber of robot $RN has =
    EXISTING IMAGES!"
    fi
    fi
    fi
    if [[ ""$SkipMedia =3D "true" ]]
    then
    newlabels[$i]=3D"+Skip+"
    newmediatype[$i]=3D"+Skip+"
    newwriteable[$i]=3D"+Skip+"
    else
    newlabels[$i]=3D$RVSN
    newmediatype[$i]=3D$MediaType
    newwriteable[$i]=3D$Writeable
    fi
    i=3D$((i + 1))
    done

    if [[ ""$TESTING =3D "true" ]]
    then
    i=3D0
    Message "\nNew tapes information:"
    while [[ $i -lt $filledslots ]]
    do
    Message "Robot No.: $RobotNumber Slot No.: ${newslots[$i]} =
    MediaID: ${newlabels[$i]} MediaType: ${newmediatype[$i]} Writeable: =
    ${newwriteable[$i]}" =20
    i=3D$((i + 1))
    done
    fi
    }

    DisplayChanges()
    {
    # Display the real labels etc found in each robot.
    #
    # Globals:=20
    # =20
    # Inputs: 1 - Robot number
    # 2 - Robot type
    #
    # Outputs: None

    RobotNumber=3D$1
    RobotType=3D$2

    Message "\nInventory of robot number $RobotNumber"
    Message "------------------------------------------------"
    Message "Slot" =20
    Message "No. MediaID MediaType Writeable" =20
    # xxxx...xxxxxx..xxxxxxxx..xxx
    # 1 2 3 4 5
    # 01234567890123456789012345678901234567890123456789 0
    i=3D0
    while [[ $i -lt $filledslots ]]
    do
    output=3D`printf "%-4s %-6s %-8s %-3s" ${newslots[$i]} =
    ${newlabels[$i]} ${newmediatype[$i]} ${newwriteable[$i]}"` =20
    Message "$output"
    i=3D$((i + 1))
    done
    }

    MoveRealTapesIntoRobot()
    {
    # Update VMDB with true location of tapes in the robot
    #
    # Globals: VMHOME, maxdummy, fakelabel[]
    # =20
    # Inputs: 1 - Robot number
    # 2 - Robot type
    #
    # Outputs: None

    RobotNumber=3D$1
    RobotType=3D$2

    i=3D0
    Message "\nMoving volume database entries for robot $RobotNumber:"
    while [[ $i -lt $filledslots ]]
    do
    if [ ""${newlabels[$i]} !=3D "+Skip+" ]
    then
    Message "Moving (in database) MediaID ${newlabels[$i]} into slot =
    ${newslots[$i]} of robot number $RobotNumber"
    if [[ ""$MASTERSERVER =3D "" ]]
    then
    $VMHOME/vmchange -res -m ${newlabels[$i]} -mt ${newmediatype[$i]} -rt =
    $RobotType -rn $RobotNumber -rc1 ${newslots[$i]} 2>$TMP
    else
    $VMHOME/vmchange -res -M $MASTERSERVER -m ${newlabels[$i]} -mt =
    ${newmediatype[$i]} -rt $RobotType -rn $RobotNumber -rc1 =
    ${newslots[$i]} 2>$TMP
    fi
    else
    Message "Skipping media in slot ${newslots[$i]} of robot number =
    $RobotNumber due to problems listed above."
    fi
    i=3D$((i + 1))
    done
    return
    }

    ################################################## ####################
    # ScriptMain - Execution starts here...
    ################################################## ####################
    #
    # Pseudo code description of program execution
    #=20
    # 1. Set up globals; define functions
    # 2. Check environment
    # 3. Get list of available robots (robid[] robpath[] robtype[])
    # 4. Loop over robots
    # 5. Get currently occupied slots (newslots[])
    # 6. Get old labels from volume db (oldslots[] oldlabels[])
    # 7. Move old labels out of volume db
    # 8. Add dummy media ids to volume db (dummylabels[])
    # 9. Scan recorded labels on media
    # 10. Confirm desire to make changes
    # 11. Move real labels into robot in volume db
    # 12. End loop over robots
    #
    ################################################## ####################

    # 1. Set up Globals; define functions - see head of script.

    # Copy StdIn & StdOut in case they get redirected.
    # We have to do this here in case the script is called with
    # incorrect parameters. (Message() writes to &3)
    exec 3>&1
    exec 4<&0

    if [ $# =3D 0 ]
    then
    Fatal 975 "Not enough parameters!" ScriptMain
    Usage
    fi

    # 2. Check environment
    CheckEnv $*

    # 3. Get list of available robots (robid[] robpath[] robtype[])
    GetAvailableRobotInfo

    # 4. Loop over robots
    j=3D0
    while [[ $j -lt $maxrobots ]]
    do
    # 5. Get currently occupied slots (newslots[])
    GetSlotsWithTapes ${robid[$j]} ${robtype[$j]}

    # 6. Get old labels from volume db (oldslots[] oldlabels[])
    GetMediaInRobotFromVMDB ${robid[$j]}=20

    # 7. Move old labels out of volume db
    MoveMediaFromRobot ${robid[$j]}

    # 8. Add dummy media ids to volume db (dummylabels[])
    CreateDummyMediaInRobot ${robid[$j]} ${robtype[$j]} ${robdens[$j]}

    # 9. Scan recorded labels on media (newlabels[])
    GetRVSNFromTapes ${robid[$j]} ${robtype[$j]} ${robdens[$j]}

    # 10. Confirm desire to make changes
    DisplayChanges ${robid[$j]} ${robtype[$j]}

    # 10a. If we're running interactively, ask whether to do changes?
    #=20

    # 11. Move real labels into robot in volume db
    MoveRealTapesIntoRobot ${robid[$j]} ${robtype[$j]}

    j=3D$((j + 1))
    done # 12. End loop over robots

    # Normal exit condition - trap will run CleanUp for us.
    exit 0



    "Jeremy Aldrich" wrote in message
    news:3ea02f5b@hronntp01....
    > I am having problems with 4 tapes that were previously used. They all

    have
    > a blank EVSN and an RVSN that is currently used by another tape. How can

    I
    > erase these tapes or the labels for the tapes? Also, how can I find the
    > mediaID or barCode just by reading what is in the drive?
    >
    > ------------------------------------
    >
    > Jeremy Aldrich
    > Data Technology Services, Inc.
    > 10920 W Alameda Ave
    > Lakewood, CO 80226
    > (303)989-1446 x123
    > www.DTSiNETadvantage.com
    > www.dtsisoftware.com
    >
    >
    >




  3. still having problems

    Hey all,

    I am still having problems with tapes that have an RVSN but NO EVSN.
    The ./bplabel command tells me that I need an EVSN and density to run the
    command. How do I erase
    tapes that have an RVSN but no EVSN?
    I run:
    bplabel -ev A20020 -d 4mm -o
    (there is no -h option)
    The command is then added to the queue, but it doesn't do anything to the
    tape that is in the drive. Am I missing a secondary command?

    Any help is greatly appreciated...the Knowledge Base has proven to be
    useless on this question.

    Jeremy Aldrich
    Data Technology Services, Inc.
    10920 W Alameda Ave
    Lakewood, CO 80226
    (303)989-1446 x123
    www.DTSiNETadvantage.com


    "the 13th warrior" wrote in message
    news:3ea3b346@hronntp01....
    > 1) ./bplabel -h ( relabelisation of media )
    > 2) reading the rvsn and evsn of media
    >
    >
    > "Jeremy Aldrich" wrote in message
    > news:3ea02f5b@hronntp01....
    > > I am having problems with 4 tapes that were previously used. They all

    > have
    > > a blank EVSN and an RVSN that is currently used by another tape. How

    can
    > I
    > > erase these tapes or the labels for the tapes? Also, how can I find the
    > > mediaID or barCode just by reading what is in the drive?
    > >
    > > ------------------------------------
    > >
    > > Jeremy Aldrich
    > > Data Technology Services, Inc.
    > > 10920 W Alameda Ave
    > > Lakewood, CO 80226
    > > (303)989-1446 x123
    > > www.DTSiNETadvantage.com
    > > www.dtsisoftware.com
    > >
    > >
    > >

    >
    >




+ Reply to Thread