Get VIO adapters info directly from AIX LPAR

Sometimes You need to find out VIO names and VIO adapter’s which are used by Your AIX LPAR, but do not have access to the VIO servers directly. There is a quick way using kdb to extract those information for You. Just use below scripts.

1) For virtual FC adapters

#!/usr/bin/ksh 
VFCS_LIST=$(lsdev -Cc adapter | awk '/Available .* Virtual Fibre Channel Client Adapter/ { print $1 }')
for f in ${VFCS_LIST}; do 
		echo vfcs $f | kdb | awk ' 
				/^adapter: / { 
						adapter = $2 
						lpar_id = $4 
						lpar_name = $6 
						next 
				} 
				/^host_name: / { 
						vios_host_name = $2 
						vios_host_device_name = $4 
						next 
				} 
				/^num_cmd_elems: / { 
						location_code = $4 
						next 
				} 
				/^portName: / { 
						wwpn = $2 
						next 
				} 
				END { 
						printf( "%-10s %-20s %-20s %s\n", 
								adapter, 
								vios_host_name, 
								vios_host_device_name, 
								wwpn ) 
				} 
				' 
done

2) For virtual SCSI adapters

#!/bin/ksh 
VSCSI_LIST=$(lsdev -Cc adapter | awk '/Available .* Virtual SCSI Client Adapter/ { print $1 }') 
for s in ${VSCSI_LIST}; do 
		echo cvai $s | kdb | awk -v adapter=$s ' 
				/:blank:+host_name: / { 
						vios_host_device_name = $6 
						next 
				} 
				/host part_number: / { 
						vios_host_id = $3 
						vios_host_name = $8 
						next 
				} 
				END { 
						printf( "%-10s %-20s %-20s\n", 
								adapter, 
								vios_host_name, 
								vios_host_device_name ) 
				} 
				' 
done