Search in sources :

Example 16 with FileDescriptor

use of com.emc.storageos.fileorchestrationcontroller.FileDescriptor in project coprhd-controller by CoprHD.

the class FileService method assignFilePolicyToFS.

private TaskResourceRep assignFilePolicyToFS(FileShare fs, FilePolicy filePolicy, String task) {
    StorageSystem device = _dbClient.queryObject(StorageSystem.class, fs.getStorageDevice());
    FileOrchestrationController controller = getController(FileOrchestrationController.class, FileOrchestrationController.FILE_ORCHESTRATION_DEVICE);
    Operation op = _dbClient.createTaskOpStatus(FileShare.class, fs.getId(), task, ResourceOperationTypeEnum.ASSIGN_FILE_POLICY_TO_FILE_SYSTEM);
    op.setDescription("assign file policy to file system");
    // As the action done by tenant admin
    // Set current tenant as task's tenant!!!
    Task taskObj = op.getTask(fs.getId());
    FilePolicyServiceUtils.updateTaskTenant(_dbClient, filePolicy, "assign", taskObj, fs.getTenant().getURI());
    try {
        _log.info("No Errors found proceeding further {}, {}, {}", new Object[] { _dbClient, fs, filePolicy });
        List<FileDescriptor> fileDescriptors = new ArrayList<>();
        FileDescriptor desc = new FileDescriptor(Type.FILE_EXISTING_SOURCE, fs.getId());
        fileDescriptors.add(desc);
        controller.assignFilePolicyToFileSystem(filePolicy, fileDescriptors, task);
        auditOp(OperationTypeEnum.ASSIGN_FILE_POLICY, true, AuditLogManager.AUDITOP_BEGIN, fs.getId().toString(), device.getId().toString(), filePolicy.getId());
    } catch (BadRequestException e) {
        _dbClient.error(FileShare.class, fs.getId(), task, e);
        _log.error("Error Assigning Filesystem policy {}, {}", e.getMessage(), e);
        throw e;
    } catch (Exception e) {
        _log.error("Error Assigning Filesystem policy {}, {}", e.getMessage(), e);
        throw APIException.badRequests.unableToProcessRequest(e.getMessage());
    }
    return toTask(fs, task, op);
}
Also used : TaskMapper.toTask(com.emc.storageos.api.mapper.TaskMapper.toTask) Task(com.emc.storageos.db.client.model.Task) FileOrchestrationController(com.emc.storageos.fileorchestrationcontroller.FileOrchestrationController) ArrayList(java.util.ArrayList) BadRequestException(com.emc.storageos.svcs.errorhandling.resources.BadRequestException) Operation(com.emc.storageos.db.client.model.Operation) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) MapFileShare(com.emc.storageos.api.mapper.functions.MapFileShare) FileDescriptor(com.emc.storageos.fileorchestrationcontroller.FileDescriptor) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) URISyntaxException(java.net.URISyntaxException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) BadRequestException(com.emc.storageos.svcs.errorhandling.resources.BadRequestException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 17 with FileDescriptor

use of com.emc.storageos.fileorchestrationcontroller.FileDescriptor in project coprhd-controller by CoprHD.

the class FileRemoteMirrorServiceApiImpl method getDescriptorsOfFileShareDeleted.

@Override
protected List<FileDescriptor> getDescriptorsOfFileShareDeleted(URI systemURI, List<URI> fileShareURIs, String deletionType, boolean forceDelete, boolean deleteOnlyMirrors) {
    List<FileDescriptor> fileDescriptors = new ArrayList<FileDescriptor>();
    for (URI fileURI : fileShareURIs) {
        FileShare fileShare = _dbClient.queryObject(FileShare.class, fileURI);
        FileDescriptor.Type descriptorType;
        if (fileShare.getPersonality() == null || fileShare.getPersonality().contains("null")) {
            descriptorType = FileDescriptor.Type.FILE_DATA;
        } else if (FileShare.PersonalityTypes.TARGET == getPersonality(fileShare)) {
            if (isParentInactiveForTarget(fileShare)) {
                descriptorType = FileDescriptor.Type.FILE_DATA;
            } else {
                _log.warn("Attempted to delete an Mirror target that had an active Mirror source");
                throw APIException.badRequests.cannotDeleteMirrorFileShareTargetWithActiveSource(fileURI, fileShare.getParentFileShare().getURI());
            }
        } else {
            descriptorType = FileDescriptor.Type.FILE_MIRROR_SOURCE;
        }
        FileDescriptor fileDescriptor = new FileDescriptor(descriptorType, fileShare.getStorageDevice(), fileShare.getId(), fileShare.getPool(), deletionType, forceDelete, deleteOnlyMirrors);
        fileDescriptors.add(fileDescriptor);
    }
    return fileDescriptors;
}
Also used : ArrayList(java.util.ArrayList) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) FileShare(com.emc.storageos.db.client.model.FileShare) FileDescriptor(com.emc.storageos.fileorchestrationcontroller.FileDescriptor)

Example 18 with FileDescriptor

use of com.emc.storageos.fileorchestrationcontroller.FileDescriptor in project coprhd-controller by CoprHD.

the class FileMirrorServiceApiImpl method createFileSystems.

/**
 * It take mirror recommendation and then creates source and mirror fileshare
 */
