Search in sources :

Example 1 with FileMirrorRecommendation

use of com.emc.storageos.api.service.impl.placement.FileMirrorRecommendation in project coprhd-controller by CoprHD.

the class FileMirrorServiceApiImpl method prepareFileSystems.

/**
 * Prepare the source and target filesystems
 *
 * @param param
 * @param task
 * @param taskList
 * @param project
 * @param varray
 * @param vpool
 * @param recommendations
 * @param cosCapabilities
 * @param createInactive
 * @return
 */
public List<FileShare> prepareFileSystems(FileSystemParam param, String task, TaskList taskList, Project project, TenantOrg tenantOrg, DataObject.Flag[] flags, VirtualArray varray, VirtualPool vpool, List<Recommendation> recommendations, VirtualPoolCapabilityValuesWrapper cosCapabilities, Boolean createInactive) {
    List<FileShare> preparedFileSystems = new ArrayList<>();
    Iterator<Recommendation> recommendationsIter = recommendations.iterator();
    while (recommendationsIter.hasNext()) {
        FileMirrorRecommendation recommendation = (FileMirrorRecommendation) recommendationsIter.next();
        // If id is already set in recommendation, do not prepare the fileSystem (fileSystem already exists)
        if (recommendation.getId() != null) {
            continue;
        }
        // Get the source file share!!
        FileShare sourceFileShare = getPrecreatedFile(taskList, param.getLabel());
        if (!cosCapabilities.createMirrorExistingFileSystem()) {
            // Set the recommendation only for source file systems which are not meant for vpool change!!
            _log.info(String.format("createFileSystem --- FileShare: %1$s, StoragePool: %2$s, StorageSystem: %3$s", sourceFileShare.getId(), recommendation.getSourceStoragePool(), recommendation.getSourceStorageSystem()));
            validateFileSystem(recommendation, sourceFileShare);
        }
        // set the source mirror recommendations
        setFileMirrorRecommendation(recommendation, vpool, varray, false, false, sourceFileShare);
        FileShare targetFileShare = null;
        StringBuilder fileLabelBuilder = null;
        VirtualPool targetVpool = vpool;
        String targetFsPrefix = sourceFileShare.getName();
        if (cosCapabilities.getFileTargetCopyName() != null && !cosCapabilities.getFileTargetCopyName().isEmpty()) {
            targetFsPrefix = cosCapabilities.getFileTargetCopyName();
        }
        if (FileReplicationType.LOCAL.name().equalsIgnoreCase(cosCapabilities.getFileReplicationType())) {
            // Stripping out the special characters like ; /-+!@#$%^&())";:[]{}\ | but allow underscore character _
            String varrayName = varray.getLabel().replaceAll("[^\\dA-Za-z\\_]", "");
            fileLabelBuilder = new StringBuilder(targetFsPrefix).append("-localTarget");
            _log.info("Target file system name {}", fileLabelBuilder.toString());
            targetFileShare = prepareEmptyFileSystem(fileLabelBuilder.toString(), sourceFileShare.getCapacity(), project, recommendation, tenantOrg, varray, vpool, targetVpool, flags, task);
            // Set target file recommendations to target file system!!!
            setFileMirrorRecommendation(recommendation, vpool, varray, true, false, targetFileShare);
            // Update the source and target relationship!!
            setMirrorFileShareAttributes(sourceFileShare, targetFileShare);
            preparedFileSystems.add(sourceFileShare);
            preparedFileSystems.add(targetFileShare);
        } else {
            // Source file system!!
            preparedFileSystems.add(sourceFileShare);
            List<VirtualArray> virtualArrayTargets = new ArrayList<VirtualArray>();
            if (cosCapabilities.getFileReplicationTargetVArrays() != null & !cosCapabilities.getFileReplicationTargetVArrays().isEmpty()) {
                for (String strVarray : cosCapabilities.getFileReplicationTargetVArrays()) {
                    virtualArrayTargets.add(_dbClient.queryObject(VirtualArray.class, URI.create(strVarray)));
                }
            }
            for (VirtualArray targetVArray : virtualArrayTargets) {
                if (cosCapabilities.getFileReplicationTargetVPool() != null) {
                    targetVpool = _dbClient.queryObject(VirtualPool.class, cosCapabilities.getFileReplicationTargetVPool());
                } else {
                    targetVpool = vpool;
                }
                // Stripping out the special characters like ; /-+!@#$%^&())";:[]{}\ | but allow underscore character _
                String varrayName = targetVArray.getLabel().replaceAll("[^\\dA-Za-z\\_]", "");
                fileLabelBuilder = new StringBuilder(targetFsPrefix).append("-target");
                _log.info("Target file system name {}", fileLabelBuilder.toString());
                targetFileShare = prepareEmptyFileSystem(fileLabelBuilder.toString(), sourceFileShare.getCapacity(), project, recommendation, tenantOrg, targetVArray, vpool, targetVpool, flags, task);
                // Set target file recommendations to target file system!!!
                setFileMirrorRecommendation(recommendation, targetVpool, targetVArray, true, false, targetFileShare);
                // Update the source and target relationship!!
                setMirrorFileShareAttributes(sourceFileShare, targetFileShare);
                preparedFileSystems.add(targetFileShare);
            }
        }
    }
    return preparedFileSystems;
}
Also used : VirtualArray(com.emc.storageos.db.client.model.VirtualArray) ArrayList(java.util.ArrayList) FileMirrorRecommendation(com.emc.storageos.api.service.impl.placement.FileMirrorRecommendation) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) FileShare(com.emc.storageos.db.client.model.FileShare) FileMirrorRecommendation(com.emc.storageos.api.service.impl.placement.FileMirrorRecommendation) Recommendation(com.emc.storageos.volumecontroller.Recommendation)

