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