Script to gather npiv mapping
For Single Server:
for fcs in `lsdev -C |grep fcs |grep Available |awk '{print $1}'` do ada=`echo "vfcs $fcs" |kdb |grep adapter |awk '{print $2}'` loc=`echo "vfcs $fcs" |kdb |grep location_code |awk '{print $4}'` part=`echo "vfcs $fcs" |kdb |grep partition_name |awk '{print $6}'` host=`echo "vfcs $fcs" |kdb |grep host_name |awk '{print $2}'` hostdev=`echo "vfcs $fcs" |kdb |grep host_device |awk '{print $4}'` wwpn=`echo "vfcs $fcs" |kdb |grep portName |awk '{print $2}' |sed 's/../&:/g;s/:$//'` echo $ada,$loc,$part,$host,$hostdev,$wwpn done
For Mutiple Server:
Step 1: Choose a server where you can access all your LPAR’s
Step 2: Generate a key from the chosen server and then scp same key to LPAR under /root
Step 3: Now, You can execute the below script from chosen server
Note:- In our case, We have chosen NIM server as our source server where the script to be executed
server – Should contain LPAR or server name
Name of the script: npiv_mapping.sh
echo Server Name,FCS,Location Code,Hostname,VIO Server,VFChost,WWPN for i in `cat server` do for fcs in `ssh $i lsdev -C |grep fcs |grep Available |awk '{print $1}'` do ada=`ssh $i "echo "vfcs $fcs" |kdb" |grep adapter |awk '{print $2}'` loc=`ssh $i "echo "vfcs $fcs" |kdb" |grep location_code |awk '{print $4}'` part=`ssh $i "echo "vfcs $fcs" |kdb" |grep partition_name |awk '{print $6}'` host=`ssh $i "echo "vfcs $fcs" |kdb" |grep host_name |awk '{print $2}'` hostdev=`ssh $i "echo "vfcs $fcs" |kdb" |grep host_device |awk '{print $4}'` wwpn=`ssh $i "echo "vfcs $fcs" |kdb" |grep portName |awk '{print $2}' |sed 's/../&:/g;s/:$//'` echo $i,$ada,$loc,$part,$host,$hostdev,$wwpn done done
Script to gather vscsi mapping
For Single Server:
for vscsi in `lsdev -C |grep vscsi |grep Available |awk '{print $1}'` do host=`echo "cvai $vscsi" | kdb |grep partition_name |awk '{print $6}'` vio=`echo "cvai $vscsi" | kdb |grep part_name |awk '{print $8}'` vhost=`echo "cvai $vscsi" | kdb |grep host_name |awk '{print $6}'` echo $vscsi,$vio,$vhost done
For Mutiple Server:
Step 1: Choose a server where you can access all your LPAR’s
Step 2: Generate a key from the chosen server and then scp same key to LPAR under /root
Step 3: Now, You can execute the below script from chosen server
Note:- In our case, We have chosen NIM server as our source server where the script to be executed
server – Should contain LPAR or server name
Name of the script: vscsi_mapping.sh
echo Server Name,VSCSI,VIO Server,Vhost for vscsi_mapping_list in `cat server` do for vscsi in `ssh $vscsi_mapping_list lsdev -C |grep vscsi |grep Available |awk '{print $1}'` do host=`ssh $vscsi_mapping_list "echo "cvai $vscsi" | kdb" |grep partition_name |awk '{print $6}'` vio=`ssh $vscsi_mapping_list "echo "cvai $vscsi" | kdb" |grep part_name |awk '{print $8}'` vhost=`ssh $vscsi_mapping_list "echo "cvai $vscsi" | kdb" |grep host_name |awk '{print $6}'` echo $vscsi_mapping_list,$vscsi,$vio,$vhost done done