use of com.emc.storageos.model.block.BlockSnapshotSessionRestRep in project coprhd-controller by CoprHD.
the class BlockVolumes method unlinkTargetSnapshot.
public static void unlinkTargetSnapshot(String sessionId, String volumeId, Boolean deleteOption) {
ViPRCoreClient client = BourneUtil.getViprClient();
SnapshotSessionUnlinkTargetsParam sessionTargets = new SnapshotSessionUnlinkTargetsParam();
List<SnapshotSessionUnlinkTargetParam> targetLists = Lists.newArrayList();
List<RelatedResourceRep> targets = client.blockSnapshotSessions().get(uri(sessionId)).getLinkedTarget();
List<BlockSnapshotRestRep> snapshots = client.blockSnapshots().getByRefs(targets);
for (BlockSnapshotRestRep snap : snapshots) {
SnapshotSessionUnlinkTargetParam targetList = new SnapshotSessionUnlinkTargetParam();
targetList.setId(snap.getId());
targetList.setDeleteTarget(deleteOption);
targetLists.add(targetList);
}
if (!targetLists.isEmpty()) {
sessionTargets.setLinkedTargets(targetLists);
Task<BlockSnapshotSessionRestRep> tasks = client.blockSnapshotSessions().unlinkTargets(uri(sessionId), sessionTargets);
flash.put("info", MessagesUtils.get("resources.snapshot.session.unlink.success", sessionId));
} else {
flash.error(MessagesUtils.get(NOTARGET, sessionId));
}
volume(volumeId, null);
}
use of com.emc.storageos.model.block.BlockSnapshotSessionRestRep in project coprhd-controller by CoprHD.
the class BlockVolumes method volumeSnapshotSessions.
public static void volumeSnapshotSessions(String volumeId) {
ViPRCoreClient client = BourneUtil.getViprClient();
VolumeRestRep volume = client.blockVolumes().get(uri(volumeId));
List<BlockSnapshotSessionRestRep> snapshotSessions = Lists.newArrayList();
if (volume.getConsistencyGroup() != null) {
URI consistencygroup = volume.getConsistencyGroup().getId();
List<NamedRelatedResourceRep> cgSessions = client.blockConsistencyGroups().getSnapshotSessions(consistencygroup);
snapshotSessions = client.blockSnapshotSessions().getByRefs(cgSessions);
} else {
List<NamedRelatedResourceRep> refs = client.blockSnapshotSessions().listByVolume(uri(volumeId));
snapshotSessions = client.blockSnapshotSessions().getByRefs(refs);
}
render(snapshotSessions, volumeId);
}
use of com.emc.storageos.model.block.BlockSnapshotSessionRestRep in project coprhd-controller by CoprHD.
the class BlockProvider method constructSnapshotWithSnapshotSessionOptions.
protected List<AssetOption> constructSnapshotWithSnapshotSessionOptions(List<BlockSnapshotRestRep> snapshots, List<BlockSnapshotSessionRestRep> snapshotSessions) {
List<AssetOption> options = Lists.newArrayList();
// Create a map of linked target URIs to snapshot session names for convenience when creating
// the option labels.
Map<URI, String> linkedSnapshotToSnapshotSessionMap = new HashMap<URI, String>();
for (BlockSnapshotSessionRestRep snapshotSession : snapshotSessions) {
for (RelatedResourceRep linkedTarget : snapshotSession.getLinkedTarget()) {
linkedSnapshotToSnapshotSessionMap.put(linkedTarget.getId(), snapshotSession.getName());
}
}
for (BlockSnapshotRestRep snapshot : snapshots) {
// Ignore RP Bookmarks for snapshot session options
boolean isRPSnapshot = (snapshot.getTechnologyType() != null && snapshot.getTechnologyType().equalsIgnoreCase(RECOVERPOINT_BOOKMARK_SNAPSHOT_TYPE_VALUE));
boolean validSnapshotOption = snapshot.getTechnologyType() == null || !isRPSnapshot;
if (validSnapshotOption) {
options.add(new AssetOption(snapshot.getId(), getBlockSnapshotLinkedLabel(snapshot, linkedSnapshotToSnapshotSessionMap)));
}
}
AssetOptionsUtils.sortOptionsByLabel(options);
return options;
}
use of com.emc.storageos.model.block.BlockSnapshotSessionRestRep in project coprhd-controller by CoprHD.
the class BlockProvider method getLinkedSnapshotsForSnapshotSessionVolume.
@Asset("linkedSnapshotsForVolume")
@AssetDependencies({ "snapshotSessionBlockVolume", "blockVolumeOrConsistencyType" })
public List<AssetOption> getLinkedSnapshotsForSnapshotSessionVolume(AssetOptionsContext ctx, URI volumeOrCGId, String volumeOrConsistencyType) {
if (!checkTypeConsistency(volumeOrCGId, volumeOrConsistencyType)) {
warn("Inconsistent types, %s and %s, return empty results", volumeOrCGId, volumeOrConsistencyType);
return new ArrayList<AssetOption>();
}
List<BlockSnapshotRestRep> snapshots = new ArrayList<BlockSnapshotRestRep>();
List<BlockSnapshotSessionRestRep> snapshotSessions = new ArrayList<BlockSnapshotSessionRestRep>();
final ViPRCoreClient client = api(ctx);
if (isVolumeType(volumeOrConsistencyType)) {
snapshots = client.blockSnapshots().getByVolume(volumeOrCGId, new DefaultResourceFilter<BlockSnapshotRestRep>());
snapshotSessions = client.blockSnapshotSessions().getByVolume(volumeOrCGId, new DefaultResourceFilter<BlockSnapshotSessionRestRep>());
} else {
snapshots = client.blockSnapshots().getByConsistencyGroup(volumeOrCGId, new DefaultResourceFilter<BlockSnapshotRestRep>());
snapshotSessions = client.blockSnapshotSessions().getByConsistencyGroup(volumeOrCGId, new DefaultResourceFilter<BlockSnapshotSessionRestRep>());
}
return constructSnapshotWithSnapshotSessionOptions(snapshots, snapshotSessions);
}
use of com.emc.storageos.model.block.BlockSnapshotSessionRestRep in project coprhd-controller by CoprHD.
the class BlockProvider method getVolumeSnapshotSessionOptionsForProject.
/**
* get single volume snapshot sessions for a project
* @param ctx
* @param project
* @return
*/
private List<AssetOption> getVolumeSnapshotSessionOptionsForProject(AssetOptionsContext ctx, URI project) {
final ViPRCoreClient client = api(ctx);
List<BlockSnapshotSessionRestRep> snapshotSessions = client.blockSnapshotSessions().findByProject(project);
List<BlockSnapshotSessionRestRep> singleVolumeSnapshotSessions = new ArrayList<BlockSnapshotSessionRestRep>();
for (BlockSnapshotSessionRestRep snapshotSession : snapshotSessions) {
if (snapshotSession.getReplicationGroupInstance() == null) {
singleVolumeSnapshotSessions.add(snapshotSession);
}
}
return constructSnapshotSessionOptions(client, project, singleVolumeSnapshotSessions);
}
Aggregations