Search in sources :

Example 1 with BlockSnapshotSessionRestRep

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;
}
Also used : BlockSnapshotSessionRestRep(com.emc.storageos.model.block.BlockSnapshotSessionRestRep) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) VirtualArrayRelatedResourceRep(com.emc.storageos.model.VirtualArrayRelatedResourceRep) NamedURI(com.emc.storageos.db.client.model.NamedURI) StringSet(com.emc.storageos.db.client.model.StringSet) ArrayList(java.util.ArrayList) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 2 with BlockSnapshotSessionRestRep

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));
}
Also used : BlockSnapshotSessionRestRep(com.emc.storageos.model.block.BlockSnapshotSessionRestRep) ApplicationSnapshotSession(models.datatable.ApplicationSnapSessionDataTable.ApplicationSnapshotSession) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep)

Example 3 with BlockSnapshotSessionRestRep

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);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) BlockSnapshotSessionRestRep(com.emc.storageos.model.block.BlockSnapshotSessionRestRep) URI(java.net.URI)

Example 4 with BlockSnapshotSessionRestRep

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);
}
Also used : Task(com.emc.vipr.client.Task) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) BlockSnapshotSessionRestRep(com.emc.storageos.model.block.BlockSnapshotSessionRestRep)

Example 5 with BlockSnapshotSessionRestRep

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;
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) BlockSnapshotSessionRestRep(com.emc.storageos.model.block.BlockSnapshotSessionRestRep) BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) URI(java.net.URI)

Aggregations

BlockSnapshotSessionRestRep (com.emc.storageos.model.block.BlockSnapshotSessionRestRep)20 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)9 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)8 URI (java.net.URI)8 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)5 BlockSnapshotRestRep (com.emc.storageos.model.block.BlockSnapshotRestRep)5 ArrayList (java.util.ArrayList)5 VirtualArrayRelatedResourceRep (com.emc.storageos.model.VirtualArrayRelatedResourceRep)4 VolumeGroupCopySetParam (com.emc.storageos.model.application.VolumeGroupCopySetParam)4 BlockSnapshotSessionList (com.emc.storageos.model.block.BlockSnapshotSessionList)4 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)4 Asset (com.emc.sa.asset.annotation.Asset)3 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)3 DeactivateBlockSnapshotSession (com.emc.sa.service.vipr.block.tasks.DeactivateBlockSnapshotSession)2 AssetOption (com.emc.vipr.model.catalog.AssetOption)2 GetBlockSnapshotSession (com.emc.sa.service.vipr.application.tasks.GetBlockSnapshotSession)1 GetBlockSnapshotSessionList (com.emc.sa.service.vipr.application.tasks.GetBlockSnapshotSessionList)1 DeactivateBlockSnapshot (com.emc.sa.service.vipr.block.tasks.DeactivateBlockSnapshot)1 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 BlockSnapshotSession (com.emc.storageos.db.client.model.BlockSnapshotSession)1