
# File	: techlab_cluster02_vol-lun_create
# By	: Maarten.deBoer@Atso.net, 220525
# Build cluster02 volumes & Qtrees after aggr401 crash

# Volumes
ssh alnlfas3170b-mgt 'vol create bc_atl02_vol002 -l C.UTF-8 aggr401 15000g'
ssh alnlfas3170b-mgt 'snap reserve bc_atl02_vol002 0'

ssh alnlfas3170b-mgt 'vol create bc_atl02_vol008 -l C.UTF-8 aggr401 850g'
ssh alnlfas3170b-mgt 'snap reserve bc_atl02_vol008 0'

ssh alnlfas3170b-mgt 'df -g'

ssh alnlfas3170b-mgt 'qtree create /vol/bc_atl02_vol002/alnlcluster02'
ssh alnlfas3170b-mgt 'qtree create /vol/bc_atl02_vol008/alnlcluster02'
ssh alnlfas3170b-mgt 'qtree status'

#ssh alnlfas3170b-mgt 'lun create -s 2T -t hyper_v /vol/ec_atl02_vol227/alnlcluster02/LUN_CLUSTER02_7_CSV5'

# hyper_v LUNs via file cluster02_LUNs
cat techlab_cluster02_LUNs|grep -v ^#|while read LINE
do
  LUN_PATH=`echo ${LINE}|awk -F\; '{print $1}'`
  LUN_SIZE=`echo ${LINE}|awk -F\; '{print $2}'|tr [:lower:] [:upper:]`
  LUN_TYPE=`echo ${LINE}|awk -F\; '{print $3}'`
  echo "  LINE=${LINE}, LUN_PATH=${LUN_PATH}, LUN_SIZE=${LUN_SIZE} ${LUN_TYPE}"

#  ssh -n alnlfas3170b-mgt "lun create -s ${LUN_SIZE} -t ${LUN_TYPE} ${LUN_PATH}"

done  # cat
#ssh alnlfas3170b-mgt 'lun show '|egrep 'vol002|vol008'


# igroups
# igroup create { -f | -i } -t <ostype> [ -a <portset> ]
#                <initiator_group> [ <node> ... ]
# ssh alnlfas3170b-mgt 'igroup create -f -t vmware ALNLCLN091'
cat techlab_cluster02_LUNs|grep -v ^#|while read LINE
do
  LUN_TYPE=`echo ${LINE}|awk -F\; '{print $3}'`
  LUN_IGS=`echo ${LINE}|awk -F\; '{print $4}'`
  echo "  LINE=${LINE}, LUN_TYPE=${LUN_TYPE}, LUN_IGS=${LUN_IGS}"
  for LUN_IG in ${LUN_IGS}
  do
    echo "    LUN_IG=${LUN_IG}"
#    ssh -n alnlfas3170b-mgt "igroup create -f -t ${LUN_TYPE} ${LUN_IG}"

  done  # for

done  # cat
ssh alnlfas3170b-mgt "igroup show"


# lun map [ -f ] <lun_path> <initiator_group> [ <lun_id> ]
#  - make a LUN accessible to initiators in the specified group, at
#    the LUN ID specified.
cat techlab_cluster02_LUNs|grep -v ^#|while read LINE
do

  LUN_PATH=`echo ${LINE}|awk -F\; '{print $1}'`
  LUN_IGS=`echo ${LINE}|awk -F\; '{print $4}'`
  echo "  LINE=${LINE}, LUN_TYPE=${LUN_PATH}, LUN_IGS=${LUN_IGS}"
  for LUN_IG in ${LUN_IGS}
  do
    echo "    MAP ${LUN_PATH} LUN_IG=${LUN_IG}"
    ssh -n alnlfas3170b-mgt "lun map ${LUN_PATH} ${LUN_IG}"
  done  # for


done  # cat
ssh alnlfas3170b-mgt 'lun show -m'

