use of com.emc.storageos.db.joiner.Joiner in project coprhd-controller by CoprHD.
the class VPlexUtil method getExportMasksWithExistingInitiators.
/**
* Returns ExportMask for the VPLEX cluster where passed in list of initiators is in the existingInitiators List.
*
* @param vplexURI URI of the VPLEX system
* @param dbClient database client instance
* @param inits List of Initiators
* @param varrayUri URI of the Virtual Array
* @param vplexCluster VPLEX Cluster value (1 or 2)
* @return the ExportMask with inits in the existingInitiators list
* @throws Exception
*/
public static ExportMask getExportMasksWithExistingInitiators(URI vplexURI, DbClient dbClient, List<Initiator> inits, URI varrayURI, String vplexCluster) throws Exception {
ExportMask sharedVplexExportMask = null;
// Get initiators WWN in upper case without colons
Collection<String> initiatorNames = Collections2.transform(inits, CommonTransformerFunctions.fctnInitiatorToPortName());
// J1 joiner to fetch all the exportMasks for the VPLEX where existingInitiators list match one or all inits.
Joiner j1 = new Joiner(dbClient);
j1.join(ExportMask.class, "exportmask").match("existingInitiators", initiatorNames).match("storageDevice", vplexURI).go().printTuples("exportmask");
List<ExportMask> exportMasks = j1.list("exportmask");
// exportMasks list could have mask for both the VPLEX cluster for the same initiators for the cross-connect case
// hence get the ExportMask for the specific VPLEX cluster.
List<ExportMask> exportMasksForVplexCluster = getExportMasksForVplexCluster(vplexURI, dbClient, varrayURI, vplexCluster, exportMasks);
if (!exportMasksForVplexCluster.isEmpty()) {
sharedVplexExportMask = exportMasksForVplexCluster.get(0);
_log.info(String.format("Found ExportMask %s %s with some or all initiators %s in the existing initiators.", sharedVplexExportMask.getMaskName(), sharedVplexExportMask.getId(), initiatorNames));
}
return sharedVplexExportMask;
}
Aggregations