Search in sources :

Example 61 with VolumeRestRep

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

the class BlockProvider method getBlockObjectLabelWithVarray.

private static String getBlockObjectLabelWithVarray(BlockObjectRestRep blockObject, Map<URI, VirtualArrayRestRep> varrayNames) {
    if (blockObject instanceof VolumeRestRep) {
        VolumeRestRep volume = (VolumeRestRep) blockObject;
        String varrayName = varrayNames.get(volume.getVirtualArray().getId()).getName();
        return getMessage("block.unexport.volume", volume.getName(), volume.getProvisionedCapacity(), varrayName, volume.getWwn());
    }
    return blockObject.getName();
}
Also used : VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep)

Example 62 with VolumeRestRep

use of com.emc.storageos.model.block.VolumeRestRep 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 63 with VolumeRestRep

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

the class BlockProvider method getApplicationVirtualArrays.

@Asset("applicationVirtualArray")
@AssetDependencies("application")
public List<AssetOption> getApplicationVirtualArrays(AssetOptionsContext ctx, URI applicationId) {
    final ViPRCoreClient client = api(ctx);
    List<NamedRelatedResourceRep> volList = client.application().listVolumes(applicationId);
    List<AssetOption> options = new ArrayList<AssetOption>();
    boolean isRP = false;
    URI sourceVarrayId = null;
    List<VolumeRestRep> allRPSourceVols = null;
    if (volList != null && !volList.isEmpty()) {
        VolumeRestRep vol = client.blockVolumes().get(volList.get(0));
        if (BlockProviderUtils.isVolumeRP(vol)) {
            isRP = true;
            allRPSourceVols = client.blockVolumes().getByRefs(volList, RecoverPointPersonalityFilter.SOURCE);
            if (allRPSourceVols != null && !allRPSourceVols.isEmpty()) {
                VolumeRestRep rpvol = allRPSourceVols.get(0);
                sourceVarrayId = rpvol.getVirtualArray().getId();
            }
        }
    } else {
        options.add(newAssetOption(URI.create("none"), "None"));
        return options;
    }
    // if the volumes are RP (vplex or not) add the RP targets as options
    if (isRP) {
        options.add(newAssetOption(sourceVarrayId, "protection.site.type.source"));
        Set<URI> targetVarrayIds = new HashSet<URI>();
        List<AssetOption> targetOptions = new ArrayList<AssetOption>();
        List<VolumeRestRep> allRPTargetVols = client.blockVolumes().getByRefs(volList, RecoverPointPersonalityFilter.TARGET);
        for (VolumeRestRep targetVol : allRPTargetVols) {
            targetVarrayIds.add(targetVol.getVirtualArray().getId());
        }
        List<VirtualArrayRestRep> targetVarrays = client.varrays().getByIds(targetVarrayIds);
        for (VirtualArrayRestRep targetVarray : targetVarrays) {
            targetOptions.add(newAssetOption(String.format("tgt:%s", targetVarray.getId().toString()), "protection.site.type.target", targetVarray.getName()));
        }
        // sort the targets
        AssetOptionsUtils.sortOptionsByLabel(targetOptions);
        options.addAll(targetOptions);
    }
    if (options.isEmpty()) {
        options.add(newAssetOption(URI.create("none"), "None"));
    }
    return options;
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) ArrayList(java.util.ArrayList) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) URI(java.net.URI) VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) HashSet(java.util.HashSet) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 64 with VolumeRestRep

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

the class BlockProvider method getVolumesWithoutConsistencyGroup.

@Asset("volumeWithoutConsistencyGroup")
@AssetDependencies("project")
public List<AssetOption> getVolumesWithoutConsistencyGroup(AssetOptionsContext ctx, URI project) {
    debug("getting volumes that don't belong to a consistency group (project=%s)", project);
    ViPRCoreClient client = api(ctx);
    List<VolumeRestRep> volumes = client.blockVolumes().findByProject(project);
    Map<URI, VolumeRestRep> volumeNames = getProjectVolumeNames(client, project);
    List<AssetOption> options = Lists.newArrayList();
    for (VolumeRestRep volume : volumes) {
        if (volume.getConsistencyGroup() == null) {
            options.add(createVolumeOption(client, null, 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 65 with VolumeRestRep

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

the class BlockProvider method getBlockVolumes.

@Asset("unassignedBlockVolume")
@AssetDependencies({ "host", "project", "blockStorageType" })
public List<AssetOption> getBlockVolumes(AssetOptionsContext ctx, URI hostOrClusterId, final URI projectId, String blockStorageType) {
    ViPRCoreClient client = api(ctx);
    Set<URI> exportedBlockResources = BlockProvider.getExportedVolumes(client, projectId, hostOrClusterId, null);
    UnexportedBlockResourceFilter<VolumeRestRep> unexportedFilter = new UnexportedBlockResourceFilter<VolumeRestRep>(exportedBlockResources);
    SourceTargetVolumesFilter sourceTargetVolumesFilter = new SourceTargetVolumesFilter();
    BlockVolumeBootVolumeFilter bootVolumeFilter = new BlockVolumeBootVolumeFilter();
    List<VolumeRestRep> volumes = client.blockVolumes().findByProject(projectId, unexportedFilter.and(sourceTargetVolumesFilter).and(bootVolumeFilter.not()));
    // get varray IDs for host/cluster
    List<VirtualArrayRestRep> varrays = new ArrayList<>();
    if (EXCLUSIVE_STORAGE_OPTION.key.equals(blockStorageType) && URIUtil.isType(hostOrClusterId, Host.class)) {
        varrays = client.varrays().findByConnectedHost(hostOrClusterId);
    } else if (SHARED_STORAGE_OPTION.key.equals(blockStorageType) && URIUtil.isType(hostOrClusterId, Cluster.class)) {
        varrays = client.varrays().findByConnectedCluster(hostOrClusterId);
    }
    List<URI> varrayIds = new ArrayList<>();
    for (VirtualArrayRestRep varray : varrays) {
        varrayIds.add(varray.getId());
    }
    // remove volumes not in hosts/cluster's varray
    Iterator<VolumeRestRep> itr = volumes.iterator();
    while (itr.hasNext()) {
        if (!varrayIds.contains(itr.next().getVirtualArray().getId())) {
            itr.remove();
        }
    }
    return createVolumeOptions(client, volumes);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) ArrayList(java.util.ArrayList) Host(com.emc.storageos.db.client.model.Host) SourceTargetVolumesFilter(com.emc.vipr.client.core.filters.SourceTargetVolumesFilter) URI(java.net.URI) BlockVolumeBootVolumeFilter(com.emc.vipr.client.core.filters.BlockVolumeBootVolumeFilter) VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) 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