Search in sources :

Example 56 with VolumeRestRep

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

the class BlockStorageUtils method deactivateVolumes.

public static void deactivateVolumes(List<URI> volumeIds, VolumeDeleteTypeEnum type) {
    if (CollectionUtils.isNotEmpty(volumeIds)) {
        Tasks<VolumeRestRep> tasks = execute(new DeactivateVolumes(volumeIds, type));
        addAffectedResources(tasks);
    }
}
Also used : DeactivateVolumes(com.emc.sa.service.vipr.block.tasks.DeactivateVolumes) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep)

Example 57 with VolumeRestRep

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

the class BlockStorageUtils method expandVolume.

public static void expandVolume(URI volumeId, double newSizeInGB) {
    String newSize = gbToVolumeSize(newSizeInGB);
    Task<VolumeRestRep> task = execute(new ExpandVolume(volumeId, newSize));
    addAffectedResource(task);
}
Also used : ExpandVolume(com.emc.sa.service.vipr.block.tasks.ExpandVolume) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep)

Example 58 with VolumeRestRep

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

the class BlockProvider method getLocalMirrorBlockVolumes.

@Asset("localMirrorBlockVolume")
@AssetDependencies({ "project" })
public List<AssetOption> getLocalMirrorBlockVolumes(AssetOptionsContext context, URI project) {
    final ViPRCoreClient client = api(context);
    List<VolumeRestRep> volumes = listVolumes(client, project);
    List<VolumeDetail> volumeDetails = getVolumeDetails(client, volumes);
    Map<URI, VolumeRestRep> volumeNames = getProjectVolumeNames(client, project);
    List<AssetOption> options = Lists.newArrayList();
    for (VolumeDetail detail : volumeDetails) {
        if (isLocalMirrorSupported(detail.vpool)) {
            options.add(createVolumeOption(client, null, detail.volume, volumeNames));
        }
    }
    return options;
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) URI(java.net.URI) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 59 with VolumeRestRep

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

the class BlockProvider method groupFullCopyByApplicationSubGroup.

private Map<String, List<VolumeRestRep>> groupFullCopyByApplicationSubGroup(AssetOptionsContext ctx, List<VolumeRestRep> vols) {
    final ViPRCoreClient client = api(ctx);
    Map<String, List<VolumeRestRep>> grouped = new HashMap<String, List<VolumeRestRep>>();
    Set<RelatedResourceRep> parentVolIds = new HashSet<RelatedResourceRep>();
    for (VolumeRestRep vol : vols) {
        if (vol != null && vol.getProtection() != null && vol.getProtection().getFullCopyRep() != null && vol.getProtection().getFullCopyRep().getAssociatedSourceVolume() != null) {
            parentVolIds.add(vol.getProtection().getFullCopyRep().getAssociatedSourceVolume());
        }
    }
    List<VolumeRestRep> parentVolumes = client.blockVolumes().getByRefs(parentVolIds);
    if (parentVolumes != null && !parentVolumes.isEmpty()) {
        for (VolumeRestRep vol : parentVolumes) {
            if (grouped.get(vol.getReplicationGroupInstance()) == null) {
                grouped.put(vol.getReplicationGroupInstance(), new ArrayList<VolumeRestRep>());
            }
            grouped.get(vol.getReplicationGroupInstance()).add(vol);
        }
    }
    return grouped;
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) VirtualArrayRelatedResourceRep(com.emc.storageos.model.VirtualArrayRelatedResourceRep) HashMap(java.util.HashMap) StoragePortGroupRestRepList(com.emc.storageos.model.portgroup.StoragePortGroupRestRepList) BlockSnapshotSessionList(com.emc.storageos.model.block.BlockSnapshotSessionList) StoragePortList(com.emc.storageos.model.ports.StoragePortList) ArrayList(java.util.ArrayList) VolumeGroupList(com.emc.storageos.model.application.VolumeGroupList) List(java.util.List) NamedVolumesList(com.emc.storageos.model.block.NamedVolumesList) SnapshotList(com.emc.storageos.model.SnapshotList) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) HashSet(java.util.HashSet)

Example 60 with VolumeRestRep

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

the class BlockProvider method getProtectedVolumes.

@Asset("protectedBlockVolume")
@AssetDependencies({ "project", "blockVolumeOrConsistencyType" })
public List<AssetOption> getProtectedVolumes(AssetOptionsContext ctx, URI project, String volumeOrConsistencyType) {
    ViPRCoreClient client = api(ctx);
    if (isVolumeType(volumeOrConsistencyType)) {
        debug("getting protected volumes (project=%s)", project);
        // Allow recoverpoint or SRDF sources
        ResourceFilter<VolumeRestRep> filter = RecoverPointPersonalityFilter.SOURCE.or(new SRDFSourceFilter());
        List<VolumeRestRep> volumes = client.blockVolumes().findByProject(project, filter);
        // We need to filter out SRDF Metro volumes as they are not eligible for FAILOVER or SWAP
        List<VolumeRestRep> filteredVols = new ArrayList<>();
        for (VolumeRestRep currentVolume : volumes) {
            ProtectionRestRep protection = currentVolume.getProtection();
            if (protection != null && protection.getSrdfRep() != null && protection.getSrdfRep().getSRDFTargetVolumes() != null && !protection.getSrdfRep().getSRDFTargetVolumes().isEmpty()) {
                for (VolumeRestRep srdfTarget : client.blockVolumes().getByRefs(protection.getSrdfRep().getSRDFTargetVolumes(), new SRDFTargetFilter())) {
                    SRDFRestRep srdf = (srdfTarget.getProtection() != null) ? srdfTarget.getProtection().getSrdfRep() : null;
                    if (srdf != null && (srdf.getAssociatedSourceVolume() != null) && (srdf.getSrdfCopyMode() != null) && (!ACTIVE.equalsIgnoreCase(srdf.getSrdfCopyMode()))) {
                        filteredVols.add(currentVolume);
                        break;
                    }
                }
            } else {
                // Add the volume as before
                filteredVols.add(currentVolume);
            }
        }
        return createVolumeOptions(client, filteredVols);
    } else {
        debug("getting protected consistency groups (project=%s)", project);
        // Allow recoverpoint or SRDF sources
        ResourceFilter<BlockConsistencyGroupRestRep> filter = new ConsistencyGroupFilter(BlockConsistencyGroup.Types.RP.name(), false).or(new ConsistencyGroupFilter(BlockConsistencyGroup.Types.SRDF.name(), false));
        List<BlockConsistencyGroupRestRep> consistencyGroups = client.blockConsistencyGroups().search().byProject(project).filter(filter).run();
        // We need to filter out SRDF Metro volumes as they are not eligible for FAILOVER or SWAP
        List<BlockConsistencyGroupRestRep> filteredCgs = new ArrayList<>();
        for (BlockConsistencyGroupRestRep cg : consistencyGroups) {
            // Get SRDF source volumes
            if (cg.getTypes().contains(BlockConsistencyGroup.Types.SRDF.name())) {
                List<VolumeRestRep> srcVolumes = client.blockVolumes().getByRefs(cg.getVolumes(), new SRDFSourceFilter());
                if (srcVolumes != null && !srcVolumes.isEmpty()) {
                    // Get the first source volume and obtain its target references
                    VolumeRestRep srcVolume = srcVolumes.get(0);
                    for (VolumeRestRep srdfTarget : client.blockVolumes().getByRefs(srcVolume.getProtection().getSrdfRep().getSRDFTargetVolumes(), new SRDFTargetFilter())) {
                        SRDFRestRep srdf = (srdfTarget.getProtection() != null) ? srdfTarget.getProtection().getSrdfRep() : null;
                        if (srdf != null && (srdf.getAssociatedSourceVolume() != null) && (srdf.getSrdfCopyMode() != null) && (!ACTIVE.equalsIgnoreCase(srdf.getSrdfCopyMode()))) {
                            filteredCgs.add(cg);
                            break;
                        }
                    }
                }
            } else {
                // Add the cg as before
                filteredCgs.add(cg);
            }
        }
        return createBaseResourceOptions(filteredCgs);
    }
}
Also used : SRDFSourceFilter(com.emc.vipr.client.core.filters.SRDFSourceFilter) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) BlockConsistencyGroupRestRep(com.emc.storageos.model.block.BlockConsistencyGroupRestRep) SRDFRestRep(com.emc.storageos.model.block.VolumeRestRep.SRDFRestRep) ArrayList(java.util.ArrayList) ProtectionRestRep(com.emc.storageos.model.block.VolumeRestRep.ProtectionRestRep) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) SRDFTargetFilter(com.emc.vipr.client.core.filters.SRDFTargetFilter) ConsistencyGroupFilter(com.emc.vipr.client.core.filters.ConsistencyGroupFilter) BlockVolumeConsistencyGroupFilter(com.emc.vipr.client.core.filters.BlockVolumeConsistencyGroupFilter) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Aggregations

VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)136 URI (java.net.URI)74 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)49 Asset (com.emc.sa.asset.annotation.Asset)35 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)35 ArrayList (java.util.ArrayList)25 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)23 AssetOption (com.emc.vipr.model.catalog.AssetOption)20 BlockSnapshotRestRep (com.emc.storageos.model.block.BlockSnapshotRestRep)13 HashSet (java.util.HashSet)13 UnManagedVolumeRestRep (com.emc.storageos.model.block.UnManagedVolumeRestRep)12 Test (org.junit.Test)12 NamedVolumesList (com.emc.storageos.model.block.NamedVolumesList)11 BlockConsistencyGroupRestRep (com.emc.storageos.model.block.BlockConsistencyGroupRestRep)10 VirtualArrayRelatedResourceRep (com.emc.storageos.model.VirtualArrayRelatedResourceRep)9 BlockObjectRestRep (com.emc.storageos.model.block.BlockObjectRestRep)8 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)7 VolumeCreate (com.emc.storageos.model.block.VolumeCreate)7 List (java.util.List)7 SnapshotList (com.emc.storageos.model.SnapshotList)6