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;
}
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;
}
Aggregations