Search in sources :

Example 11 with NamedVolumesList

use of com.emc.storageos.model.block.NamedVolumesList in project coprhd-controller by CoprHD.

the class BlockProvider method getVirtualArrayChangeCandidateVolumes.

@Asset("virtualArrayChangeVolume")
@AssetDependencies({ "project", "targetVirtualArray" })
public List<AssetOption> getVirtualArrayChangeCandidateVolumes(AssetOptionsContext ctx, URI projectId, URI varrayId) {
    ViPRCoreClient client = api(ctx);
    NamedVolumesList volumeList = client.blockVolumes().listVirtualArrayChangeCandidates(projectId, varrayId);
    List<VolumeRestRep> volumes = client.blockVolumes().getByRefs(volumeList.getVolumes());
    return createVolumeOptions(client, volumes);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) NamedVolumesList(com.emc.storageos.model.block.NamedVolumesList) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 12 with NamedVolumesList

use of com.emc.storageos.model.block.NamedVolumesList in project coprhd-controller by CoprHD.

the class BlockProvider method getApplicationSnapshotSessionCopySetsForRestore.

private Set<String> getApplicationSnapshotSessionCopySetsForRestore(AssetOptionsContext ctx, URI application) {
    Set<String> restoreCopySets = new HashSet<String>();
    Set<String> copySetNames = api(ctx).application().getVolumeGroupSnapsetSessionSets(application).getCopySets();
    boolean isRP = false;
    NamedVolumesList volsInApp = api(ctx).application().getVolumeByApplication(application);
    if (volsInApp != null && volsInApp.getVolumes() != null && !volsInApp.getVolumes().isEmpty()) {
        VolumeRestRep firstVol = api(ctx).blockVolumes().get(volsInApp.getVolumes().get(0).getId());
        isRP = BlockStorageUtils.isRPVolume(firstVol);
    }
    if (isRP) {
        List<VolumeRestRep> applicationVolumes = api(ctx).blockVolumes().getByRefs(api(ctx).application().getVolumeByApplication(application).getVolumes());
        Set<String> sourceRepGrpNames = new HashSet<String>();
        for (VolumeRestRep volume : applicationVolumes) {
            if (volume.getReplicationGroupInstance() != null && BlockStorageUtils.isRPSourceVolume(volume)) {
                sourceRepGrpNames.add(volume.getReplicationGroupInstance());
            }
        }
        for (String copySetName : copySetNames) {
            VolumeGroupCopySetParam input = new VolumeGroupCopySetParam();
            input.setCopySetName(copySetName);
            BlockSnapshotSessionList sessions = api(ctx).application().getVolumeGroupSnapshotSessionsByCopySet(application, input);
            if (sessions != null && sessions.getSnapSessionRelatedResourceList() != null && !sessions.getSnapSessionRelatedResourceList().isEmpty()) {
                BlockSnapshotSessionRestRep sessionRep = api(ctx).blockSnapshotSessions().get(sessions.getSnapSessionRelatedResourceList().get(0));
                if (sessionRep != null && sessionRep.getReplicationGroupInstance() != null && sourceRepGrpNames.contains(sessionRep.getReplicationGroupInstance())) {
                    restoreCopySets.add(copySetName);
                }
            }
        }
    } else {
        restoreCopySets.addAll(copySetNames);
    }
    return restoreCopySets;
}
Also used : BlockSnapshotSessionRestRep(com.emc.storageos.model.block.BlockSnapshotSessionRestRep) VolumeGroupCopySetParam(com.emc.storageos.model.application.VolumeGroupCopySetParam) NamedVolumesList(com.emc.storageos.model.block.NamedVolumesList) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) BlockSnapshotSessionList(com.emc.storageos.model.block.BlockSnapshotSessionList) HashSet(java.util.HashSet)

Example 13 with NamedVolumesList

use of com.emc.storageos.model.block.NamedVolumesList in project coprhd-controller by CoprHD.

the class BlockProvider method getApplicationSnapshotCopySetsForRestore.