@Override
public TaskList createFileSystems(FileSystemParam param, Project project, VirtualArray varray, VirtualPool vpool, TenantOrg tenantOrg, DataObject.Flag[] flags, List<Recommendation> recommendations, TaskList taskList, String taskId, VirtualPoolCapabilityValuesWrapper vpoolCapabilities) throws InternalException {
    List<FileShare> fileList = null;
    List<FileShare> fileShares = new ArrayList<FileShare>();
    // Prepare the FileShares
    fileList = prepareFileSystems(param, taskId, taskList, project, tenantOrg, flags, varray, vpool, recommendations, vpoolCapabilities, false);
    fileShares.addAll(fileList);
    // prepare the file descriptors
    String suggestedNativeFsId = param.getFsId() == null ? "" : param.getFsId();
    final List<FileDescriptor> fileDescriptors = prepareFileDescriptors(fileShares, vpoolCapabilities, suggestedNativeFsId);
    final FileOrchestrationController controller = getController(FileOrchestrationController.class, FileOrchestrationController.FILE_ORCHESTRATION_DEVICE);
    try {
        // Execute the fileshare creations requests
        controller.createFileSystems(fileDescriptors, taskId);
    } catch (InternalException e) {
        _log.error("Controller error when creating mirror filesystems", e);
        failFileShareCreateRequest(taskId, taskList, fileShares, e.getMessage());
        throw e;
    } catch (Exception e) {
        _log.error("Controller error when creating mirror filesystems", e);
        failFileShareCreateRequest(taskId, taskList, fileShares, e.getMessage());
        throw e;
    }
    return taskList;
}
Also used : FileOrchestrationController(com.emc.storageos.fileorchestrationcontroller.FileOrchestrationController) ArrayList(java.util.ArrayList) 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 19 with FileDescriptor

use of com.emc.storageos.fileorchestrationcontroller.FileDescriptor in project coprhd-controller by CoprHD.

the class DefaultFileServiceApiImpl method createFileSystems.

@Override
public TaskList createFileSystems(FileSystemParam param, Project project, VirtualArray varray, VirtualPool vpool, TenantOrg tenantOrg, DataObject.Flag[] flags, List<Recommendation> recommendations, TaskList taskList, String task, VirtualPoolCapabilityValuesWrapper vpoolCapabilities) throws InternalException {
    List<FileShare> fileList = null;
    List<FileShare> fileShares = new ArrayList<FileShare>();
    // Prepare the FileShares
    fileList = getFileScheduler().prepareFileSystems(param, task, taskList, project, varray, vpool, recommendations, vpoolCapabilities, false);
    fileShares.addAll(fileList);
    // prepare the file descriptors
    String suggestedNativeFsId = param.getFsId() == null ? "" : param.getFsId();
    final List<FileDescriptor> fileDescriptors = prepareFileDescriptors(fileShares, vpoolCapabilities, suggestedNativeFsId);
    final FileOrchestrationController controller = getController(FileOrchestrationController.class, FileOrchestrationController.FILE_ORCHESTRATION_DEVICE);
    try {
        // Execute the fileshare creations requests
        controller.createFileSystems(fileDescriptors, task);
    } catch (InternalException e) {
        _log.error("Controller error when creating filesystems", e);
        failFileShareCreateRequest(task, taskList, fileShares, e.getMessage());
        throw e;
    } catch (Exception e) {
        _log.error("Controller error when creating filesystems", e);
        failFileShareCreateRequest(task, taskList, fileShares, e.getMessage());
        throw e;
    }
    return taskList;
}
Also used : FileOrchestrationController(com.emc.storageos.fileorchestrationcontroller.FileOrchestrationController) ArrayList(java.util.ArrayList) FileShare(com.emc.storageos.db.client.model.FileShare) FileDescriptor(com.emc.storageos.fileorchestrationcontroller.FileDescriptor) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException)

Example 20 with FileDescriptor

use of com.emc.storageos.fileorchestrationcontroller.FileDescriptor in project coprhd-controller by CoprHD.

the class DefaultFileServiceApiImpl method getDescriptorsOfFileShareDeleted.

/**
 * {@inheritDoc}
 */
@Override
protected List<FileDescriptor> getDescriptorsOfFileShareDeleted(URI systemURI, List<URI> fileShareURIs, String deletionType, boolean forceDelete, boolean deleteOnlyMirrors) {
    List<FileDescriptor> fileDescriptors = new ArrayList<FileDescriptor>();
    for (URI fileShareURI : fileShareURIs) {
        FileShare filesystem = _dbClient.queryObject(FileShare.class, fileShareURI);
        FileDescriptor fileDescriptor = new FileDescriptor(FileDescriptor.Type.FILE_DATA, filesystem.getStorageDevice(), filesystem.getId(), filesystem.getPool(), deletionType, forceDelete, deleteOnlyMirrors);
        fileDescriptors.add(fileDescriptor);
    }
    return fileDescriptors;
}
Also used : ArrayList(java.util.ArrayList) URI(java.net.URI) FileShare(com.emc.storageos.db.client.model.FileShare) FileDescriptor(com.emc.storageos.fileorchestrationcontroller.FileDescriptor)

Aggregations

FileDescriptor (com.emc.storageos.fileorchestrationcontroller.FileDescriptor)21 FileShare (com.emc.storageos.db.client.model.FileShare)20 ArrayList (java.util.ArrayList)13 FileOrchestrationController (com.emc.storageos.fileorchestrationcontroller.FileOrchestrationController)8 URI (java.net.URI)7 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)5 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)5 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)4 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)4 Workflow (com.emc.storageos.workflow.Workflow)3 FSExportMap (com.emc.storageos.db.client.model.FSExportMap)2 NamedURI (com.emc.storageos.db.client.model.NamedURI)2 SMBShareMap (com.emc.storageos.db.client.model.SMBShareMap)2 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)2 FileSystemParam (com.emc.storageos.model.file.FileSystemParam)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 TaskMapper.toTask (com.emc.storageos.api.mapper.TaskMapper.toTask)1 MapFileShare (com.emc.storageos.api.mapper.functions.MapFileShare)1