use of com.emc.storageos.protectioncontroller.RPController in project coprhd-controller by CoprHD.
the class RPBlockServiceApiImpl method createSnapshot.
/**
* Uses the appropriate controller to create the snapshots.
*
* @param reqVolume The volume from the snapshot request.
* @param snapshotURIs The URIs of the prepared snapshots.
* @param snapshotType The snapshot technology type.
* @param createInactive true if the snapshots should be created but not
* activated, false otherwise.
* @param readOnly true if the snapshot should be read only, false otherwise
* @param taskId The unique task identifier.
*/
@Override
public void createSnapshot(Volume reqVolume, List<URI> snapshotURIs, String snapshotType, Boolean createInactive, Boolean readOnly, String taskId) {
boolean vplex = RPHelper.isVPlexVolume(reqVolume, _dbClient);
ProtectionSystem protectionSystem = _dbClient.queryObject(ProtectionSystem.class, reqVolume.getProtectionController());
URI storageControllerURI = null;
if (vplex) {
Volume backendVolume = vplexBlockServiceApiImpl.getVPLEXSnapshotSourceVolume(reqVolume);
storageControllerURI = backendVolume.getStorageController();
} else {
storageControllerURI = reqVolume.getStorageController();
}
if (reqVolume.getProtectionController() != null && (snapshotType.equalsIgnoreCase(BlockSnapshot.TechnologyType.RP.toString()) || reqVolume.getPersonality().equals(Volume.PersonalityTypes.TARGET.toString()))) {
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storageControllerURI);
RPController controller = getController(RPController.class, protectionSystem.getSystemType());
controller.createSnapshot(protectionSystem.getId(), storageSystem.getId(), snapshotURIs, createInactive, readOnly, taskId);
} else {
if (vplex) {
super.createSnapshot(vplexBlockServiceApiImpl.getVPLEXSnapshotSourceVolume(reqVolume), snapshotURIs, snapshotType, createInactive, readOnly, taskId);
} else {
super.createSnapshot(reqVolume, snapshotURIs, snapshotType, createInactive, readOnly, taskId);
}
}
}
use of com.emc.storageos.protectioncontroller.RPController in project coprhd-controller by CoprHD.
the class RPBlockServiceApiImpl method prepareSnapshots.
/**
* Prepares the snapshots for a snapshot request.
*
* @param volumes The volumes for which snapshots are to be created.
* @param snapShotType The snapshot technology type.
* @param snapshotName The snapshot name.
* @param snapshotURIs [OUT] The URIs for the prepared snapshots.
* @param taskId The unique task identifier
*
* @return The list of snapshots
*/
@Override
public List<BlockSnapshot> prepareSnapshots(List<Volume> volumes, String snapshotType, String snapshotName, List<URI> snapshotURIs, String taskId) {
List<BlockSnapshot> snapshots = new ArrayList<BlockSnapshot>();
int index = 1;
for (Volume volume : volumes) {
VolumeGroup volumeGroup = volume.getApplication(_dbClient);
boolean isInApplication = volumeGroup != null && !volumeGroup.getInactive();
if (RPHelper.isProtectionBasedSnapshot(volume, snapshotType, _dbClient) && snapshotType.equalsIgnoreCase(BlockSnapshot.TechnologyType.RP.toString())) {
// need to create snapshots on
if (!volume.getRpTargets().isEmpty()) {
List<URI> targetVolumeURIs = new ArrayList<URI>();
// Build a URI list of target volumes for the call to obtain copy access states
for (String targetVolumeStr : volume.getRpTargets()) {
targetVolumeURIs.add(URI.create(targetVolumeStr));
}
// Get a handle on the RPController so we can query the access states associated with the
// target volumes.
RPController rpController = getController(RPController.class, ProtectionSystem._RP);
Map<URI, String> copyAccessStates = rpController.getCopyAccessStates(volume.getProtectionController(), targetVolumeURIs);
for (URI targetVolumeURI : targetVolumeURIs) {
Volume targetVolume = _dbClient.queryObject(Volume.class, targetVolumeURI);
// can be created for that copy.
if (copyAccessStates != null && !copyAccessStates.isEmpty() && RPHelper.isValidBookmarkState(copyAccessStates.get(targetVolume.getId()))) {
BlockSnapshot snapshot = prepareSnapshotFromVolume(volume, snapshotName, targetVolume, 0, snapshotType, isInApplication);
snapshot.setOpStatus(new OpStatusMap());
snapshot.setEmName(snapshotName);
snapshot.setEmInternalSiteName(targetVolume.getInternalSiteName());
snapshot.setVirtualArray(targetVolume.getVirtualArray());
snapshots.add(snapshot);
_log.info(String.format("Prepared snapshot : [%s]", snapshot.getLabel()));
} else {
_log.warn(String.format("A BlockSnapshot is not being prepared for target volume %s because copy %s is currently in a state [%s] that does not allow bookmarks to be created.", targetVolume.getId(), targetVolume.getRpCopyName(), copyAccessStates.get(targetVolume.getId())));
}
}
}
} else {
boolean vplex = RPHelper.isVPlexVolume(volume, _dbClient);
Volume volumeToSnap = volume;
if (vplex) {
volumeToSnap = vplexBlockServiceApiImpl.getVPLEXSnapshotSourceVolume(volume);
}
boolean isRPTarget = false;
if (NullColumnValueGetter.isNotNullValue(volume.getPersonality()) && volume.getPersonality().equals(PersonalityTypes.TARGET.name())) {
isRPTarget = true;
}
BlockSnapshot snapshot = prepareSnapshotFromVolume(volumeToSnap, snapshotName, (isRPTarget ? volume : null), index++, snapshotType, isInApplication);
snapshot.setTechnologyType(snapshotType);
// Check to see if the RP Copy Name of this volume contains any of the RP Source
// suffix's appended by ViPR
boolean rpCopyNameContainsSrcSuffix = NullColumnValueGetter.isNotNullValue(volume.getRpCopyName()) && (volume.getRpCopyName().contains(SRC_COPY_SUFFIX) || volume.getRpCopyName().contains(MP_ACTIVE_COPY_SUFFIX) || volume.getRpCopyName().contains(MP_STANDBY_COPY_SUFFIX));
// Hotfix for COP-18957
// Check to see if the requested volume is a former Source.
// We do this by checking to see if this is a Target volume and that the RP Copy Name
// contains any of the RP Source suffix's appended by ViPR.
//
// TODO: This is a short term solution since there will be a better way of determining
// this in future releases.
//
// FIXME: One concern here is RP ingestion where ViPR isn't the one who sets the copy names.
// Valid concern and this needs to be changed when RP ingest supports RP+VPLEX: Yoda/Yoda+.
boolean isFormerSource = isRPTarget && rpCopyNameContainsSrcSuffix;
// Check to see if the requested volume is a former target that is now the
// source as a result of a swap. This is done by checking the source volume's
// virtual pool for RP protection. If RP protection does not exist, we know this
// is a former target.
// TODO: In the future the swap functionality should update the vpools accordingly to
// add/remove protection. This check should be removed at that point and another
// method to check for a swapped state should be used.
boolean isFormerTarget = false;
if (NullColumnValueGetter.isNotNullValue(volume.getPersonality()) && volume.getPersonality().equals(PersonalityTypes.SOURCE.name()) && !rpCopyNameContainsSrcSuffix) {
isFormerTarget = true;
}
if (!isInApplication && (((isRPTarget || isFormerTarget) && vplex && !isFormerSource) || !vplex)) {
// For RP+Vplex targets (who are not former source volumes) and former target volumes,
// we do not want to create a backing array CG snap. To avoid doing this, we do not
// set the consistency group.
// OR
// This is a native snapshot so do not set the consistency group, otherwise
// the SMIS code/array will get confused trying to look for a consistency
// group that only exists in RecoverPoint.
snapshot.setConsistencyGroup(null);
}
snapshots.add(snapshot);
_log.info(String.format("Prepared snapshot : [%s]", snapshot.getLabel()));
}
}
if (!snapshots.isEmpty()) {
for (BlockSnapshot snapshot : snapshots) {
Operation op = new Operation();
op.setResourceType(ResourceOperationTypeEnum.CREATE_VOLUME_SNAPSHOT);
op.setStartTime(Calendar.getInstance());
snapshot.getOpStatus().createTaskStatus(taskId, op);
snapshotURIs.add(snapshot.getId());
}
// Create all the snapshot objects
_dbClient.createObject(snapshots);
} else {
// are in direct access mode (invalid bookmark state).
throw APIException.badRequests.cannotCreateSnapshots();
}
// But only return the unique ones
return snapshots;
}
Aggregations