Search in sources :

Example 16 with BlockSnapshot

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

the class ControllerUtils method getVolumeGroupSnapshots.

/**
 * Gets all snapshots for the given set name.
 */
public static List<BlockSnapshot> getVolumeGroupSnapshots(URI volumeGroupId, String snapsetLabel, DbClient dbClient) {
    List<BlockSnapshot> snapshots = new ArrayList<BlockSnapshot>();
    if (snapsetLabel != null) {
        URIQueryResultList list = new URIQueryResultList();
        dbClient.queryByConstraint(AlternateIdConstraint.Factory.getBlockSnapshotsBySnapsetLabel(snapsetLabel), list);
        Iterator<BlockSnapshot> iter = dbClient.queryIterativeObjects(BlockSnapshot.class, list);
        while (iter.hasNext()) {
            BlockSnapshot snapshot = iter.next();
            if (isSourceInVoumeGroup(snapshot, volumeGroupId, dbClient)) {
                snapshots.add(snapshot);
            }
        }
    }
    return snapshots;
}
Also used : BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 17 with BlockSnapshot

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

the class ControllerUtils method getSnapshotLabelsFromExistingSnaps.

public static Set<String> getSnapshotLabelsFromExistingSnaps(String repGroupName, BlockObject source, DbClient dbClient) {
    List<BlockSnapshot> snapshots = getSnapshotsPartOfReplicationGroup(repGroupName, source.getStorageController(), dbClient);
    Set<String> snapLables = new HashSet<>();
    if (!CollectionUtils.isEmpty(snapshots)) {
        for (BlockSnapshot snapshot : snapshots) {
            snapLables.add(String.format("%s-%s", snapshot.getSnapsetLabel(), source.getLabel()));
        }
    }
    return snapLables;
}
Also used : BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) HashSet(java.util.HashSet)

Example 18 with BlockSnapshot

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

the class ControllerUtils method getBlockSnapshotsBySnapsetLabelForProject.

/**
 * Utility method which will filter the snapshots from getBlockSnapshotsBySnapsetLabel query by the
 * snapshot's project
 *
 * @param snapshot
 * @param dbClient
 * @return
 */
public static List<BlockSnapshot> getBlockSnapshotsBySnapsetLabelForProject(BlockSnapshot snapshot, DbClient dbClient) {
    URIQueryResultList list = new URIQueryResultList();
    dbClient.queryByConstraint(AlternateIdConstraint.Factory.getBlockSnapshotsBySnapsetLabel(snapshot.getSnapsetLabel()), list);
    Iterator<BlockSnapshot> resultsIt = dbClient.queryIterativeObjects(BlockSnapshot.class, list);
    List<BlockSnapshot> snapshots = new ArrayList<BlockSnapshot>();
    while (resultsIt.hasNext()) {
        BlockSnapshot snap = resultsIt.next();
        if (snapshot.getProject() != null && snapshot.getProject().getURI().equals(snap.getProject().getURI())) {
            snapshots.add(snap);
        }
    }
    return snapshots;
}
Also used : BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 19 with BlockSnapshot

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

the class ControllerUtils method checkIfVolumeHasSnapshot.

public static boolean checkIfVolumeHasSnapshot(Volume volume, DbClient dbClient) {
    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()) {
            s_logger.debug("Volume {} has snapshot", volume.getId());
            return true;
        }
    }
    return false;
}
Also used : BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 20 with BlockSnapshot

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

the class ControllerUtils method getSnapshotForStorageReplicationGroup.

/*
     * For each storage system and RG, get one snapshot
     * 
     * @param snapshots List of snapshots
     * 
     * @return table with storage URI, replication group name, and snapshot
     */
public static Table<URI, String, BlockSnapshot> getSnapshotForStorageReplicationGroup(List<BlockSnapshot> snapshots) {
    Table<URI, String, BlockSnapshot> storageRgToSnapshot = HashBasedTable.create();
    for (BlockSnapshot snapshot : snapshots) {
        URI storage = snapshot.getStorageController();
        String rgName = snapshot.getReplicationGroupInstance();
        if (!storageRgToSnapshot.contains(storage, rgName)) {
            storageRgToSnapshot.put(storage, rgName, snapshot);
        }
    }
    return storageRgToSnapshot;
}
Also used : BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) URI(java.net.URI)

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