Search in sources :

Example 21 with BlockSnapshot

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

the class ControllerUtils method getCopyModeFromSnapshotGroup.

/**
 * Gets copy mode for snapshots in snapshot replication group.
 *
 * @param snapGroupName the snap group name
 * @param storage the storage
 * @param dbClient the db client
 * @return the copy mode from snapshot group
 */
public static String getCopyModeFromSnapshotGroup(String snapGroupName, URI storage, DbClient dbClient) {
    List<BlockSnapshot> snapshots = getSnapshotsPartOfReplicationGroup(snapGroupName, storage, dbClient);
    if (!CollectionUtils.isEmpty(snapshots)) {
        BlockSnapshot snapshot = snapshots.get(0);
        return snapshot.getCopyMode();
    }
    s_logger.warn(String.format("No snapshots found for snap group name %s on storage controller %s, returning 'no copy' mode", snapGroupName, storage));
    return BlockSnapshot.CopyMode.nocopy.name();
}
Also used : BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot)

Example 22 with BlockSnapshot

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

the class ControllerUtils method checkCGHasGroupRelationship.

/**
 * Check if CG has any group relationship
 *
 * Note - on array side, if replica has been removed from replication group, but source volume has not been removed from CG yet,
 * the CG will not have group relationship until the source volume get removed from the CG.
 *
 * As a result, getting associator names cannot be used to check if CG has group relationship.
 */
