Search in sources :

Example 66 with VolumeRestRep

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

the class BlockProvider method getProjectBlockVolumes.

protected List<VolumeRestRep> getProjectBlockVolumes(ViPRCoreClient client, URI hostOrClusterId, URI project, boolean onlyMounted) {
    List<VolumeRestRep> volumes = Lists.newArrayList();
    // the list of host ids that the volume could be mounted to
    List<URI> hostIds = getHostIds(client, hostOrClusterId, onlyMounted);
    // get a list of all volumes and snapshots in the project
    List<VolumeRestRep> projectVolumes = client.blockVolumes().findByProject(project);
    // cycle through every volume in the project and add those that match
    for (VolumeRestRep volume : projectVolumes) {
        boolean isMounted = isMounted(hostIds, volume);
        if ((onlyMounted && isMounted) || (!onlyMounted && !isMounted)) {
            volumes.add(volume);
        }
    }
    return volumes;
}
Also used : VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) URI(java.net.URI)

Example 67 with VolumeRestRep

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

the class BlockProvider method getVolumeDetails.

/**
 * Gets the volume details for a collection of volumes.
 *
 * @param client the bourne client.
 * @param volumes the collection of volumes.
 * @return the volume details.
 */
protected static List<VolumeDetail> getVolumeDetails(ViPRCoreClient client, Collection<VolumeRestRep> volumes) {
    Set<URI> blockVirtualPoolIds = getBlockVirtualPoolIdsForVolumes(volumes);
    Map<URI, BlockVirtualPoolRestRep> virtualPoolMap = getBlockVirtualPools(client, blockVirtualPoolIds);
    List<VolumeDetail> details = Lists.newArrayList();
    for (VolumeRestRep volume : volumes) {
        BlockVirtualPoolRestRep virtualPool = virtualPoolMap.get(volume.getVirtualPool().getId());
        details.add(new VolumeDetail(volume, virtualPool));
    }
    return details;
}
Also used : BlockVirtualPoolRestRep(com.emc.storageos.model.vpool.BlockVirtualPoolRestRep) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) URI(java.net.URI)

Example 68 with VolumeRestRep

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

the class BlockProvider method getRpFailoverTargets.

protected List<AssetOption> getRpFailoverTargets(ViPRCoreClient client, VolumeRestRep volume) {
    Map<String, String> targetVolumes = Maps.newLinkedHashMap();
    URI protectionSetId = volume.getProtection().getRpRep().getProtectionSet().getId();
    ProtectionSetRestRep localProtectionSet = client.blockVolumes().getProtectionSet(volume.getId(), protectionSetId);
    String sourceSiteName = volume.getProtection().getRpRep().getInternalSiteName();
    CachedResources<VirtualArrayRestRep> virtualArrays = new CachedResources<VirtualArrayRestRep>(client.varrays());
    List<RelatedResourceRep> rpTargets = localProtectionSet.getVolumes();
    for (VolumeRestRep protectionSetVolume : client.blockVolumes().getByRefs(rpTargets, RecoverPointPersonalityFilter.TARGET)) {
        String targetSiteName = protectionSetVolume.getProtection().getRpRep().getInternalSiteName();
        boolean isLocal = StringUtils.equals(sourceSiteName, targetSiteName);
        String rpType = isLocal ? "local" : "remote";
        VirtualArrayRestRep virtualArray = virtualArrays.get(protectionSetVolume.getVirtualArray());
        String label = getMessage("recoverpoint.target", name(protectionSetVolume), rpType, name(virtualArray));
        targetVolumes.put(stringId(protectionSetVolume), label);
    }
    List<AssetOption> options = Lists.newArrayList();
    for (Map.Entry<String, String> entry : targetVolumes.entrySet()) {
        options.add(new AssetOption(entry.getKey(), entry.getValue()));
    }
    AssetOptionsUtils.sortOptionsByLabel(options);
    return options;
}
Also used : AssetOption(com.emc.vipr.model.catalog.AssetOption) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) VirtualArrayRelatedResourceRep(com.emc.storageos.model.VirtualArrayRelatedResourceRep) URI(java.net.URI) CachedResources(com.emc.vipr.client.core.util.CachedResources) ProtectionSetRestRep(com.emc.storageos.model.protection.ProtectionSetRestRep) VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) Map(java.util.Map) HashMap(java.util.HashMap)

Example 69 with VolumeRestRep

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

the class CreateBlockVolumeByName method executeTask.

@Override
public Task<VolumeRestRep> executeTask() throws Exception {
    VolumeCreate create = new VolumeCreate();
    create.setVpool(vpoolId);
    create.setVarray(varrayId);
    create.setProject(projectId);
    create.setSize(size);
    create.setConsistencyGroup(consistencyGroupId);
    create.setCount(1);
    create.setName(volumeName);
    create.setPortGroup(portGroupId);
    create.setComputeResource(computeResourceId);
    Tasks<VolumeRestRep> tasksForVolume = getClient().blockVolumes().create(create);
    if (tasksForVolume.getTasks().size() != 1) {
        throw new IllegalStateException("Invalid number of tasks returned from API: " + tasksForVolume.getTasks().size());
    }
    addOrderIdTag(tasksForVolume.firstTask().getTaskResource().getId());
    return tasksForVolume.firstTask();
}
Also used : VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) VolumeCreate(com.emc.storageos.model.block.VolumeCreate)

Example 70 with VolumeRestRep

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

the class CreateMultipleBlockVolumes method doExecute.

@Override
public Tasks<VolumeRestRep> doExecute() throws Exception {
    Set<String> errorMessages = Sets.newHashSet();
    Tasks<VolumeRestRep> tasks = null;
    for (CreateBlockVolumeHelper param : helpers) {
        String volumeSize = BlockStorageUtils.gbToVolumeSize(param.getSizeInGb());
        VolumeCreate create = new VolumeCreate();
        create.setVpool(param.getVirtualPool());
        create.setVarray(param.getVirtualArray());
        create.setProject(param.getProject());
        create.setName(param.getName());
        create.setSize(volumeSize);
        create.setComputeResource(param.getComputeResource());
        create.setPortGroup(param.getPortGroup());
        int numberOfVolumes = 1;
        if ((param.getCount() != null) && (param.getCount() > 1)) {
            numberOfVolumes = param.getCount();
        }
        create.setCount(numberOfVolumes);
        create.setConsistencyGroup(param.getConsistencyGroup());
        try {
            if (tasks == null) {
                tasks = getClient().blockVolumes().create(create);
            } else {
                tasks.getTasks().addAll(getClient().blockVolumes().create(create).getTasks());
            }
        } catch (ServiceErrorException ex) {
            errorMessages.add(ex.getDetailedMessage());
            logError(getMessage("CreateMultipleBlockVolumes.getTask.error", create.getName(), ex.getDetailedMessage()));
        }
    }
    if (tasks == null) {
        throw stateException("CreateMultipleBlockVolumes.illegalState.invalid", Joiner.on('\n').join(errorMessages));
    }
    return tasks;
}
Also used : VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) ServiceErrorException(com.emc.vipr.client.exceptions.ServiceErrorException) CreateBlockVolumeHelper(com.emc.sa.service.vipr.block.CreateBlockVolumeHelper) VolumeCreate(com.emc.storageos.model.block.VolumeCreate)

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