Search in sources :

Example 11 with FileOrchestrationController

use of com.emc.storageos.fileorchestrationcontroller.FileOrchestrationController 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 12 with FileOrchestrationController

use of com.emc.storageos.fileorchestrationcontroller.FileOrchestrationController 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 13 with FileOrchestrationController

use of com.emc.storageos.fileorchestrationcontroller.FileOrchestrationController 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 14 with FileOrchestrationController

use of com.emc.storageos.fileorchestrationcontroller.FileOrchestrationController 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 15 with FileOrchestrationController

use of com.emc.storageos.fileorchestrationcontroller.FileOrchestrationController 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)

Aggregations

FileOrchestrationController (com.emc.storageos.fileorchestrationcontroller.FileOrchestrationController)28 FileShare (com.emc.storageos.db.client.model.FileShare)9 FileDescriptor (com.emc.storageos.fileorchestrationcontroller.FileDescriptor)8 ArrayList (java.util.ArrayList)7 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)6 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)6 Operation (com.emc.storageos.db.client.model.Operation)4 TaskMapper.toTask (com.emc.storageos.api.mapper.TaskMapper.toTask)3 MapFileShare (com.emc.storageos.api.mapper.functions.MapFileShare)3 FilePolicy (com.emc.storageos.db.client.model.FilePolicy)3 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)3 Task (com.emc.storageos.db.client.model.Task)3 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)3 BadRequestException (com.emc.storageos.svcs.errorhandling.resources.BadRequestException)3 URI (java.net.URI)3 Path (javax.ws.rs.Path)3 Produces (javax.ws.rs.Produces)3 NamedURI (com.emc.storageos.db.client.model.NamedURI)2 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)2 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)2