public static boolean checkCGHasGroupRelationship(StorageSystem storage, URI cgURI, DbClient dbClient) {
    // get volumes part of this CG
    List<Volume> volumes = ControllerUtils.getVolumesPartOfCG(cgURI, dbClient);
    boolean isVNX = storage.deviceIsType(Type.vnxblock);
    // check if replica of any of these volumes have replicationGroupInstance set
    for (Volume volume : volumes) {
        if (NullColumnValueGetter.isNotNullValue(volume.getReplicationGroupInstance())) {
            if (!isVNX) {
                // VNX doesn't have group clones/mirrors
                // clone
                URIQueryResultList cloneList = new URIQueryResultList();
                dbClient.queryByConstraint(ContainmentConstraint.Factory.getAssociatedSourceVolumeConstraint(volume.getId()), cloneList);
                Iterator<URI> iter = cloneList.iterator();
                while (iter.hasNext()) {
                    URI cloneID = iter.next();
                    Volume clone = dbClient.queryObject(Volume.class, cloneID);
                    if (clone != null && !clone.getInactive()) {
                        return true;
                    }
                }
                // mirror
                URIQueryResultList mirrorList = new URIQueryResultList();
                dbClient.queryByConstraint(ContainmentConstraint.Factory.getVolumeBlockMirrorConstraint(volume.getId()), mirrorList);
                Iterator<URI> itr = mirrorList.iterator();
                while (itr.hasNext()) {
                    URI mirrorID = itr.next();
                    BlockMirror mirror = dbClient.queryObject(BlockMirror.class, mirrorID);
                    if (mirror != null && !mirror.getInactive()) {
                        return true;
                    }
                }
            }
            // snapshot
            URIQueryResultList list = new URIQueryResultList();
            dbClient.queryByConstraint(ContainmentConstraint.Factory.getVolumeSnapshotConstraint(volume.getId()), list);
            Iterator<URI> it = list.iterator();
            while (it.hasNext()) {
                URI snapshotID = it.next();
                BlockSnapshot snapshot = dbClient.queryObject(BlockSnapshot.class, snapshotID);
                if (snapshot != null && !snapshot.getInactive()) {
                    return true;
                }
            }
            // snapshot session
            if (storage.checkIfVmax3()) {
                URIQueryResultList sessionList = new URIQueryResultList();
                dbClient.queryByConstraint(ContainmentConstraint.Factory.getBlockSnapshotSessionByConsistencyGroup(cgURI), sessionList);
                Iterator<URI> itr = sessionList.iterator();
                while (itr.hasNext()) {
                    URI sessionID = itr.next();
                    BlockSnapshotSession session = dbClient.queryObject(BlockSnapshotSession.class, sessionID);
                    if (session != null && !session.getInactive()) {
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
Also used : BlockMirror(com.emc.storageos.db.client.model.BlockMirror) BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) Volume(com.emc.storageos.db.client.model.Volume) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 23 with BlockSnapshot

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

the class ControllerUtils method getAutoTieringPolicyName.

public static String getAutoTieringPolicyName(URI uri, DbClient dbClient) {
    String policyName = Constants.NONE;
    if (URIUtil.isType(uri, Volume.class)) {
        Volume volume = dbClient.queryObject(Volume.class, uri);
        URI policyURI = volume.getAutoTieringPolicyUri();
        if (!NullColumnValueGetter.isNullURI(policyURI)) {
            AutoTieringPolicy policy = dbClient.queryObject(AutoTieringPolicy.class, policyURI);
            policyName = policy.getPolicyName();
        }
    } else if (URIUtil.isType(uri, BlockSnapshot.class)) {
        BlockSnapshot snapshot = dbClient.queryObject(BlockSnapshot.class, uri);
        StorageSystem storage = dbClient.queryObject(StorageSystem.class, snapshot.getStorageController());
        if (storage.checkIfVmax3()) {
            Volume volume = dbClient.queryObject(Volume.class, snapshot.getParent());
            URI policyURI = volume.getAutoTieringPolicyUri();
            if (!NullColumnValueGetter.isNullURI(policyURI)) {
                AutoTieringPolicy policy = dbClient.queryObject(AutoTieringPolicy.class, policyURI);
                policyName = policy.getPolicyName();
            }
        }
    } else if (URIUtil.isType(uri, BlockMirror.class)) {
        BlockMirror mirror = dbClient.queryObject(BlockMirror.class, uri);
        if (!NullColumnValueGetter.isNullURI(mirror.getAutoTieringPolicyUri())) {
            AutoTieringPolicy policy = dbClient.queryObject(AutoTieringPolicy.class, mirror.getAutoTieringPolicyUri());
            policyName = policy.getPolicyName();
        }
    }
    return policyName;
}
Also used : AutoTieringPolicy(com.emc.storageos.db.client.model.AutoTieringPolicy) BlockMirror(com.emc.storageos.db.client.model.BlockMirror) Volume(com.emc.storageos.db.client.model.Volume) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) URI(java.net.URI) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 24 with BlockSnapshot

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

the class RPBlockServiceApiImpl method getSnapshots.

/**
 * Get the snapshots for the passed volume.
 *
 * @param volume A reference to a volume.
 *
 * @return The snapshots for the passed volume.
 */
@Override
public List<BlockSnapshot> getSnapshots(Volume volume) {
    List<BlockSnapshot> snapshots = new ArrayList<BlockSnapshot>();
    // Get all the snapshots for this volume
    snapshots.addAll(super.getSnapshots(volume));
    // If this is a RP+VPLEX/MetroPoint volume get any local snaps for this volume as well,
    // we need to call out to VPLEX Api to get this information as the parent of these
    // snaps will be the backing volume.
    boolean vplex = RPHelper.isVPlexVolume(volume, _dbClient);
    if (vplex) {
        snapshots.addAll(vplexBlockServiceApiImpl.getSnapshots(volume));
    }
    // Get all bookmarks for the source copy if the passed in volume is an RP source volume
    if (volume.getPersonality().equalsIgnoreCase(Volume.PersonalityTypes.SOURCE.name())) {
        URI cgUri = volume.getConsistencyGroup();
        List<Volume> rpSourceVolumes = RPHelper.getCgSourceVolumes(cgUri, _dbClient);
        for (Volume rpSourceVolume : rpSourceVolumes) {
            // Get all RP bookmarks for this RP Volume. Since bookmarks are not assigned to any source volumes in the CG, we need to
            // query all the source volumes in the CG and fetch them.
            List<BlockSnapshot> allSnapshots = super.getSnapshots(rpSourceVolume);
            for (BlockSnapshot snapshot : allSnapshots) {
                if (BlockSnapshot.TechnologyType.RP.name().equalsIgnoreCase(snapshot.getTechnologyType())) {
                    snapshots.add(snapshot);
                }
            }
        }
    }
    return snapshots;
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) ArrayList(java.util.ArrayList) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Example 25 with BlockSnapshot

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

the class SRDFBlockServiceApiImpl method getSnapshotsForVolume.

/**
 * Get the snapshots for the passed volume only, do not retrieve any of the related snaps.
 *
 * @param volume A reference to a volume.
 *
 * @return The snapshots for the passed volume.
 */
public List<BlockSnapshot> getSnapshotsForVolume(Volume volume) {
    List<BlockSnapshot> snapshots = new ArrayList<BlockSnapshot>();
    boolean vplex = VPlexUtil.isVplexVolume(volume, _dbClient);
    if (vplex) {
        Volume snapshotSourceVolume = VPlexUtil.getVPLEXBackendVolume(volume, true, _dbClient, false);
        if (snapshotSourceVolume != null) {
            snapshots.addAll(super.getSnapshots(snapshotSourceVolume));
        }
    } else {
        snapshots.addAll(super.getSnapshots(volume));
    }
    return snapshots;
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) ArrayList(java.util.ArrayList)

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