/** * Creates or modifies FC ports * * <p>Steps- 1. Merge all target WWNs into a single list. 2. Get all FC ports of storage system. * 3. From the list constructed in step 1, remove all existing port network Ids 4. Create storage * port instances for the remaining WWNs in the merged list. * * @param initiatorTargetMap */ private void performFCOperation(Map<String, List<String>> initiatorTargetMap) { logger.info( "Start FC Ports create/modify operations," + " for storage system:{} ", storageSystem.getId()); // Merge all target wwns into a single list Set<String> mergedWwnSet = new HashSet<String>(); Set<String> keys = initiatorTargetMap.keySet(); for (String key : keys) { List<String> wwnList = initiatorTargetMap.get(key); for (String wwn : wwnList) { String formattedWwn = addColon(wwn); mergedWwnSet.add(formattedWwn); } } // Get all existing FC storage ports List<StoragePort> fcPorts = getFCPorts(); // Remove the existing storage port wwns from the merged list for (StoragePort fcPort : fcPorts) { String portNetworkId = fcPort.getPortNetworkId(); if (mergedWwnSet.contains(portNetworkId)) { mergedWwnSet.remove(portNetworkId); } } // Now, create new ports for each item present in the final mergedWwnList for (String targetStoragePortWWN : mergedWwnSet) { create(targetStoragePortWWN, StorageProtocol.Transport.FC.name()); } logger.info( "End FC Ports create/modify operations," + " for storage system : {}", storageSystem.getId()); }
/* * Filters FC ports from all port list */ private List<StoragePort> getFCPorts() { return filterPortsByType(StorageProtocol.Transport.FC.name()); }