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