use of com.emc.storageos.model.block.BlockSnapshotSessionRestRep in project coprhd-controller by CoprHD.
the class BlockMapper method map.
/**
* Maps a BlockSnapshotSession instance to its Rest representation.
*
* @param dbClient A reference to a database client.
* @param from An instance of BlockSnapshotSession.
*
* @return An instance of BlockSnapshotSessionRestRep
*/
public static BlockSnapshotSessionRestRep map(DbClient dbClient, BlockSnapshotSession from) {
if (from == null) {
return null;
}
BlockSnapshotSessionRestRep to = new BlockSnapshotSessionRestRep();
// Map base class fields.
mapDataObjectFields(from, to);
// Map snapshot session consistency group.
URI consistencyGroup = from.getConsistencyGroup();
if (consistencyGroup != null) {
to.setConsistencyGroup(toRelatedResource(ResourceTypeEnum.BLOCK_CONSISTENCY_GROUP, consistencyGroup));
}
// Map snapshot session parent i.e., the snapshot session source.
NamedURI parentNamedURI = from.getParent();
if (parentNamedURI != null) {
URI parentURI = parentNamedURI.getURI();
// It may be possible that the source for the snapshot
// session is a backend source volume for a VPLEX volume
// if we support creating snapshot sessions for VPLEX
// volumes backed by storage that supports snapshot sessions.
// In this case, the parent we want to reflect in the response
// is the VPLEX volume.
URIQueryResultList results = new URIQueryResultList();
dbClient.queryByConstraint(AlternateIdConstraint.Factory.getVolumeByAssociatedVolumesConstraint(parentURI.toString()), results);
Iterator<URI> resultsIter = results.iterator();
if (resultsIter.hasNext()) {
parentURI = resultsIter.next();
}
// volume for an array snapshot, which is a BlockSnapshot.
if (URIUtil.isType(parentURI, Volume.class)) {
to.setParent(toRelatedResource(ResourceTypeEnum.VOLUME, parentURI));
} else {
to.setParent(toRelatedResource(ResourceTypeEnum.BLOCK_SNAPSHOT, parentURI));
}
}
// Map project
NamedURI projectURI = from.getProject();
if (projectURI != null) {
to.setProject(toRelatedResource(ResourceTypeEnum.PROJECT, projectURI.getURI()));
}
// Map storage controller
URI storageURI = from.getStorageController();
if (storageURI != null) {
to.setStorageController(storageURI);
}
// Map linked targets.
StringSet linkedTargetIds = from.getLinkedTargets();
if ((linkedTargetIds != null) && (!linkedTargetIds.isEmpty())) {
List<RelatedResourceRep> linkedTargetReps = new ArrayList<RelatedResourceRep>();
for (String linkedTargetId : linkedTargetIds) {
URI linkedTargetURI = URI.create(linkedTargetId);
// Linked targets are instances of BlockSnapshot.
linkedTargetReps.add(toRelatedResource(ResourceTypeEnum.BLOCK_SNAPSHOT, linkedTargetURI));
}
to.setLinkedTargets(linkedTargetReps);
}
// Map session label.
to.setSessionLabel(from.getSessionLabel());
// Map replication group name.
to.setReplicationGroupInstance(from.getReplicationGroupInstance());
// Map session set name.
to.setSessionSetName(from.getSessionSetName());
return to;
}
use of com.emc.storageos.model.block.BlockSnapshotSessionRestRep in project coprhd-controller by CoprHD.
the class BlockApplications method getAssociatedSnapSessionJSON.
public static void getAssociatedSnapSessionJSON(String sessionLabel) {
String[] sessionSet = sessionLabel.split("~~~");
List<ApplicationSnapshotSession> sessionDetails = Lists.newArrayList();
List<NamedRelatedResourceRep> sessionSetDetails = AppSupportUtil.getVolumeGroupSnapshotSessionsByCopySet(sessionSet[0], sessionSet[1]);
for (NamedRelatedResourceRep snapSession : sessionSetDetails) {
BlockSnapshotSessionRestRep snapshotSession = BourneUtil.getViprClient().blockSnapshotSessions().get(snapSession.getId());
sessionDetails.add(new ApplicationSnapshotSession(snapshotSession));
}
renderJSON(DataTablesSupport.createJSON(sessionDetails, params));
}
use of com.emc.storageos.model.block.BlockSnapshotSessionRestRep in project coprhd-controller by CoprHD.
the class BlockSnapshotSessions method delete.
private static void delete(List<URI> ids, VolumeDeleteTypeEnum deleteType) {
if (ids != null) {
ViPRCoreClient client = BourneUtil.getViprClient();
for (URI id : ids) {
Tasks<BlockSnapshotSessionRestRep> task = client.blockSnapshotSessions().deactivate(id, deleteType);
}
flash.put("info", MessagesUtils.get("resources.snapshots.deactivate", ids.size()));
}
snapshotSessions(null);
}
use of com.emc.storageos.model.block.BlockSnapshotSessionRestRep in project coprhd-controller by CoprHD.
the class BlockSnapshotSessions method snapshotSessionDetails.
public static void snapshotSessionDetails(String snapshotSessionId) {
ViPRCoreClient client = BourneUtil.getViprClient();
AffectedResources.BlockSnapshotSessionDetails blockSnapshotSession = new AffectedResources.BlockSnapshotSessionDetails(uri(snapshotSessionId));
if (blockSnapshotSession.blockSnapshotSession == null) {
flash.error(MessagesUtils.get(UNKNOWN, snapshotSessionId));
snapshotSessions(null);
}
if (blockSnapshotSession.volume != null) {
AffectedResources.VolumeDetails volume = new AffectedResources.VolumeDetails(blockSnapshotSession.volume.getId());
renderArgs.put("volume", volume);
}
List<Task<BlockSnapshotSessionRestRep>> tasks = null;
if (blockSnapshotSession.blockSnapshotSession != null) {
Tasks<BlockSnapshotSessionRestRep> tasksResponse = client.blockSnapshotSessions().getTasks(blockSnapshotSession.blockSnapshotSession.getId());
tasks = tasksResponse.getTasks();
}
render(blockSnapshotSession, tasks);
}
use of com.emc.storageos.model.block.BlockSnapshotSessionRestRep in project coprhd-controller by CoprHD.
the class BlockSnapshotSessionsDataTable method fetch.
public static List<BlockSnapshotSession> fetch(URI projectId) {
if (projectId == null) {
return Collections.emptyList();
}
ViPRCoreClient client = getViprClient();
List<BlockSnapshotSessionRestRep> blockSnapshots = client.blockSnapshotSessions().findByProject(projectId);
Map<URI, VolumeRestRep> parentVolumes = getParentVolumes(blockSnapshots);
List<BlockSnapshotSession> results = Lists.newArrayList();
for (BlockSnapshotSessionRestRep blockSnapshot : blockSnapshots) {
BlockSnapshotSession snap = new BlockSnapshotSession(blockSnapshot);
// Get the parent volume of the snapshot
VolumeRestRep volume = parentVolumes.get(ResourceUtils.id(blockSnapshot.getParent()));
snap.volume = ResourceUtils.name(volume);
results.add(snap);
}
return results;
}
Aggregations