use of com.emc.storageos.db.client.model.StringSet in project coprhd-controller by CoprHD.
the class ExportUtils method cleanStaleHostReferences.
/**
* Cleans stale host references from export group instance
*
* @param exportGroup {@link ExportGroup}
* @param dbClient {@link DbClient}
*/
private static void cleanStaleHostReferences(ExportGroup exportGroup, DbClient dbClient) {
if (null == exportGroup || exportGroup.getInactive()) {
return;
}
StringSet exportGroupInitiators = exportGroup.getInitiators();
// not be empty
if (!CollectionUtils.isEmpty(exportGroup.getHosts()) && !CollectionUtils.isEmpty(exportGroupInitiators)) {
Set<String> egHosts = new HashSet<>();
Collection<Initiator> initiators = Collections2.transform(exportGroupInitiators, CommonTransformerFunctions.fctnStringToInitiator(dbClient));
for (Initiator initiator : initiators) {
// upgrade.
if (null != initiator && initiator.getHost() != null) {
egHosts.add(initiator.getHost().toString());
}
}
Set<String> staleHosts = new HashSet<>(Sets.difference(exportGroup.getHosts(), egHosts));
if (!CollectionUtils.isEmpty(staleHosts)) {
Collection<URI> staleHostURIs = Collections2.transform(staleHosts, CommonTransformerFunctions.FCTN_STRING_TO_URI);
_log.info(String.format("Stale host references [%s] will be removed from Export Group %s", Joiner.on(',').join(staleHostURIs), exportGroup.getId()));
exportGroup.removeHosts(new ArrayList<>(staleHostURIs));
}
}
if (!ExportGroupType.Initiator.toString().equalsIgnoreCase(exportGroup.getType()) && CollectionUtils.isEmpty(exportGroup.getHosts()) && !exportGroup.checkInternalFlags(DataObject.Flag.INTERNAL_OBJECT)) {
// COP-27689 - Even if all the export masks got cleared, the export Group still remains with initiators and volumes.
// Clean up all the initiators, volumes and ports as there are no available export masks.
_log.info("There are no hosts in the export Group {}-->{} after cleaning up stale hosts.", exportGroup.getId(), exportGroup.getLabel());
resetExportGroup(exportGroup, dbClient);
}
}
use of com.emc.storageos.db.client.model.StringSet in project coprhd-controller by CoprHD.
the class ExportUtils method cleanStaleZoningMapEntries.
/**
* Cleanup any stale entries in the zoning maps for the export masks with the passed URIs.
*
* @param maskURIs The URIs of the export masks to examine.
* @param dbClient A reference to a database client.
*/
private static void cleanStaleZoningMapEntries(List<URI> maskURIs, DbClient dbClient) {
Iterator<ExportMask> maskIter = dbClient.queryIterativeObjects(ExportMask.class, maskURIs);
while (maskIter.hasNext()) {
ExportMask maskObj = maskIter.next();
StringSetMap zoningMap = maskObj.getZoningMap();
StringSet maskInitIds = maskObj.getInitiators();
Set<String> zoningMapInitIds = new HashSet<>(zoningMap.keySet());
for (String zoningMapInitId : zoningMapInitIds) {
if (maskInitIds == null || maskInitIds.isEmpty() || !maskInitIds.contains(zoningMapInitId)) {
zoningMap.remove(zoningMapInitId);
}
}
maskObj.setZoningMap(zoningMap);
dbClient.updateObject(maskObj);
}
}
use of com.emc.storageos.db.client.model.StringSet in project coprhd-controller by CoprHD.
the class ExportUtils method cleanStaleClusterReferences.
/**
* Cleans stale cluster references from export group instance
*
* @param exportGroup {@link ExportGroup}
* @param dbClient {@link DbClient}
*/
private static void cleanStaleClusterReferences(ExportGroup exportGroup, DbClient dbClient) {
if (null == exportGroup || exportGroup.getInactive()) {
return;
}
StringSet exportGroupInitiators = exportGroup.getInitiators();
if (!CollectionUtils.isEmpty(exportGroup.getClusters()) && !CollectionUtils.isEmpty(exportGroupInitiators)) {
Set<String> egClusterURIs = new HashSet<>();
Collection<Host> hosts = Collections2.transform(exportGroup.getHosts(), CommonTransformerFunctions.fctnStringToHost(dbClient));
for (Host host : hosts) {
if (host.getCluster() != null) {
egClusterURIs.add(host.getCluster().toString());
}
}
Set<String> staleClusters = new HashSet<>(Sets.difference(exportGroup.getClusters(), egClusterURIs));
if (!CollectionUtils.isEmpty(staleClusters)) {
Collection<URI> staleClusterURIs = Collections2.transform(staleClusters, CommonTransformerFunctions.FCTN_STRING_TO_URI);
_log.info(String.format("Stale cluster references [%s] will be removed from Export Group %s", Joiner.on(',').join(staleClusterURIs), exportGroup.getId()));
exportGroup.removeClusters(new ArrayList<>(staleClusterURIs));
}
}
if (ExportGroupType.Cluster.toString().equalsIgnoreCase(exportGroup.getType()) && CollectionUtils.isEmpty(exportGroup.getClusters()) && !exportGroup.checkInternalFlags(DataObject.Flag.INTERNAL_OBJECT)) {
// COP-27689 - Even if all the export masks got cleared, the export Group still remains with initiators and volumes.
// Clean up all the initiators, volumes and ports as there are no available export masks.
_log.info("There are no clusters in the export Group {}-->{} , after cleaning slate clusters.", exportGroup.getId(), exportGroup.getLabel());
resetExportGroup(exportGroup, dbClient);
}
}
use of com.emc.storageos.db.client.model.StringSet in project coprhd-controller by CoprHD.
the class VPlexUtil method getVPLEXBackendVolume.
/**
* Returns the source or ha backend volume of the passed VPLEX volume.
*
* @param vplexVolume A reference to the VPLEX volume.
* @param sourceVolume A boolean thats used to return either source
* or ha backend volume.
* @param dbClient an instance of {@link DbClient}
* @param errorIfNotFound A boolean thats used to either return null or throw error
*
* @return A reference to the backend volume
* If sourceVolume is true returns source backend
* volume else returns ha backend volume.
*/
public static Volume getVPLEXBackendVolume(Volume vplexVolume, boolean sourceVolume, DbClient dbClient, boolean errorIfNotFound) {
StringSet associatedVolumeIds = vplexVolume.getAssociatedVolumes();
Volume backendVolume = null;
if (associatedVolumeIds == null) {
if (errorIfNotFound) {
throw InternalServerErrorException.internalServerErrors.noAssociatedVolumesForVPLEXVolume(vplexVolume.forDisplay());
} else {
return backendVolume;
}
}
// Get the backend volume either source or ha.
List<URI> volumeUriList = new ArrayList<>();
for (String associatedVolumeId : associatedVolumeIds) {
volumeUriList.add(URI.create(associatedVolumeId));
}
Iterator<Volume> volumes = dbClient.queryIterativeObjects(Volume.class, volumeUriList, true);
while (volumes.hasNext()) {
Volume associatedVolume = volumes.next();
if (associatedVolume != null) {
if (sourceVolume && associatedVolume.getVirtualArray().equals(vplexVolume.getVirtualArray())) {
backendVolume = associatedVolume;
break;
}
if (!sourceVolume && !(associatedVolume.getVirtualArray().equals(vplexVolume.getVirtualArray()))) {
backendVolume = associatedVolume;
break;
}
}
}
return backendVolume;
}
use of com.emc.storageos.db.client.model.StringSet in project coprhd-controller by CoprHD.
the class ConnectivityUtil method updateRpSystemConnectivity.
/**
* Refreshes the list of connected varrays for an RP system.
*
* @param rpSystem
*/
public static void updateRpSystemConnectivity(ProtectionSystem rpSystem, DbClient dbClient) {
if (rpSystem.getInactive()) {
return;
}
if (rpSystem.getVirtualArrays() == null) {
rpSystem.setVirtualArrays(new StringSet());
}
rpSystem.getVirtualArrays().replace(StringSetUtil.uriListToSet(getRPSystemVirtualArrays(dbClient, rpSystem.getId())));
dbClient.updateAndReindexObject(rpSystem);
}
Aggregations