use of com.emc.storageos.db.client.model.BlockObject in project coprhd-controller by CoprHD.
the class VolumeIngestionUtil method getRPVolume.
/**
* Gets the RP block object corresponding to the passed in block object.
* The unamanged volume corresponding to the block object is retrieved to determine the RP properties
* because the RP properties might not yet be set in the BlockObject.
*
* If the passed in block object is RP protected, returns back the same block object.
*
* If the passed in block object is a VPLEX backend volume, returns the block object
* corresponding to the VPLEX virtual volume
*
* @param requestContext current unManagedVolume Ingestion context.
* @param blockObject Block object
* @param dbClient dbClient reference
* @return RP protected block object, null if not RP protected.
*/
public static BlockObject getRPVolume(IngestionRequestContext requestContext, BlockObject blockObject, DbClient dbClient) {
UnManagedVolume umVolume = getUnManagedVolumeForBlockObject(blockObject, dbClient);
if (umVolume != null && checkUnManagedResourceIsRecoverPointEnabled(umVolume)) {
return blockObject;
}
// If this is a vplex backend volume, then check if the vplex virtual volume is RP enabled
if (umVolume != null && isVplexBackendVolume(umVolume)) {
String vplexParentVolumeGUID = PropertySetterUtil.extractValueFromStringSet(SupportedVolumeInformation.VPLEX_PARENT_VOLUME.toString(), umVolume.getVolumeInformation());
String vplexParentBlockObjectGUID = vplexParentVolumeGUID.replace(VolumeIngestionUtil.UNMANAGEDVOLUME, VolumeIngestionUtil.VOLUME);
BlockObject vplexParentBlockObject = requestContext.findCreatedBlockObject(vplexParentBlockObjectGUID);
if (vplexParentBlockObject == null) {
vplexParentBlockObject = VolumeIngestionUtil.getBlockObject(vplexParentBlockObjectGUID, dbClient);
}
URIQueryResultList unManagedVolumeList = new URIQueryResultList();
dbClient.queryByConstraint(AlternateIdConstraint.Factory.getVolumeInfoNativeIdConstraint(vplexParentVolumeGUID), unManagedVolumeList);
if (unManagedVolumeList.iterator().hasNext()) {
UnManagedVolume umv = dbClient.queryObject(UnManagedVolume.class, unManagedVolumeList.iterator().next());
if (umv != null && checkUnManagedResourceIsRecoverPointEnabled(umv)) {
return vplexParentBlockObject;
}
}
}
return null;
}
use of com.emc.storageos.db.client.model.BlockObject in project coprhd-controller by CoprHD.
the class VolumeIngestionUtil method validateStoragePortsInVarray.
/**
* Validates StoragePorts in a VirtualArray for an UnManagedExportMask.
*
* @param dbClient a reference to the database client
* @param volume a BlockObject
* @param varray the VirtualArray to validate
* @param portsInUnManagedMask the set of ports in the UnManagedExportMask
* @param mask the UnManagedExportMask to validate
* @param errorMessages error messages to return if necessary
* @return a BlockObject
*/
public static <T extends BlockObject> boolean validateStoragePortsInVarray(DbClient dbClient, T volume, URI varray, Set<String> portsInUnManagedMask, UnManagedExportMask mask, List<String> errorMessages) {
_logger.info("validating storage ports in varray " + varray);
List<URI> allVarrayStoragePortUris = dbClient.queryByConstraint(AlternateIdConstraint.Factory.getVirtualArrayStoragePortsConstraint(varray.toString()));
allVarrayStoragePortUris = filterOutUnregisteredPorts(dbClient, allVarrayStoragePortUris);
Set<String> allVarrayStoragePortUriStrings = new HashSet<String>((Collections2.transform(allVarrayStoragePortUris, CommonTransformerFunctions.FCTN_URI_TO_STRING)));
SetView<String> unManagedExportMaskPortsNotInSourceVarray = Sets.difference(portsInUnManagedMask, allVarrayStoragePortUriStrings);
// Temporary relaxation of storage port restriction for XIO:
// With XIO we do not have the ability to remove specific (and possibly unavailable) storage ports
// from the LUN maps. So a better check specifically for XIO is to ensure that we at least have one
// storage port in the varray.
StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, mask.getStorageSystemUri());
boolean portsValid = true;
boolean atLeastOnePortMatched = unManagedExportMaskPortsNotInSourceVarray.size() < portsInUnManagedMask.size();
if (storageSystem != null) {
if (storageSystem.getSystemType().equalsIgnoreCase(SystemType.xtremio.toString()) || storageSystem.getSystemType().equalsIgnoreCase(SystemType.unity.toString())) {
portsValid = atLeastOnePortMatched;
} else {
portsValid = unManagedExportMaskPortsNotInSourceVarray.isEmpty();
}
}
if (!portsValid) {
_logger.warn("The following Storage Ports in UnManagedExportMask {} are unavailable in source Virtual Array {}: {}", new Object[] { mask.getMaskName(), varray, Joiner.on(",").join(unManagedExportMaskPortsNotInSourceVarray) });
if (volume instanceof Volume) {
Volume vol = (Volume) volume;
if (isVplexVolume(vol, dbClient)) {
URI haVarray = checkVplexHighAvailabilityArray(vol, dbClient);
if (null != haVarray) {
_logger.info("Checking high availability Virtual Array {} for Storage Ports as well.", haVarray);
allVarrayStoragePortUris = dbClient.queryByConstraint(AlternateIdConstraint.Factory.getVirtualArrayStoragePortsConstraint(haVarray.toString()));
allVarrayStoragePortUris = filterOutUnregisteredPorts(dbClient, allVarrayStoragePortUris);
allVarrayStoragePortUriStrings = new HashSet<String>((Collections2.transform(allVarrayStoragePortUris, CommonTransformerFunctions.FCTN_URI_TO_STRING)));
SetView<String> unManagedExportMaskPortsNotInHaVarray = Sets.difference(unManagedExportMaskPortsNotInSourceVarray, allVarrayStoragePortUriStrings);
if (!unManagedExportMaskPortsNotInHaVarray.isEmpty()) {
int unfoundPortCount = unManagedExportMaskPortsNotInSourceVarray.size() - unManagedExportMaskPortsNotInHaVarray.size();
if (unfoundPortCount < portsInUnManagedMask.size()) {
_logger.warn("Storage Ports {} in unmanaged mask {} were not found in VPLEX source or high availability varray, " + "but at least one port was found in either, so this mask is okay for further processing...", new Object[] { Joiner.on(",").join(getStoragePortNames(Collections2.transform(unManagedExportMaskPortsNotInHaVarray, CommonTransformerFunctions.FCTN_STRING_TO_URI), dbClient)), mask.forDisplay() });
return true;
} else {
_logger.warn("The following Storage Ports in UnManagedExportMask {} are not available in high " + "availability varray {} either, so matching fails for this mask: {}", new Object[] { mask.getMaskName(), getVarrayName(haVarray, dbClient), Joiner.on(",").join(unManagedExportMaskPortsNotInHaVarray) });
StringBuffer errorMessage = new StringBuffer("Unable to find the following Storage Port(s) of unmanaged export mask ");
errorMessage.append(mask.forDisplay());
errorMessage.append(" in source Virtual Array ");
errorMessage.append(getVarrayName(varray, dbClient));
errorMessage.append(" or in high availability Virtual Array ");
errorMessage.append(getVarrayName(haVarray, dbClient)).append(": ");
errorMessage.append(Joiner.on(", ").join(getStoragePortNames((Collections2.transform(unManagedExportMaskPortsNotInHaVarray, CommonTransformerFunctions.FCTN_STRING_TO_URI)), dbClient)));
errorMessage.append(". All ports must be present in one Virtual Array or the other for exported distributed VPLEX volume ingestion.");
errorMessages.add(errorMessage.toString());
return false;
}
} else {
_logger.info("Storage Ports {} in unmanaged mask {} found in high availability varray {}, so this mask is okay", new Object[] { Joiner.on(",").join(getStoragePortNames(Collections2.transform(unManagedExportMaskPortsNotInSourceVarray, CommonTransformerFunctions.FCTN_STRING_TO_URI), dbClient)), mask.forDisplay(), getVarrayName(haVarray, dbClient) });
return true;
}
} else if (atLeastOnePortMatched) {
_logger.info("Storage Ports {} in unmanaged mask {} not found in VPLEX local varray, but at least one port was found, so this mask is okay", new Object[] { Joiner.on(",").join(getStoragePortNames(Collections2.transform(unManagedExportMaskPortsNotInSourceVarray, CommonTransformerFunctions.FCTN_STRING_TO_URI), dbClient)), mask.forDisplay() });
return true;
}
}
}
StringBuffer errorMessage = new StringBuffer("Storage Port(s) ");
errorMessage.append(Joiner.on(", ").join(getStoragePortNames(Collections2.transform(unManagedExportMaskPortsNotInSourceVarray, CommonTransformerFunctions.FCTN_STRING_TO_URI), dbClient)));
errorMessage.append(" in unmanaged export mask ").append(mask.forDisplay());
errorMessage.append(" are not available in Virtual Array ").append(getVarrayName(varray, dbClient));
errorMessage.append(". All ports of the mask must be present in the ingesting Virtual Array for storage systems of type ");
errorMessage.append(storageSystem.getSystemType()).append(". ");
errorMessages.add(errorMessage.toString());
_logger.warn(errorMessages.toString());
return false;
}
_logger.info("Storage Ports {} in unmanaged mask {} are valid for varray {}, so this mask is okay", new Object[] { Joiner.on(",").join(getStoragePortNames(Collections2.transform(portsInUnManagedMask, CommonTransformerFunctions.FCTN_STRING_TO_URI), dbClient)), mask.forDisplay(), getVarrayName(varray, dbClient) });
return true;
}
use of com.emc.storageos.db.client.model.BlockObject 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.BlockObject in project coprhd-controller by CoprHD.
the class VolumeIngestionUtil method clearSnapshotsFlags.
/**
* Clear the flags of the snapshots 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 clearSnapshotsFlags(IngestionRequestContext requestContext, Volume volume, Set<DataObject> updatedObjects, DbClient dbClient) {
URIQueryResultList snapshotURIs = new URIQueryResultList();
dbClient.queryByConstraint(ContainmentConstraint.Factory.getVolumeSnapshotConstraint(volume.getId()), snapshotURIs);
Iterator<BlockSnapshot> snapshotsIterator = dbClient.queryIterativeObjects(BlockSnapshot.class, snapshotURIs);
while (snapshotsIterator.hasNext()) {
BlockSnapshot snap = snapshotsIterator.next();
_logger.info("Clearing internal volume flag of snapshot {} of RP volume {}", snap.getLabel(), volume.getLabel());
snap.clearInternalFlags(BlockIngestOrchestrator.INTERNAL_VOLUME_FLAGS);
updatedObjects.add(snap);
}
// clear the flags of any snapshots created in the context
for (BlockObject createdObject : requestContext.getBlockObjectsToBeCreatedMap().values()) {
if (createdObject instanceof BlockSnapshot) {
BlockSnapshot snapshot = (BlockSnapshot) createdObject;
if (snapshot.getParent() != null && volume.getId().equals(snapshot.getParent().getURI())) {
_logger.info("Clearing internal volume flag of snapshot {} of RP volume {}", snapshot.getLabel(), volume.getLabel());
snapshot.clearInternalFlags(BlockIngestOrchestrator.INTERNAL_VOLUME_FLAGS);
}
}
}
}
use of com.emc.storageos.db.client.model.BlockObject in project coprhd-controller by CoprHD.
the class BlockDeviceController method restoreSnapshotSession.
/**
* {@inheritDoc}
*/
@Override
public void restoreSnapshotSession(URI systemURI, URI snapSessionURI, Boolean updateStatus, String opId) {
BlockSnapshotSession snapshotSession = _dbClient.queryObject(BlockSnapshotSession.class, snapSessionURI);
TaskCompleter completer = new BlockSnapshotSessionRestoreWorkflowCompleter(snapshotSession.getId(), updateStatus, opId);
try {
// Get a new workflow to restore the snapshot session.
Workflow workflow = _workflowService.getNewWorkflow(this, RESTORE_SNAPSHOT_SESSION_WF_NAME, false, opId);
_log.info("Created new workflow to restore snapshot session {} with operation id {}", snapSessionURI, opId);
String waitFor = null;
// Check if we are dealing with a single volume or a group...
BlockObject sourceObj = null;
if (snapshotSession.hasConsistencyGroup() && NullColumnValueGetter.isNotNullValue(snapshotSession.getReplicationGroupInstance())) {
// We need a single source volume for the session.
BlockConsistencyGroup cg = _dbClient.queryObject(BlockConsistencyGroup.class, snapshotSession.getConsistencyGroup());
List<Volume> nativeVolumes = BlockConsistencyGroupUtils.getActiveNativeVolumesInCG(cg, _dbClient);
// get source group name from the session.
String sourceGroupName = snapshotSession.getReplicationGroupInstance();
for (Volume volume : nativeVolumes) {
if (sourceGroupName.equals(volume.getReplicationGroupInstance())) {
sourceObj = volume;
// get source volume which matches session's RG name
break;
}
}
} else {
sourceObj = BlockObject.fetch(_dbClient, snapshotSession.getParent().getURI());
}
if (sourceObj instanceof Volume && isNonSplitSRDFTargetVolume((Volume) sourceObj)) {
// PRIOR to Restoring R2 Device from its session, we need to
// a) SUSPEND the R1-R2 pair if the Copy Mode is ACTIVE Or
// b) SPLIT the R1-R2 pair if the Copy Mode is SYNC/ ASYNC
Volume sourceVolume = (Volume) sourceObj;
URI srdfSourceVolumeURI = sourceVolume.getSrdfParent().getURI();
Volume srdfSourceVolume = _dbClient.queryObject(Volume.class, srdfSourceVolumeURI);
URI srdfSourceStorageSystemURI = srdfSourceVolume.getStorageController();
if (Mode.ACTIVE.equals(Mode.valueOf(sourceVolume.getSrdfCopyMode()))) {
waitFor = suspendSRDFLinkWorkflowStep(waitFor, srdfSourceStorageSystemURI, srdfSourceVolumeURI, sourceObj.getId(), workflow);
} else {
// split all members the group
Workflow.Method splitMethod = srdfDeviceController.splitSRDFGroupLinkMethod(srdfSourceStorageSystemURI, srdfSourceVolumeURI, sourceObj.getId(), false);
Workflow.Method splitRollbackMethod = srdfDeviceController.resumeGroupPairsMethod(srdfSourceStorageSystemURI, srdfSourceVolumeURI, sourceObj.getId());
waitFor = workflow.createStep(SRDFDeviceController.SPLIT_SRDF_MIRRORS_STEP_GROUP, SRDFDeviceController.SPLIT_SRDF_MIRRORS_STEP_DESC, waitFor, srdfSourceStorageSystemURI, getDeviceType(srdfSourceStorageSystemURI), SRDFDeviceController.class, splitMethod, splitRollbackMethod, null);
}
} else if (sourceObj instanceof Volume && isNonSplitSRDFSourceVolume((Volume) sourceObj)) {
// PRIOR to Restoring R1 Device from its session, we need to SUSPEND the R1-R2 pair if the Copy Mode is
// ACTIVE
Volume srdfSourceVolume = (Volume) sourceObj;
URI srdfSourceStorageSystemURI = srdfSourceVolume.getStorageController();
StringSet targets = srdfSourceVolume.getSrdfTargets();
if (null != targets) {
for (String target : targets) {
if (NullColumnValueGetter.isNotNullValue(target)) {
Volume srdfTargetVolume = _dbClient.queryObject(Volume.class, URI.create(target));
if (null != srdfTargetVolume && Mode.ACTIVE.equals(Mode.valueOf(srdfTargetVolume.getSrdfCopyMode()))) {
waitFor = suspendSRDFLinkWorkflowStep(waitFor, srdfSourceStorageSystemURI, srdfSourceVolume.getId(), srdfTargetVolume.getId(), workflow);
}
break;
}
}
}
}
// Create the workflow step to restore the snapshot session.
waitFor = workflow.createStep(RESTORE_SNAPSHOT_SESSION_STEP_GROUP, String.format("Restore snapshot session %s", snapSessionURI), waitFor, systemURI, getDeviceType(systemURI), getClass(), restoreBlockSnapshotSessionMethod(systemURI, snapSessionURI), rollbackMethodNullMethod(), null);
// Execute the workflow.
workflow.executePlan(completer, "Restore block snapshot session successful");
} catch (Exception e) {
_log.error("Restore block snapshot session failed", e);
ServiceCoded serviceException = DeviceControllerException.exceptions.restoreBlockSnapshotSessionFailed(e);
completer.error(_dbClient, serviceException);
}
}
Aggregations