use of com.emc.storageos.db.client.model.BlockSnapshot in project coprhd-controller by CoprHD.
the class DefaultBlockSnapshotSessionApiImpl method prepareSnapshotForSession.
/**
* {@inheritDoc}
*/
@Override
public BlockSnapshot prepareSnapshotForSession(BlockObject sourceObj, String snapsetLabel, String label) {
BlockSnapshot snapshot = new BlockSnapshot();
snapshot.setId(URIUtil.createId(BlockSnapshot.class));
URI cgUri = sourceObj.getConsistencyGroup();
if (cgUri != null) {
snapshot.setConsistencyGroup(cgUri);
}
snapshot.setSourceNativeId(sourceObj.getNativeId());
snapshot.setParent(new NamedURI(sourceObj.getId(), sourceObj.getLabel()));
snapshot.setLabel(label);
snapshot.setStorageController(sourceObj.getStorageController());
snapshot.setSystemType(sourceObj.getSystemType());
snapshot.setVirtualArray(sourceObj.getVirtualArray());
snapshot.setProtocol(new StringSet());
snapshot.getProtocol().addAll(sourceObj.getProtocol());
Project sourceProject = BlockSnapshotSessionUtils.querySnapshotSessionSourceProject(sourceObj, _dbClient);
snapshot.setProject(new NamedURI(sourceProject.getId(), sourceObj.getLabel()));
snapshot.setSnapsetLabel(ResourceOnlyNameGenerator.removeSpecialCharsForName(snapsetLabel, SmisConstants.MAX_SNAPSHOT_NAME_LENGTH));
snapshot.setTechnologyType(BlockSnapshot.TechnologyType.NATIVE.name());
_dbClient.createObject(snapshot);
return snapshot;
}
use of com.emc.storageos.db.client.model.BlockSnapshot in project coprhd-controller by CoprHD.
the class RPBlockSnapshotSessionApiImpl method prepareSnapshotForSession.
/**
* {@inheritDoc}
*/
@Override
public BlockSnapshot prepareSnapshotForSession(BlockObject sourceObj, String snapsetLabel, String instanceLabel) {
// Important: that the only difference between these snapshots and snapshots created with the
// create snapshot APIs is that the parent and project NamedURIs for those snapshots use the
// snapshot label rather than the source label. This is an inconsistency between non-RP snaps
// and other snaps and should probably be fixed.
BlockSnapshotSessionApi snapSessionImpl = getImplementationForBackendSystem(sourceObj.getStorageController());
BlockSnapshot snapshot = snapSessionImpl.prepareSnapshotForSession(sourceObj, snapsetLabel, instanceLabel);
// 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);
_dbClient.updateObject(snapshot);
return snapshot;
}
use of com.emc.storageos.db.client.model.BlockSnapshot in project coprhd-controller by CoprHD.
the class VPlexBlockSnapshotSessionApiImpl method prepareSnapshotsForSession.
/**
* {@inheritDoc}
*/
@Override
public List<Map<URI, BlockSnapshot>> prepareSnapshotsForSession(List<BlockObject> sourceObjList, int sourceCount, int newTargetCount, String newTargetsName, boolean inApplication) {
// The snapshots are generally prepared with information from the
// source side backend volume, which is the volume being snapped.
// The passed source object will be a volume, else would not have
// made it this far.
List<BlockObject> srcSideBackendVolumes = new ArrayList<>();
for (BlockObject sourceObj : sourceObjList) {
srcSideBackendVolumes.add(VPlexUtil.getVPLEXBackendVolume((Volume) sourceObj, true, _dbClient));
}
BlockSnapshotSessionApi snapSessionImpl = getImplementationForBackendSystem(srcSideBackendVolumes.get(0).getStorageController());
List<Map<URI, BlockSnapshot>> snapshotMap = snapSessionImpl.prepareSnapshotsForSession(srcSideBackendVolumes, sourceCount, newTargetCount, newTargetsName, inApplication);
// However, the project is from the VPLEX volume.
Project sourceProject = BlockSnapshotSessionUtils.querySnapshotSessionSourceProject(sourceObjList.get(0), _dbClient);
for (Map<URI, BlockSnapshot> snapshots : snapshotMap) {
for (BlockSnapshot snapshot : snapshots.values()) {
snapshot.setProject(new NamedURI(sourceProject.getId(), sourceObjList.get(0).getLabel()));
_dbClient.updateObject(snapshot);
}
}
return snapshotMap;
}
use of com.emc.storageos.db.client.model.BlockSnapshot in project coprhd-controller by CoprHD.
the class VPlexBlockSnapshotSessionApiImpl method validateRelinkSnapshotSessionTargets.
/**
* {@inheritDoc}
*/
@Override
public void validateRelinkSnapshotSessionTargets(BlockObject snapSessionSourceObj, BlockSnapshotSession tgtSnapSession, Project project, List<URI> snapshotURIs, UriInfo uriInfo) {
URI sourceURI = snapSessionSourceObj.getId();
if (URIUtil.isType(sourceURI, Volume.class)) {
// Get the platform specific implementation for the source side
// backend storage system and call the validation routine.
Volume vplexVolume = (Volume) snapSessionSourceObj;
BlockObject srcSideBackendVolume = VPlexUtil.getVPLEXBackendVolume(vplexVolume, true, _dbClient);
BlockSnapshotSessionApi snapSessionImpl = getImplementationForBackendSystem(srcSideBackendVolume.getStorageController());
snapSessionImpl.validateRelinkSnapshotSessionTargets(srcSideBackendVolume, tgtSnapSession, project, snapshotURIs, uriInfo);
// If the targets to be re-linked are in replication groups, then all targets
// in the group will be re-linked. So, we need to find all snapshots that will
// be re-linked. First make sure we only have a single snapshot per replication
// group so we don't process any twice.
List<URI> filteredSnapshotURIs = new ArrayList<URI>();
if (tgtSnapSession.hasConsistencyGroup() && NullColumnValueGetter.isNotNullValue(tgtSnapSession.getReplicationGroupInstance())) {
filteredSnapshotURIs.addAll(ControllerUtils.ensureOneSnapshotPerReplicationGroup(snapshotURIs, _dbClient));
} else {
filteredSnapshotURIs.addAll(snapshotURIs);
}
List<BlockSnapshot> allSnapshots = new ArrayList<BlockSnapshot>();
for (URI snapshotURI : snapshotURIs) {
BlockSnapshot snapshot = _dbClient.queryObject(BlockSnapshot.class, snapshotURI);
allSnapshots.addAll(ControllerUtils.getSnapshotsPartOfReplicationGroup(snapshot, _dbClient));
}
// Since it is possible to expose a VPLEX backend snapshot as a VPLEX volume,
// it is possible that a linked target being re-linked has been exposed as a
// VPLEX volume. If that is the case, then what this essentially amounts to
// is that the linked target is being restored with the data from the target
// session. As such, the same restrictions for restoring a snapshot session apply
// here, but not for the snapshot session source objects, and instead for the
// VPLEX volumes built on top of the linked targets.
List<Volume> vplexVolumesBuiltOnSnapshots = VPlexUtil.getVPlexVolumesBuiltOnSnapshots(allSnapshots, _dbClient);
for (Volume vplexVolumesBuiltOnSnapshot : vplexVolumesBuiltOnSnapshots) {
// Check for pending tasks on the VPLEX source volume.
checkForPendingTasks(vplexVolumesBuiltOnSnapshot, vplexVolumesBuiltOnSnapshot.getTenant().getURI());
// Verify no active mirrors on the VPLEX volume.
verifyActiveMirrors(vplexVolumesBuiltOnSnapshot);
}
} else {
// so should never be called.
throw APIException.methodNotAllowed.notSupportedForVplexVolumes();
}
}
use of com.emc.storageos.db.client.model.BlockSnapshot in project coprhd-controller by CoprHD.
the class VPlexBlockSnapshotSessionApiImpl method prepareSnapshotForSession.
/**
* {@inheritDoc}
*/
@Override
public BlockSnapshot prepareSnapshotForSession(BlockObject sourceObj, String snapsetLabel, String instanceLabel) {
// The snapshot is generally prepared with information from the
// source side backend volume, which is the volume being snapped.
// The passed source object will be a volume, else would not have
// made it this far.
Volume srcSideBackendVolume = VPlexUtil.getVPLEXBackendVolume((Volume) sourceObj, true, _dbClient);
BlockSnapshotSessionApi snapSessionImpl = getImplementationForBackendSystem(srcSideBackendVolume.getStorageController());
BlockSnapshot snapshot = snapSessionImpl.prepareSnapshotForSession(srcSideBackendVolume, snapsetLabel, instanceLabel);
// However, the project is from the VPLEX volume.
Project sourceProject = BlockSnapshotSessionUtils.querySnapshotSessionSourceProject(sourceObj, _dbClient);
snapshot.setProject(new NamedURI(sourceProject.getId(), sourceObj.getLabel()));
_dbClient.updateObject(snapshot);
return snapshot;
}
Aggregations