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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations