use of com.emc.storageos.db.client.model.FileShare 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.db.client.model.FileShare in project coprhd-controller by CoprHD.
the class FileMirrorServiceApiImpl method createTargetsForExistingSource.
@Override
public TaskResourceRep createTargetsForExistingSource(FileShare fs, Project project, VirtualPool vpool, VirtualArray varray, TaskList taskList, String task, List<Recommendation> recommendations, VirtualPoolCapabilityValuesWrapper vpoolCapabilities) throws InternalException {
List<FileShare> fileList = null;
List<FileShare> fileShares = new ArrayList<FileShare>();
FileSystemParam fsParams = new FileSystemParam();
fsParams.setFsId(fs.getId().toString());
fsParams.setLabel(fs.getLabel());
fsParams.setVarray(fs.getVirtualArray());
fsParams.setVpool(fs.getVirtualPool());
TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, project.getTenantOrg().getURI());
// Prepare the FileShares
fileList = prepareFileSystems(fsParams, task, taskList, project, tenant, null, varray, vpool, recommendations, vpoolCapabilities, false);
fileShares.addAll(fileList);
// prepare the file descriptors
final List<FileDescriptor> fileDescriptors = prepareFileDescriptors(fileShares, vpoolCapabilities, null);
final FileOrchestrationController controller = getController(FileOrchestrationController.class, FileOrchestrationController.FILE_ORCHESTRATION_DEVICE);
try {
// Execute the create mirror copies of fileshare!!!
controller.createTargetsForExistingSource(fs.getId().toString(), fileDescriptors, task);
} catch (InternalException e) {
_log.error("Controller error when creating mirror filesystems", e);
failFileShareCreateRequest(task, taskList, fileShares, e.getMessage());
throw e;
} catch (Exception e) {
_log.error("Controller error when creating mirror filesystems", e);
failFileShareCreateRequest(task, taskList, fileShares, e.getMessage());
throw e;
}
return taskList.getTaskList().get(0);
}
use of com.emc.storageos.db.client.model.FileShare in project coprhd-controller by CoprHD.
the class FileMirrorServiceApiImpl method assignFilePolicyToFileSystem.
@Override
public void assignFilePolicyToFileSystem(FileShare fs, FilePolicy filePolicy, Project project, VirtualPool vpool, VirtualArray varray, TaskList taskList, String task, List<Recommendation> recommendations, VirtualPoolCapabilityValuesWrapper vpoolCapabilities) throws InternalException {
List<FileShare> fileList = null;
List<FileShare> fileShares = new ArrayList<>();
FileSystemParam fsParams = new FileSystemParam();
fsParams.setFsId(fs.getId().toString());
fsParams.setLabel(fs.getLabel());
fsParams.setVarray(fs.getVirtualArray());
fsParams.setVpool(fs.getVirtualPool());
TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, project.getTenantOrg().getURI());
// Prepare the FileShares
fileList = prepareFileSystems(fsParams, task, taskList, project, tenant, null, varray, vpool, recommendations, vpoolCapabilities, false);
fileShares.addAll(fileList);
// prepare the file descriptors
final List<FileDescriptor> fileDescriptors = prepareFileDescriptors(fileShares, vpoolCapabilities, null);
final FileOrchestrationController controller = getController(FileOrchestrationController.class, FileOrchestrationController.FILE_ORCHESTRATION_DEVICE);
try {
// Execute the create mirror copies of file share!!!
controller.assignFilePolicyToFileSystem(filePolicy, fileDescriptors, task);
} catch (InternalException e) {
_log.error("Controller error when creating mirror filesystems", e);
failFileShareCreateRequest(task, taskList, fileShares, e.getMessage());
throw e;
} catch (Exception e) {
_log.error("Controller error when creating mirror filesystems", e);
failFileShareCreateRequest(task, taskList, fileShares, e.getMessage());
throw e;
}
}
use of com.emc.storageos.db.client.model.FileShare in project coprhd-controller by CoprHD.
the class FileMirrorServiceApiImpl method failFileShareCreateRequest.
private void failFileShareCreateRequest(String task, TaskList taskList, List<FileShare> preparedFileShares, String errorMsg) {
String errorMessage = String.format("Controller error: %s", errorMsg);
for (TaskResourceRep fileShareTask : taskList.getTaskList()) {
fileShareTask.setState(Operation.Status.error.name());
fileShareTask.setMessage(errorMessage);
Operation statusUpdate = new Operation(Operation.Status.error.name(), errorMessage);
_dbClient.updateTaskOpStatus(FileShare.class, fileShareTask.getResource().getId(), task, statusUpdate);
}
for (FileShare fileShare : preparedFileShares) {
fileShare.setInactive(true);
_dbClient.updateObject(fileShare);
}
}
use of com.emc.storageos.db.client.model.FileShare in project coprhd-controller by CoprHD.
the class FileMirrorServiceApiImpl method prepareFileDescriptors.
/**
* Prepare the file descriptors
*
* @param filesystems
* @param cosCapabilities
* @param suggestedId
* @return
*/
private List<FileDescriptor> prepareFileDescriptors(List<FileShare> filesystems, VirtualPoolCapabilityValuesWrapper cosCapabilities, String suggestedId) {
// Build up a list of FileDescriptors based on the fileshares
final List<FileDescriptor> fileDescriptors = new ArrayList<FileDescriptor>();
for (FileShare filesystem : filesystems) {
FileDescriptor.Type fileType = FileDescriptor.Type.FILE_MIRROR_SOURCE;
// Source desc type to create mirrors for existing file system!!
if (cosCapabilities.createMirrorExistingFileSystem()) {
fileType = FileDescriptor.Type.FILE_EXISTING_MIRROR_SOURCE;
}
if (filesystem.getPersonality() != null && filesystem.getPersonality().equals(FileShare.PersonalityTypes.TARGET.toString())) {
fileType = FileDescriptor.Type.FILE_MIRROR_TARGET;
}
VirtualPoolCapabilityValuesWrapper vpoolCapabilities = new VirtualPoolCapabilityValuesWrapper(cosCapabilities);
FileDescriptor desc = new FileDescriptor(fileType, filesystem.getStorageDevice(), filesystem.getId(), filesystem.getPool(), filesystem.getCapacity(), vpoolCapabilities, null, suggestedId);
fileDescriptors.add(desc);
}
return fileDescriptors;
}
Aggregations