Search in sources :

Example 46 with BlockObject

use of com.emc.storageos.db.client.model.BlockObject in project coprhd-controller by CoprHD.

the class DefaultBlockSnapshotSessionApiImpl method validateRestoreSnapshotSession.

/**
 * {@inheritDoc}
 */
@Override
public void validateRestoreSnapshotSession(List<BlockObject> snapSessionSourceObjs, Project project) {
    // Validate the project tenant.
    TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, project.getTenantOrg().getURI());
    ArgValidator.checkEntity(tenant, project.getTenantOrg().getURI(), false);
    // Verify the user is authorized.
    BlockServiceUtils.verifyUserIsAuthorizedForRequest(project, BlockServiceUtils.getUserFromContext(_securityContext), _permissionsHelper);
    for (BlockObject snapSessionSourceObj : snapSessionSourceObjs) {
        if (URIUtil.isType(snapSessionSourceObj.getId(), Volume.class)) {
            // Make sure that we don't have some pending
            // operation against the volume.
            Volume sourceVolume = (Volume) snapSessionSourceObj;
            checkForPendingTasks(sourceVolume, sourceVolume.getTenant().getURI());
            // On some platforms it is not possible to restore an array snapshot
            // point-in-time copy to a source volume if the volume has active mirrors.
            verifyActiveMirrors(sourceVolume);
        }
    }
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) BlockObject(com.emc.storageos.db.client.model.BlockObject)

Example 47 with BlockObject

use of com.emc.storageos.db.client.model.BlockObject 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 48 with BlockObject

use of com.emc.storageos.db.client.model.BlockObject in project coprhd-controller by CoprHD.

the class VPlexBlockSnapshotSessionApiImpl method createSnapshotSession.

/**
 * {@inheritDoc}
 */
@Override
public void createSnapshotSession(BlockObject sourceObj, URI snapSessionURI, List<List<URI>> snapSessionSnapshotURIs, String copyMode, String taskId) {
    if (URIUtil.isType(sourceObj.getId(), Volume.class)) {
        // Get the platform specific implementation for the source side
        // backend storage system and call the create method.
        Volume vplexVolume = (Volume) sourceObj;
        BlockObject srcSideBackendVolume = VPlexUtil.getVPLEXBackendVolume(vplexVolume, true, _dbClient);
        BlockSnapshotSessionApi snapSessionImpl = getImplementationForBackendSystem(srcSideBackendVolume.getStorageController());
        snapSessionImpl.createSnapshotSession(srcSideBackendVolume, snapSessionURI, snapSessionSnapshotURIs, copyMode, taskId);
    } else {
        // so should never be called.
        throw APIException.methodNotAllowed.notSupportedForVplexVolumes();
    }
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) BlockObject(com.emc.storageos.db.client.model.BlockObject)

Example 49 with BlockObject

use of com.emc.storageos.db.client.model.BlockObject in project coprhd-controller by CoprHD.

the class VPlexBlockSnapshotSessionApiImpl method validateRestoreSnapshotSession.

/**
 * {@inheritDoc}
 */
@Override
public void validateRestoreSnapshotSession(List<BlockObject> snapSessionSourceObjs, Project project) {
    if (URIUtil.isType(snapSessionSourceObjs.get(0).getId(), Volume.class)) {
        // Get the platform specific implementation for the source side
        // backend storage system and call the validation routine.
        List<BlockObject> srcSideBackendVolumes = new ArrayList<>();
        for (BlockObject snapSessionSourceObj : snapSessionSourceObjs) {
            Volume vplexVolume = (Volume) snapSessionSourceObj;
            srcSideBackendVolumes.add(VPlexUtil.getVPLEXBackendVolume(vplexVolume, true, _dbClient));
        }
        BlockSnapshotSessionApi snapSessionImpl = getImplementationForBackendSystem(srcSideBackendVolumes.get(0).getStorageController());
        snapSessionImpl.validateRestoreSnapshotSession(srcSideBackendVolumes, project);
        for (BlockObject snapSessionSourceObj : snapSessionSourceObjs) {
            Volume vplexVolume = (Volume) snapSessionSourceObj;
            // Check for pending tasks on the VPLEX source volume.
            checkForPendingTasks(vplexVolume, vplexVolume.getTenant().getURI());
            // Verify no active mirrors on the VPLEX volume.
            verifyActiveMirrors(vplexVolume);
        }
    } else {
        // so should never be called.
        throw APIException.methodNotAllowed.notSupportedForVplexVolumes();
    }
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) ArrayList(java.util.ArrayList) BlockObject(com.emc.storageos.db.client.model.BlockObject)

Example 50 with BlockObject

use of com.emc.storageos.db.client.model.BlockObject in project coprhd-controller by CoprHD.

the class VPlexBlockSnapshotSessionApiImpl method linkNewTargetVolumesToSnapshotSession.

/**
 * {@inheritDoc}
 */
@Override
public void linkNewTargetVolumesToSnapshotSession(BlockObject snapSessionSourceObj, BlockSnapshotSession snapSession, List<List<URI>> snapshotURIs, String copyMode, String taskId) {
    if (URIUtil.isType(snapSessionSourceObj.getId(), Volume.class)) {
        // Get the platform specific implementation for the source side
        // backend storage system and call the link method.
        Volume vplexVolume = (Volume) snapSessionSourceObj;
        BlockObject srcSideBackendVolume = VPlexUtil.getVPLEXBackendVolume(vplexVolume, true, _dbClient);
        BlockSnapshotSessionApi snapSessionImpl = getImplementationForBackendSystem(srcSideBackendVolume.getStorageController());
        snapSessionImpl.linkNewTargetVolumesToSnapshotSession(srcSideBackendVolume, snapSession, snapshotURIs, copyMode, taskId);
    } else {
        // so should never be called.
        throw APIException.methodNotAllowed.notSupportedForVplexVolumes();
    }
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) BlockObject(com.emc.storageos.db.client.model.BlockObject)

Aggregations

BlockObject (com.emc.storageos.db.client.model.BlockObject)341 URI (java.net.URI)222 ArrayList (java.util.ArrayList)152 Volume (com.emc.storageos.db.client.model.Volume)141 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)109 NamedURI (com.emc.storageos.db.client.model.NamedURI)82 HashMap (java.util.HashMap)82 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)69 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)65 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)60 ExportMask (com.emc.storageos.db.client.model.ExportMask)56 HashSet (java.util.HashSet)56 ExportGroup (com.emc.storageos.db.client.model.ExportGroup)48 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)45 CIMObjectPath (javax.cim.CIMObjectPath)44 Initiator (com.emc.storageos.db.client.model.Initiator)43 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)43 List (java.util.List)40 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)38 StringSet (com.emc.storageos.db.client.model.StringSet)36