private Set<String> getApplicationSnapshotCopySetsForRestore(AssetOptionsContext ctx, URI application) {
    Set<String> restoreCopySets = new HashSet<String>();
    Set<String> copySetNames = api(ctx).application().getVolumeGroupSnapshotSets(application).getCopySets();
    boolean isRP = false;
    NamedVolumesList volsInApp = api(ctx).application().getVolumeByApplication(application);
    if (volsInApp != null && volsInApp.getVolumes() != null && !volsInApp.getVolumes().isEmpty()) {
        VolumeRestRep firstVol = api(ctx).blockVolumes().get(volsInApp.getVolumes().get(0).getId());
        isRP = BlockStorageUtils.isRPVolume(firstVol);
    }
    if (isRP) {
        for (String copySetName : copySetNames) {
            VolumeGroupCopySetParam input = new VolumeGroupCopySetParam();
            input.setCopySetName(copySetName);
            SnapshotList snapshots = api(ctx).application().getVolumeGroupSnapshotsForSet(application, input);
            if (snapshots != null && snapshots.getSnapList() != null && !snapshots.getSnapList().isEmpty()) {
                BlockSnapshotRestRep snapRep = api(ctx).blockSnapshots().get(snapshots.getSnapList().get(0));
                if (snapRep != null) {
                    VolumeRestRep parentVol = api(ctx).blockVolumes().get(snapRep.getParent());
                    if (BlockStorageUtils.isRPSourceVolume(parentVol)) {
                        restoreCopySets.add(copySetName);
                    }
                }
            }
        }
    } else {
        restoreCopySets.addAll(copySetNames);
    }
    return restoreCopySets;
}
Also used : SnapshotList(com.emc.storageos.model.SnapshotList) BlockSnapshotRestRep(com.emc.storageos.model.block.BlockSnapshotRestRep) VolumeGroupCopySetParam(com.emc.storageos.model.application.VolumeGroupCopySetParam) NamedVolumesList(com.emc.storageos.model.block.NamedVolumesList) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) HashSet(java.util.HashSet)

Example 14 with NamedVolumesList

use of com.emc.storageos.model.block.NamedVolumesList in project coprhd-controller by CoprHD.

the class BlockProvider method getReplicationGroupsForApplicationFullCopy.

protected Set<String> getReplicationGroupsForApplicationFullCopy(ViPRCoreClient client, URI applicationId, String copySet) {
    Set<String> options = Sets.newHashSet();
    VolumeGroupCopySetParam input = new VolumeGroupCopySetParam();
    input.setCopySetName(copySet);
    NamedVolumesList fullCopies = client.application().getVolumeGroupFullCopiesForSet(applicationId, input);
    for (NamedRelatedResourceRep fullCopy : fullCopies.getVolumes()) {
        VolumeRestRep fullCopyRep = client.blockVolumes().get(fullCopy);
        if (fullCopyRep != null && fullCopyRep.getReplicationGroupInstance() != null) {
            options.add(fullCopyRep.getReplicationGroupInstance());
        }
    }
    return options;
}
Also used : VolumeGroupCopySetParam(com.emc.storageos.model.application.VolumeGroupCopySetParam) NamedVolumesList(com.emc.storageos.model.block.NamedVolumesList) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep)

Example 15 with NamedVolumesList

use of com.emc.storageos.model.block.NamedVolumesList in project coprhd-controller by CoprHD.

the class BlockConsistencyGroups method getFullCopies.

/**
 * List full copies for a consistency group
 * <p>
 * API Call: <tt>GET /block/consistency-groups/{id}/protection/full-copies</tt>
 *
 * @param consistencyGroupId
 *            the ID of the consistency group
 * @return The list of full copies for the consistency group
 */
public List<NamedRelatedResourceRep> getFullCopies(URI consistencyGroupId) {
    final String url = getIdUrl() + "/protection/full-copies";
    NamedVolumesList response = client.get(NamedVolumesList.class, url, consistencyGroupId);
    return defaultList(response.getVolumes());
}
Also used : NamedVolumesList(com.emc.storageos.model.block.NamedVolumesList)

Aggregations

NamedVolumesList (com.emc.storageos.model.block.NamedVolumesList)17 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)7 Volume (com.emc.storageos.db.client.model.Volume)6 URI (java.net.URI)6 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)5 Path (javax.ws.rs.Path)5 Produces (javax.ws.rs.Produces)5 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)4 GET (javax.ws.rs.GET)4 VolumeGroup (com.emc.storageos.db.client.model.VolumeGroup)3 VolumeGroupCopySetParam (com.emc.storageos.model.application.VolumeGroupCopySetParam)3 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)3 HashSet (java.util.HashSet)3 Asset (com.emc.sa.asset.annotation.Asset)2 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)2 SOURCE_TO_TARGET (com.emc.storageos.model.block.Copy.SyncDirection.SOURCE_TO_TARGET)2 CreateCloneOfApplication (com.emc.sa.service.vipr.application.tasks.CreateCloneOfApplication)1 CreateSnapshotForApplication (com.emc.sa.service.vipr.application.tasks.CreateSnapshotForApplication)1 WaitForTasks (com.emc.sa.service.vipr.tasks.WaitForTasks)1 MapVolume (com.emc.storageos.api.mapper.functions.MapVolume)1