Search in sources :

Example 61 with BlockSnapshot

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;
}
Also used : Project(com.emc.storageos.db.client.model.Project) NamedURI(com.emc.storageos.db.client.model.NamedURI) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) StringSet(com.emc.storageos.db.client.model.StringSet) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Example 62 with BlockSnapshot

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;
}
Also used : BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot)

Example 63 with BlockSnapshot

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;
}
Also used : Project(com.emc.storageos.db.client.model.Project) Volume(com.emc.storageos.db.client.model.Volume) NamedURI(com.emc.storageos.db.client.model.NamedURI) ArrayList(java.util.ArrayList) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) Map(java.util.Map) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) BlockObject(com.emc.storageos.db.client.model.BlockObject)

Example 64 with BlockSnapshot

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();
    }
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) ArrayList(java.util.ArrayList) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) BlockObject(com.emc.storageos.db.client.model.BlockObject)

Example 65 with BlockSnapshot

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;
}
Also used : Project(com.emc.storageos.db.client.model.Project) Volume(com.emc.storageos.db.client.model.Volume) NamedURI(com.emc.storageos.db.client.model.NamedURI) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot)

Aggregations

BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)401 Volume (com.emc.storageos.db.client.model.Volume)215 URI (java.net.URI)209 ArrayList (java.util.ArrayList)112 NamedURI (com.emc.storageos.db.client.model.NamedURI)110 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)106 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)91 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)63 BlockObject (com.emc.storageos.db.client.model.BlockObject)63 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)55 CIMObjectPath (javax.cim.CIMObjectPath)51 StringSet (com.emc.storageos.db.client.model.StringSet)49 HashMap (java.util.HashMap)48 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)46 BlockSnapshotSession (com.emc.storageos.db.client.model.BlockSnapshotSession)41 WBEMException (javax.wbem.WBEMException)38 Produces (javax.ws.rs.Produces)36 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)35 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)33 Path (javax.ws.rs.Path)33