Search in sources :

Example 1 with FileDescriptor

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

the class FileDeviceController method addStepsForCreateFileSystems.

@Override
public String addStepsForCreateFileSystems(Workflow workflow, String waitFor, List<FileDescriptor> filesystems, String taskId) throws InternalException {
    if (filesystems != null && !filesystems.isEmpty()) {
        // create source filesystems
        List<FileDescriptor> sourceDescriptors = FileDescriptor.filterByType(filesystems, FileDescriptor.Type.FILE_DATA, FileDescriptor.Type.FILE_MIRROR_SOURCE);
        for (FileDescriptor sourceDescriptor : sourceDescriptors) {
            // create a step
            waitFor = workflow.createStep(CREATE_FILESYSTEMS_STEP, String.format("Creating File systems:%n%s", taskId), null, sourceDescriptor.getDeviceURI(), getDeviceType(sourceDescriptor.getDeviceURI()), this.getClass(), createFileSharesMethod(sourceDescriptor), rollbackMethodNullMethod(), null);
        }
        // create targetFileystems
        List<FileDescriptor> targetDescriptors = FileDescriptor.filterByType(filesystems, FileDescriptor.Type.FILE_MIRROR_TARGET);
        if (targetDescriptors != null && !targetDescriptors.isEmpty()) {
            for (FileDescriptor descriptor : targetDescriptors) {
                FileShare fileShare = _dbClient.queryObject(FileShare.class, descriptor.getFsURI());
                FileShare fileShareSource = _dbClient.queryObject(FileShare.class, fileShare.getParentFileShare().getURI());
                if (fileShare.getParentFileShare() != null) {
                    waitFor = workflow.createStep(CREATE_FILESYSTEMS_STEP, String.format("Creating Target File systems:%n%s", taskId), waitFor, descriptor.getDeviceURI(), getDeviceType(descriptor.getDeviceURI()), this.getClass(), createFileSharesMethod(descriptor), rollbackCreateFileSharesMethod(fileShareSource.getStorageDevice(), asList(fileShare.getParentFileShare().getURI()), sourceDescriptors), null);
                }
            }
        }
    }
    // find out which value we should return
    return waitFor = CREATE_FILESYSTEMS_STEP;
}
Also used : FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) FileDescriptor(com.emc.storageos.fileorchestrationcontroller.FileDescriptor)

Example 2 with FileDescriptor

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

the class FileDeviceController method createExpandFileshareStep.

/**
 * Expand File System Step
 *
 * @param workflow
 * @param waitFor
 * @param fileDescriptors
 * @param taskId
 * @return
 */
private String createExpandFileshareStep(Workflow workflow, String waitFor, List<FileDescriptor> fileDescriptors, String taskId) {
    _log.info("START Expand file system");
    Map<URI, Long> filesharesToExpand = new HashMap<URI, Long>();
    for (FileDescriptor descriptor : fileDescriptors) {
        // Grab the fileshare, let's see if an expand is really needed
        FileShare fileShare = _dbClient.queryObject(FileShare.class, descriptor.getFsURI());
        // new size > existing fileshare's provisioned capacity, otherwise we can ignore.
        if (fileShare.getCapacity() != null && fileShare.getCapacity().longValue() != 0 && descriptor.getFileSize() > fileShare.getCapacity().longValue()) {
            filesharesToExpand.put(fileShare.getId(), descriptor.getFileSize());
        }
    }
    Workflow.Method expandMethod = null;
    for (Map.Entry<URI, Long> entry : filesharesToExpand.entrySet()) {
        _log.info("Creating WF step for Expand FileShare for  {}", entry.getKey().toString());
        FileShare fileShareToExpand = _dbClient.queryObject(FileShare.class, entry.getKey());
        StorageSystem storage = _dbClient.queryObject(StorageSystem.class, fileShareToExpand.getStorageDevice());
        Long fileSize = entry.getValue();
        expandMethod = expandFileSharesMethod(storage.getId(), fileShareToExpand.getId(), fileSize);
        waitFor = workflow.createStep(EXPAND_FILESYSTEMS_STEP, String.format("Expand FileShare %s", fileShareToExpand), waitFor, storage.getId(), storage.getSystemType(), getClass(), expandMethod, null, null);
        _log.info("Creating workflow step {}", EXPAND_FILESYSTEMS_STEP);
    }
    return waitFor;
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) Workflow(com.emc.storageos.workflow.Workflow) URI(java.net.URI) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) FSExportMap(com.emc.storageos.db.client.model.FSExportMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) SMBShareMap(com.emc.storageos.db.client.model.SMBShareMap) FileDescriptor(com.emc.storageos.fileorchestrationcontroller.FileDescriptor) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 3 with FileDescriptor

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

