# This script will look at all Flashcopy mappings. # For each Flashcopy Mappings, it will look at the source volume preferred id and if required # change the target preferred node id to match the source. # In the case where there are many cascaded Flashcopy # it may take a couple runs of this script for all preferred nodes to be optimized # If moving preferred path of a volume from one I/O group to an other, the movevdisk will fail. # This is normal. # This script is provided as is with no warranty. # svcinfo lsfcmap -nohdr | while read item1 item1value do svcinfo lsfcmap $item1 | while read item2 item2value do if [[ $item2 == "source_vdisk_id" ]] then SourceVdiskID=$item2value fi if [[ $item2 == "target_vdisk_id" ]] then TargetVdiskID=$item2value echo "lsfcmap: "$item1", SourceVdiskID: "$SourceVdiskID", TargetVdiskID: "$TargetVdiskID SourceVdiskPrefNodeID=$(svcinfo lsvdisk $SourceVdiskID | while read item3 item3value do if [[ $item3 == "preferred_node_id" ]] then echo $item3value break fi done ) TargetVdiskPrefNodeID=$(svcinfo lsvdisk $TargetVdiskID | while read item4 item4value do if [[ $item4 == "preferred_node_id" ]] then echo $item4value break fi done ) echo " Result: Source volume ID: "$SourceVdiskID" Preferred node ID: "$SourceVdiskPrefNodeID" target volume ID: "$TargetVdiskID" Preferred node ID: "$TargetVdiskPrefNodeID if [[ $SourceVdiskPrefNodeID == $TargetVdiskPrefNodeID ]] then echo " Preferred node ok no change required" else echo " Optimizing target volume to match source" movevdisk -node $SourceVdiskPrefNodeID $TargetVdiskID if [[ $? -eq 0 ]] then echo " movevdisk -node "$SourceVdiskPrefNodeID $TargetVdiskID" Change successful" else echo " *** ERROR *** changing Preferred node: movevdisk -node "$SourceVdiskPrefNodeID $TargetVdiskID Echo "Cannot move preferred path to $SourceVdiskPrefNodeID for volume ID $TargetVdiskID related to Flashcopy Mapping $item1 $item1value" read -p "Pausing because of the error, press any key to continue..." fi echo "Pause for 2 seconds" sleep 2 fi fi done done