use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume in project coprhd-controller by CoprHD.
the class VolumeIngestionUtil method isRPProtectingVplexVolumes.
/**
* Checks whether RP is protecting any VPLEX volumes or not.
*
* 1. Get the ProtectionSet from the context for the given unmanagedvolume.
* 2. Check every volume in the protectionset.
* 3. If the volume belongs to a VPLEX or not.
* 4. If it belongs to VPLEX break the loop and return true.
*
* @param umv - unmanaged volume to ingest
* @param requestContext - current unmanaged volume context.
* @param dbClient - dbclient reference.
*/
public static boolean isRPProtectingVplexVolumes(UnManagedVolume umv, IngestionRequestContext requestContext, DbClient dbClient) {
VolumeIngestionContext context = requestContext.getVolumeContext(umv.getNativeGuid());
boolean isRPProtectingVplexVolumes = false;
// We expect RP Context to validate Vplex volumes protected by RP or not.
if (context instanceof RecoverPointVolumeIngestionContext) {
RecoverPointVolumeIngestionContext rpContext = (RecoverPointVolumeIngestionContext) context;
ProtectionSet pset = rpContext.getManagedProtectionSet();
if (pset == null) {
return isRPProtectingVplexVolumes;
}
// Iterate thru protection set volumes.
for (String volumeIdStr : pset.getVolumes()) {
for (Set<DataObject> dataObjList : rpContext.getDataObjectsToBeUpdatedMap().values()) {
for (DataObject dataObj : dataObjList) {
if (URIUtil.identical(dataObj.getId(), URI.create(volumeIdStr))) {
Volume volume = (Volume) dataObj;
if (volume.isVPlexVolume(dbClient)) {
isRPProtectingVplexVolumes = true;
break;
}
}
}
}
}
} else if (context instanceof BlockVolumeIngestionContext) {
// In this case, the last volume ingested was a replica, so we need to fish out RP information slightly differently.
Set<DataObject> updatedObjects = requestContext.getDataObjectsToBeUpdatedMap().get(umv.getNativeGuid());
if (updatedObjects != null && !updatedObjects.isEmpty()) {
for (DataObject dataObj : updatedObjects) {
if (dataObj instanceof Volume) {
Volume volume = (Volume) dataObj;
if (volume.isVPlexVolume(dbClient)) {
isRPProtectingVplexVolumes = true;
break;
}
}
}
}
} else {
_logger.error("Context found of type: {} invalid", context.getClass().toString());
}
return isRPProtectingVplexVolumes;
}
use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume in project coprhd-controller by CoprHD.
the class VolumeIngestionUtil method clearFullCopiesFlags.
/**
* Clear the flags of the full copies of the RP volume
*
* @param requestContext current unManagedVolume Ingestion context.
* @param volumes the Volume Objects to clear flags on
* @param updatedObjects a Set of DataObjects to be updated in the database at the end of ingestion
* @param dbClient - dbClient reference.
*/
public static void clearFullCopiesFlags(IngestionRequestContext requestContext, Volume volume, Set<DataObject> updatedObjects, DbClient dbClient) {
if (volume.getFullCopies() != null) {
for (String volumeId : volume.getFullCopies()) {
BlockObject bo = requestContext.findDataObjectByType(Volume.class, URI.create(volumeId), true);
if (null != bo && bo instanceof Volume) {
_logger.info("Clearing internal volume flag of full copy {} of RP volume {}", bo.getLabel(), volume.getLabel());
bo.clearInternalFlags(BlockIngestOrchestrator.INTERNAL_VOLUME_FLAGS);
updatedObjects.add(bo);
}
}
}
}
use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume in project coprhd-controller by CoprHD.
the class VolumeIngestionUtil method findVplexParentVolume.
/**
* Recursively find a VPLEX parent volume for the given UnManagedVolume. Will first check
* VPLEX_PARENT_VOLUME and if not found, will check LOCAL_REPLICA_SOURCE_VOLUME recursively
* for its VPLEX_PARENT_VOLUME.
*
* @param unManagedVolume the UnManagedVolume to check
* @param dbClient a reference to the database client
* @param cache an optional cache of loaded VPLEX parent volume guids to UnManagedVolume object for that GUID
* @return the root parent VPLEX virtual volume UnManagedVolume, or null if none found
*/
public static UnManagedVolume findVplexParentVolume(UnManagedVolume unManagedVolume, DbClient dbClient, Map<String, UnManagedVolume> cache) {
if (unManagedVolume == null || isVplexVolume(unManagedVolume)) {
return unManagedVolume;
}
String vplexParentVolumeGuid = PropertySetterUtil.extractValueFromStringSet(SupportedVolumeInformation.VPLEX_PARENT_VOLUME.toString(), unManagedVolume.getVolumeInformation());
if (vplexParentVolumeGuid != null) {
if (cache != null && cache.containsKey(vplexParentVolumeGuid)) {
return cache.get(vplexParentVolumeGuid);
}
URIQueryResultList unManagedVolumeList = new URIQueryResultList();
dbClient.queryByConstraint(AlternateIdConstraint.Factory.getVolumeInfoNativeIdConstraint(vplexParentVolumeGuid), unManagedVolumeList);
if (unManagedVolumeList.iterator().hasNext()) {
UnManagedVolume vplexParentVolume = dbClient.queryObject(UnManagedVolume.class, unManagedVolumeList.iterator().next());
if (cache != null) {
cache.put(vplexParentVolumeGuid, vplexParentVolume);
}
return vplexParentVolume;
}
} else {
String localReplicaSourceVolumeGuid = PropertySetterUtil.extractValueFromStringSet(SupportedVolumeInformation.LOCAL_REPLICA_SOURCE_VOLUME.toString(), unManagedVolume.getVolumeInformation());
if (localReplicaSourceVolumeGuid != null) {
URIQueryResultList unManagedVolumeList = new URIQueryResultList();
dbClient.queryByConstraint(AlternateIdConstraint.Factory.getVolumeInfoNativeIdConstraint(localReplicaSourceVolumeGuid), unManagedVolumeList);
if (unManagedVolumeList.iterator().hasNext()) {
UnManagedVolume localReplicaSourceVolume = dbClient.queryObject(UnManagedVolume.class, unManagedVolumeList.iterator().next());
return findVplexParentVolume(localReplicaSourceVolume, dbClient, cache);
}
}
}
return null;
}
use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume in project coprhd-controller by CoprHD.
the class VolumeIngestionUtil method clearReplicaFlagsInIngestionContext.
/**
* Clear the flags of replicas which have been updated during the ingestion process
*
* @param requestContext current unManagedVolume Ingestion context.
* @param volumes RP volumes
* @param dbClient database client
*/
public static void clearReplicaFlagsInIngestionContext(IngestionRequestContext requestContext, List<Volume> volumes, DbClient dbClient) {
// We need to look for all snapshots and snapshot session in the contexts related to the rp volumes and its backend volumes and
// clear their flags.
_logger.info("Clearing flags of replicas in the context");
List<String> rpVolumes = new ArrayList<String>();
for (Volume volume : volumes) {
rpVolumes.add(volume.getId().toString());
if (RPHelper.isVPlexVolume(volume, dbClient) && volume.getAssociatedVolumes() != null && !volume.getAssociatedVolumes().isEmpty()) {
StringSet associatedVolumes = volume.getAssociatedVolumes();
rpVolumes.addAll(associatedVolumes);
}
}
for (VolumeIngestionContext volumeIngestionContext : requestContext.getRootIngestionRequestContext().getProcessedUnManagedVolumeMap().values()) {
if (volumeIngestionContext instanceof IngestionRequestContext) {
for (Set<DataObject> objectsToBeUpdated : ((IngestionRequestContext) volumeIngestionContext).getDataObjectsToBeUpdatedMap().values()) {
for (DataObject o : objectsToBeUpdated) {
boolean rpBlockSnapshot = (o instanceof BlockSnapshot && rpVolumes.contains(((BlockSnapshot) o).getParent().getURI().toString()));
boolean rpBlockSnapshotSession = (o instanceof BlockSnapshotSession && rpVolumes.contains(((BlockSnapshotSession) o).getParent().getURI().toString()));
if (rpBlockSnapshot || rpBlockSnapshotSession) {
_logger.info(String.format("Clearing internal volume flag of %s %s of RP volume ", (rpBlockSnapshot ? "BlockSnapshot" : "BlockSnapshotSession"), o.getLabel()));
o.clearInternalFlags(BlockIngestOrchestrator.INTERNAL_VOLUME_FLAGS);
}
}
}
}
}
}
use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume in project coprhd-controller by CoprHD.
the class VolumeIngestionUtil method findUnManagedVolumesForCluster.
/**
* Returns a List of UnManagedVolumes for the given Cluster URI.
*
* @param clusterUri the Cluster URI to check
* @param dbClient a reference to the database client
* @return a List of UnManagedVolumes for the given Cluster URI
*/
public static List<UnManagedVolume> findUnManagedVolumesForCluster(URI clusterUri, DbClient dbClient) {
_logger.info("finding unmanaged volumes for cluster " + clusterUri);
Set<URI> consistentVolumeUris = new HashSet<URI>();
List<URI> hostUris = ComputeSystemHelper.getChildrenUris(dbClient, clusterUri, Host.class, "cluster");
int hostIndex = 0;
for (URI hostUri : hostUris) {
_logger.info(" looking at host " + hostUri);
List<Initiator> initiators = ComputeSystemHelper.queryInitiators(dbClient, hostUri);
URIQueryResultList results = new URIQueryResultList();
Set<URI> unManagedVolumeUris = new HashSet<URI>();
for (Initiator initiator : initiators) {
_logger.info(" looking at initiator " + initiator.getInitiatorPort());
dbClient.queryByConstraint(AlternateIdConstraint.Factory.getUnManagedVolumeInitiatorNetworkIdConstraint(initiator.getInitiatorPort()), results);
if (results.iterator() != null) {
for (URI uri : results) {
_logger.info(" found UnManagedVolume " + uri);
unManagedVolumeUris.add(uri);
}
}
}
Set<URI> thisHostsUris = new HashSet<URI>();
for (URI unmanagedVolumeUri : unManagedVolumeUris) {
if (hostIndex == 0) {
// on the first host, just add all UnManagedVolumes that were found
consistentVolumeUris.add(unmanagedVolumeUri);
} else {
// on subsequent hosts, create a collection to use in diffing the sets
thisHostsUris.add(unmanagedVolumeUri);
}
}
if (hostIndex > 0) {
// retain only UnManagedVolumes that are found exposed to all hosts in the cluster
consistentVolumeUris.retainAll(thisHostsUris);
}
hostIndex++;
}
_logger.info(" found {} UnManagedVolumes to be consistent across all hosts", consistentVolumeUris.size());
List<UnManagedVolume> unmanagedVolumes = new ArrayList<UnManagedVolume>();
for (URI unmanagedVolumeUri : consistentVolumeUris) {
UnManagedVolume unmanagedVolume = dbClient.queryObject(UnManagedVolume.class, unmanagedVolumeUri);
if (unmanagedVolume == null || unmanagedVolume.getInactive() == true) {
continue;
}
unmanagedVolumes.add(unmanagedVolume);
_logger.info(" volume: " + unmanagedVolume.getLabel() + " nativeGuid: " + unmanagedVolume.getNativeGuid());
}
return unmanagedVolumes;
}
Aggregations