Search in sources :

Example 6 with FileDescriptor

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

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

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

Example 9 with FileDescriptor

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

the class DefaultFileServiceApiImpl 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 desc = new FileDescriptor(FileDescriptor.Type.FILE_DATA, filesystem.getStorageDevice(), filesystem.getId(), filesystem.getPool(), filesystem.getCapacity(), cosCapabilities, null, suggestedId);
        fileDescriptors.add(desc);
    }
    return fileDescriptors;
}
Also used : ArrayList(java.util.ArrayList) FileShare(com.emc.storageos.db.client.model.FileShare) FileDescriptor(com.emc.storageos.fileorchestrationcontroller.FileDescriptor)

Example 10 with FileDescriptor

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

the class AbstractFileServiceApiImpl method reduceFileShareQuota.

/**
 * Reduce fileshare provision capacity
 * @param fileshare file share object
 * @param newSize - new fileshare size
 * @param taskId - task id
 * return
 */
@Override
public void reduceFileShareQuota(FileShare fileshare, Long newSize, String taskId) throws InternalException {
    FileOrchestrationController controller = getController(FileOrchestrationController.class, FileOrchestrationController.FILE_ORCHESTRATION_DEVICE);
    final List<FileDescriptor> fileDescriptors = new ArrayList<FileDescriptor>();
    if (fileshare.getParentFileShare() != null && fileshare.getPersonality().equals(FileShare.PersonalityTypes.TARGET.name())) {
        throw APIException.badRequests.reduceMirrorFileSupportedOnlyOnSource(fileshare.getId());
    } else {
        List<String> targetfileUris = new ArrayList<String>();
        // if filesystem is target then throw exception
        if (fileshare.getMirrorfsTargets() != null && !fileshare.getMirrorfsTargets().isEmpty()) {
            targetfileUris.addAll(fileshare.getMirrorfsTargets());
        }
        FileDescriptor descriptor = new FileDescriptor(FileDescriptor.Type.FILE_DATA, fileshare.getStorageDevice(), fileshare.getId(), fileshare.getPool(), "", false, newSize);
        fileDescriptors.add(descriptor);
        // Prepare the descriptor for targets
        for (String target : targetfileUris) {
            FileShare targetFileShare = _dbClient.queryObject(FileShare.class, URI.create(target));
            descriptor = new FileDescriptor(FileDescriptor.Type.FILE_DATA, targetFileShare.getStorageDevice(), targetFileShare.getId(), targetFileShare.getPool(), "", false, newSize);
            fileDescriptors.add(descriptor);
        }
    }
    // place the reduce filesystem call in queue
    controller.reduceFileSystem(fileDescriptors, taskId);
}
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)

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