Search in sources :

Example 71 with FileShare

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;
}
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 72 with FileShare

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);
}
Also used : FileSystemParam(com.emc.storageos.model.file.FileSystemParam) FileOrchestrationController(com.emc.storageos.fileorchestrationcontroller.FileOrchestrationController) ArrayList(java.util.ArrayList) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) FileShare(com.emc.storageos.db.client.model.FileShare) FileDescriptor(com.emc.storageos.fileorchestrationcontroller.FileDescriptor) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException)

Example 73 with FileShare

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;
    }
}
Also used : FileSystemParam(com.emc.storageos.model.file.FileSystemParam) FileOrchestrationController(com.emc.storageos.fileorchestrationcontroller.FileOrchestrationController) ArrayList(java.util.ArrayList) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) FileShare(com.emc.storageos.db.client.model.FileShare) FileDescriptor(com.emc.storageos.fileorchestrationcontroller.FileDescriptor) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException)

Example 74 with FileShare

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);
    }
}
Also used : TaskResourceRep(com.emc.storageos.model.TaskResourceRep) Operation(com.emc.storageos.db.client.model.Operation) FileShare(com.emc.storageos.db.client.model.FileShare)

Example 75 with 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;
}
Also used : VirtualPoolCapabilityValuesWrapper(com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper) ArrayList(java.util.ArrayList) FileShare(com.emc.storageos.db.client.model.FileShare) FileDescriptor(com.emc.storageos.fileorchestrationcontroller.FileDescriptor)

Aggregations

FileShare (com.emc.storageos.db.client.model.FileShare)289 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)155 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)107 URI (java.net.URI)93 ArrayList (java.util.ArrayList)79 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)73 ControllerException (com.emc.storageos.volumecontroller.ControllerException)65 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)61 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)57 Operation (com.emc.storageos.db.client.model.Operation)56 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)56 URISyntaxException (java.net.URISyntaxException)56 Path (javax.ws.rs.Path)56 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)52 Produces (javax.ws.rs.Produces)51 Snapshot (com.emc.storageos.db.client.model.Snapshot)50 MapFileShare (com.emc.storageos.api.mapper.functions.MapFileShare)49 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)45 WorkflowException (com.emc.storageos.workflow.WorkflowException)42 NamedURI (com.emc.storageos.db.client.model.NamedURI)36