Tuesday, September 15, 2015

Automation for - perennially-reserved=true

My friend Vinod Balakrishnan  & I worked on automation for perennially-reserved please see the details below.



A.) Create file with name list and save all "lun" id into it.  Create list based on clusters and luns specific to those clusters.

===========================================================================================

B.) CHECK IF All LUNS ARE PRESENT. rUN THIS ON SPECIFIC CLUSTERS AND LUN LIST

cat list | while read line
do
if ! esxcli storage core path list | grep "LUN: $line" >/dev/null
then
echo "Rahim LUN $line IS MISSING"
fi
done

===========================================================================================


C.) RUN THIS COMMAND TO SET RESV ON LISTED LUNS IN FILE list on the respective Clusters/ESXI hosts.

cat list | while read line
do
naa=`esxcli storage core path list | egrep -B5 "LUN: $line"  | grep "Device:"  | head -1`
echo $naa
esxcli storage core device setconfig -d "$naa" --perennially-reserved=true
done

============================================================================================


D.) Check if resv has been set on specified luns or not

TO CHECK IF PERENNIAL RESERVATION HAS BEEN SET ON WHICH NAA

esxcli storage core device list | egrep -B18 "Is Perennially Reserved: true" | grep " Device:"  | awk '{print $NF}' | while read line
do
 lunid=`esxcli storage core path list | egrep -A6 "$line" | grep -i lun | head -1`
 echo "$line $lunid"
done


cat list | while read line
do
if ! esxcli storage core path list | grep "LUN: $line" >/dev/null
then
echo "Rahim LUN $line IS MISSING"
fi
done

==============================================================================================