Search in sources :

Example 1 with VirtualPoolChangeRep

use of com.emc.storageos.model.vpool.VirtualPoolChangeRep in project coprhd-controller by CoprHD.

the class BlockProvider method listTargetVirtualPools.

/**
 * Returns a list of virtual pools where volume can be moved
 */
protected List<BlockVirtualPoolRestRep> listTargetVirtualPools(AssetOptionsContext ctx, URI volumeId, ResourceFilter<BlockVirtualPoolRestRep> filter) {
    ViPRCoreClient client = api(ctx);
    List<VirtualPoolChangeRep> vpoolChanges = client.blockVolumes().listVirtualPoolChangeCandidates(volumeId);
    List<URI> vpoolIds = Lists.newArrayList();
    for (VirtualPoolChangeRep change : vpoolChanges) {
        if (change.getAllowed()) {
            vpoolIds.add(change.getId());
        }
    }
    return client.blockVpools().getByIds(vpoolIds, filter);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) VirtualPoolChangeRep(com.emc.storageos.model.vpool.VirtualPoolChangeRep) URI(java.net.URI)

Example 2 with VirtualPoolChangeRep

use of com.emc.storageos.model.vpool.VirtualPoolChangeRep in project coprhd-controller by CoprHD.

the class BlockProvider method createVpoolChangeOptions.

protected List<AssetOption> createVpoolChangeOptions(String vpoolChangeOperation, List<VirtualPoolChangeRep> vpoolChanges) {
    List<AssetOption> options = Lists.newArrayList();
    List<AssetOption> available = Lists.newArrayList();
    List<AssetOption> wrongOperation = Lists.newArrayList();
    List<AssetOption> notAllowed = Lists.newArrayList();
    for (VirtualPoolChangeRep vpoolChange : vpoolChanges) {
        if (vpoolChange.getAllowed() && vpoolChange.getAllowedChangeOperations() != null) {
            for (StringHashMapEntry allowedChangeOperation : vpoolChange.getAllowedChangeOperations()) {
                String operation = allowedChangeOperation.getName();
                boolean isCorrectOperation = StringUtils.isNotBlank(operation) && operation.equalsIgnoreCase(vpoolChangeOperation);
                if (isCorrectOperation) {
                    available.add(new AssetOption(vpoolChange.getId(), vpoolChange.getName()));
                } else {
                    wrongOperation.add(new AssetOption(EMPTY_STRING, getMessage("block.virtualPool.vpoolChangeOperation", vpoolChange.getName(), getAllowedChangeOperationNames(vpoolChange.getAllowedChangeOperations()))));
                }
            }
        } else {
            notAllowed.add(new AssetOption(EMPTY_STRING, getMessage("block.virtualPool.vpoolChangeReason", vpoolChange.getName(), vpoolChange.getNotAllowedReason())));
        }
    }
    options.addAll(available);
    options.addAll(wrongOperation);
    options.addAll(notAllowed);
    return options;
}
Also used : AssetOption(com.emc.vipr.model.catalog.AssetOption) VirtualPoolChangeRep(com.emc.storageos.model.vpool.VirtualPoolChangeRep) StringHashMapEntry(com.emc.storageos.model.StringHashMapEntry)

Example 3 with VirtualPoolChangeRep

use of com.emc.storageos.model.vpool.VirtualPoolChangeRep in project coprhd-controller by CoprHD.

the class BlockProvider method getTargetVirtualPoolsForVpool.

@Asset("targetVirtualPool")
@AssetDependencies({ "project", "blockVirtualPool", "virtualPoolChangeOperation", "virtualPoolChangeVolumeWithSourceFilter", "displayJournals" })
public List<AssetOption> getTargetVirtualPoolsForVpool(AssetOptionsContext ctx, URI projectId, URI virtualPoolId, String vpoolChangeOperation, String filteredVolumes, String displayJournals) {
    List<URI> volumeIds = Lists.newArrayList();
    if (filteredVolumes != null && !filteredVolumes.isEmpty()) {
        // Best case we are passed in the volumes selected by the user
        // as comma delimited string so we do not have to load them from
        // the API.
        info("Filtered volumes selected by user: %s", filteredVolumes);
        List<String> parsedVolumeIds = TextUtils.parseCSV(filteredVolumes);
        for (String id : parsedVolumeIds) {
            volumeIds.add(uri(id));
        }
    } else {
        // Worst case we need to get the volumes from the API.
        info("Loading all volumes for vpool: %s", virtualPoolId.toString());
        List<VolumeRestRep> volumes = null;
        if (YES_VALUE.equals(displayJournals)) {
            volumes = listJournalVolumes(api(ctx), projectId, new VirtualPoolFilter(virtualPoolId));
        } else {
            volumes = listSourceVolumes(api(ctx), projectId, new VirtualPoolFilter(virtualPoolId));
        }
        for (VolumeRestRep volume : volumes) {
            volumeIds.add(volume.getId());
        }
    }
    if (CollectionUtils.isNotEmpty(volumeIds)) {
        BulkIdParam input = new BulkIdParam();
        input.setIds(volumeIds);
        List<VirtualPoolChangeRep> vpoolChanges = api(ctx).blockVpools().listVirtualPoolChangeCandidates(virtualPoolId, input);
        return createVpoolChangeOptions(vpoolChangeOperation, vpoolChanges);
    }
    return Collections.emptyList();
}
Also used : BulkIdParam(com.emc.storageos.model.BulkIdParam) VplexVolumeVirtualPoolFilter(com.emc.vipr.client.core.filters.VplexVolumeVirtualPoolFilter) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) URI(java.net.URI) VirtualPoolChangeRep(com.emc.storageos.model.vpool.VirtualPoolChangeRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Aggregations

VirtualPoolChangeRep (com.emc.storageos.model.vpool.VirtualPoolChangeRep)3 URI (java.net.URI)2 Asset (com.emc.sa.asset.annotation.Asset)1 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)1 BulkIdParam (com.emc.storageos.model.BulkIdParam)1 StringHashMapEntry (com.emc.storageos.model.StringHashMapEntry)1 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)1 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)1 VplexVolumeVirtualPoolFilter (com.emc.vipr.client.core.filters.VplexVolumeVirtualPoolFilter)1 AssetOption (com.emc.vipr.model.catalog.AssetOption)1