1. #!/bin/bash
  2. #
  3. # takes LUNID from Array and provides /dev/mapper device associated with it
  4. # next steps: create multipath functionality (currently only single pathed)
  5. #
  6. # kwillia@gmail.com
  7. ##########################################
  8.  
  9. if [ "X$1" == "X" ]; then
  10.   echo "usage: luntodevid.sh LUNID"
  11.   exit 1
  12. fi
  13. # runs the multipath command looking for LUNID $1 (from the command line)
  14. MULTIPATH=$(multipath -ll |egrep -B3 "_ [0-9]:[0-9]:[0-9]:$1 ")
  15.  
  16. # sets DEVID to the device ID
  17. DEVID=`echo $MULTIPATH | head -n1 | awk '{ print $1 }'`
  18. STORAGETYPE=`echo $MULTIPATH | head -n1 | awk '{ print $3 }'`
  19. DMID=`echo $MULTIPATH | head -n1 | awk '{ print $2 }'`
  20.  
  21. if [ "X$DEVID" == "X" ]; then
  22.   echo "LUN not found"
  23.   exit 1
  24. fi
  25.  
  26. echo "/dev/mapper/$DEVID is connected to LUNID $1"
  27. echo "Storage type is $STORAGETYPE"
  28. echo "DMID is $DMID"