Example 2 with FileMirrorRecommendation

use of com.emc.storageos.api.service.impl.placement.FileMirrorRecommendation in project coprhd-controller by CoprHD.

the class FilePolicyService method convertRecommendationsToStorageSystemAssociations.

private List<FileStorageSystemAssociation> convertRecommendationsToStorageSystemAssociations(List<FileRecommendation> recs, String appliedAt, URI vPoolURI, URI projectURI) {
    List<FileStorageSystemAssociation> associations = new ArrayList<FileStorageSystemAssociation>();
    for (FileRecommendation rec : recs) {
        FileMirrorRecommendation mirrorRec = (FileMirrorRecommendation) rec;
        FileStorageSystemAssociation association = new FileStorageSystemAssociation();
        association.setSourceSystem(mirrorRec.getSourceStorageSystem());
        association.setSourceVNAS(mirrorRec.getvNAS());
        if (appliedAt.equalsIgnoreCase(FilePolicyApplyLevel.vpool.name())) {
            association.setAppliedAtResource(vPoolURI);
        } else if (appliedAt.equalsIgnoreCase(FilePolicyApplyLevel.project.name())) {
            association.setProjectvPool(vPoolURI);
            association.setAppliedAtResource(projectURI);
        }
        Map<URI, Target> virtualArrayTargetMap = mirrorRec.getVirtualArrayTargetMap();
        // Getting the first target because we support one-to-one replication now.
        URI targetVArray = virtualArrayTargetMap.entrySet().iterator().next().getKey();
        Target target = virtualArrayTargetMap.entrySet().iterator().next().getValue();
        URI targetStorageDevice = target.getTargetStorageDevice();
        URI targetVNasURI = target.getTargetvNASURI();
        TargetAssociation targetAssociation = new TargetAssociation();
        targetAssociation.setStorageSystemURI(targetStorageDevice);
        targetAssociation.setvArrayURI(targetVArray);
        targetAssociation.setvNASURI(targetVNasURI);
        association.addTargetAssociation(targetAssociation);
        associations.add(association);
    }
    return associations;
}
Also used : FileStorageSystemAssociation(com.emc.storageos.fileorchestrationcontroller.FileStorageSystemAssociation) Target(com.emc.storageos.api.service.impl.placement.FileMirrorRecommendation.Target) FileRecommendation(com.emc.storageos.api.service.impl.placement.FileRecommendation) TargetAssociation(com.emc.storageos.fileorchestrationcontroller.FileStorageSystemAssociation.TargetAssociation) ArrayList(java.util.ArrayList) FileMirrorRecommendation(com.emc.storageos.api.service.impl.placement.FileMirrorRecommendation) URI(java.net.URI)

Aggregations

FileMirrorRecommendation (com.emc.storageos.api.service.impl.placement.FileMirrorRecommendation)2 ArrayList (java.util.ArrayList)2 Target (com.emc.storageos.api.service.impl.placement.FileMirrorRecommendation.Target)1 FileRecommendation (com.emc.storageos.api.service.impl.placement.FileRecommendation)1 FileShare (com.emc.storageos.db.client.model.FileShare)1 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)1 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)1 FileStorageSystemAssociation (com.emc.storageos.fileorchestrationcontroller.FileStorageSystemAssociation)1 TargetAssociation (com.emc.storageos.fileorchestrationcontroller.FileStorageSystemAssociation.TargetAssociation)1 Recommendation (com.emc.storageos.volumecontroller.Recommendation)1 URI (java.net.URI)1