the class FileDeviceController method createReduceFileshareStep.

/**
 * Reduce File System Step
 *
 * @param workflow
 * @param waitFor
 * @param fileDescriptors
 * @param taskId
 * @return
 */
private String createReduceFileshareStep(Workflow workflow, String waitFor, List<FileDescriptor> fileDescriptors, String taskId) {
    _log.info("START Reduce file system");
    Map<URI, Long> filesharesToReduce = new HashMap<URI, Long>();
    for (FileDescriptor descriptor : fileDescriptors) {
        FileShare fileShare = _dbClient.queryObject(FileShare.class, descriptor.getFsURI());
        if (fileShare.getCapacity() != null && fileShare.getCapacity().longValue() != 0) {
            filesharesToReduce.put(fileShare.getId(), descriptor.getFileSize());
        }
    }
    Workflow.Method reduceMethod = null;
    for (Map.Entry<URI, Long> entry : filesharesToReduce.entrySet()) {
        _log.info("Creating WF step for Reduce FileShare for  {}", entry.getKey().toString());
        FileShare fileShareToReduce = _dbClient.queryObject(FileShare.class, entry.getKey());
        StorageSystem storage = _dbClient.queryObject(StorageSystem.class, fileShareToReduce.getStorageDevice());
        Long fileSize = entry.getValue();
        reduceMethod = reduceFileSharesMethod(storage.getId(), fileShareToReduce.getId(), fileSize);
        waitFor = workflow.createStep(REDUCE_FILESYSTEMS_STEP, String.format("Reduce FileShare %s", fileShareToReduce), waitFor, storage.getId(), storage.getSystemType(), getClass(), reduceMethod, null, null);
        _log.info("Creating workflow step {}", REDUCE_FILESYSTEMS_STEP);
    }
    return waitFor;
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) Workflow(com.emc.storageos.workflow.Workflow) URI(java.net.URI) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) FSExportMap(com.emc.storageos.db.client.model.FSExportMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) SMBShareMap(com.emc.storageos.db.client.model.SMBShareMap) FileDescriptor(com.emc.storageos.fileorchestrationcontroller.FileDescriptor) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 4 with FileDescriptor

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

the class FileReplicationDeviceController method createFileMirrorSession.

/**
 * Create Mirror Work Flow Step - creates replication session between source and target
 *
 * @param workflow
 * @param waitFor
 * @param sourceDescriptors
 * @param uriFileShareMap
 * @return
 */
protected String createFileMirrorSession(Workflow workflow, String waitFor, List<FileDescriptor> sourceDescriptors, Map<URI, FileShare> uriFileShareMap) {
    for (FileDescriptor sourceDescriptor : sourceDescriptors) {
        FileShare source = uriFileShareMap.get(sourceDescriptor.getFsURI());
        for (String targetStr : source.getMirrorfsTargets()) {
            URI targetURI = URI.create(targetStr);
            StorageSystem system = dbClient.queryObject(StorageSystem.class, source.getStorageDevice());
            Workflow.Method createMethod = createMirrorFilePairStep(system.getId(), source.getId(), targetURI, null);
            Workflow.Method rollbackMethod = rollbackMirrorFilePairMethod(system.getId(), source.getId(), targetURI);
            // Ensure CreateElementReplica steps are executed sequentially (CQ613404)
            waitFor = workflow.createStep(CREATE_FILE_MIRRORS_STEP, CREATE_FILE_MIRRORS_STEP_DESC, waitFor, system.getId(), system.getSystemType(), getClass(), createMethod, rollbackMethod, null);
        }
    }
    return waitFor = CREATE_FILE_MIRRORS_STEP;
}
Also used : Workflow(com.emc.storageos.workflow.Workflow) FileShare(com.emc.storageos.db.client.model.FileShare) URI(java.net.URI) FileDescriptor(com.emc.storageos.fileorchestrationcontroller.FileDescriptor) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 5 with FileDescriptor

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

the class FileMirrorServiceApiImpl 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)

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