Search in sources :

Example 41 with Workflow

use of com.emc.storageos.workflow.Workflow in project coprhd-controller by CoprHD.

the class FileOrchestrationDeviceController method expandFileSystem.

/*
     * (non-Javadoc)
     * 
     * @see com.emc.storageos.fileorchestrationcontroller.FileOrchestrationController#expandFileSystem(java.net.URI,
     * long, java.lang.String)
     */
/**
 * expand one or more filesystem
 *
 * @param fileDescriptors
 * @param taskId
 * @throws ControllerException
 */
@Override
public void expandFileSystem(List<FileDescriptor> fileDescriptors, String taskId) throws ControllerException {
    // the wait for key returned by previous call
    String waitFor = null;
    List<URI> fileShareUris = FileDescriptor.getFileSystemURIs(fileDescriptors);
    FileWorkflowCompleter completer = new FileWorkflowCompleter(fileShareUris, taskId);
    Workflow workflow = null;
    try {
        // Generate the Workflow.
        workflow = _workflowService.getNewWorkflow(this, EXPAND_FILESYSTEMS_WF_NAME, false, taskId);
        // Next, call the FileDeviceController to add its delete methods.
        waitFor = _fileDeviceController.addStepsForExpandFileSystems(workflow, waitFor, fileDescriptors, taskId);
        // Finish up and execute the plan.
        // The Workflow will handle the TaskCompleter
        String successMessage = "Expand FileShares successful for: " + fileShareUris.toString();
        Object[] callbackArgs = new Object[] { fileShareUris };
        workflow.executePlan(completer, successMessage, new WorkflowCallback(), callbackArgs, null, null);
    } catch (Exception ex) {
        s_logger.error("Could not Expand FileShares: " + fileShareUris, ex);
        releaseWorkflowLocks(workflow);
        String opName = ResourceOperationTypeEnum.EXPORT_FILE_SYSTEM.getName();
        ServiceError serviceError = DeviceControllerException.errors.expandFileShareFailed(fileShareUris.toString(), opName, ex);
        completer.error(s_dbClient, _locker, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) FileWorkflowCompleter(com.emc.storageos.volumecontroller.impl.file.FileWorkflowCompleter) Workflow(com.emc.storageos.workflow.Workflow) FileObject(com.emc.storageos.db.client.model.FileObject) URI(java.net.URI) WorkflowException(com.emc.storageos.workflow.WorkflowException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException)

Example 42 with Workflow

use of com.emc.storageos.workflow.Workflow in project coprhd-controller by CoprHD.

the class FileOrchestrationDeviceController method addStepsToReplicateDirectoryQuotaSettings.

/**
 * Child workflow for replicating source file system directory quota settings to target system.
 *
 * @param systemTarget
 *            - URI of target StorageSystem where source quota directory settings have to be replicated.
 * @param fsURI
 *            -URI of the source FileSystem
 * @param taskId
 */
public void addStepsToReplicateDirectoryQuotaSettings(URI systemTarget, URI fsURI, String taskId) {
    s_logger.info("Generating steps for replicating directory quota settings to target cluster.");
    FileWorkflowCompleter completer = new FileWorkflowCompleter(fsURI, taskId);
    FileShare targetFileShare = null;
    Workflow workflow = null;
    try {
        FileShare sourceFileShare = s_dbClient.queryObject(FileShare.class, fsURI);
        if (sourceFileShare.getPersonality().equals(PersonalityTypes.SOURCE.name())) {
            List<String> targetfileUris = new ArrayList<String>();
            targetfileUris.addAll(sourceFileShare.getMirrorfsTargets());
            targetFileShare = s_dbClient.queryObject(FileShare.class, URI.create(targetfileUris.get(0)));
        } else {
            targetFileShare = s_dbClient.queryObject(FileShare.class, sourceFileShare.getParentFileShare());
        }
        targetFileShare.setSoftGracePeriod(sourceFileShare.getSoftGracePeriod());
        targetFileShare.setSoftLimit(sourceFileShare.getSoftLimit());
        targetFileShare.setNotificationLimit(sourceFileShare.getNotificationLimit());
        s_dbClient.updateObject(targetFileShare);
        workflow = this._workflowService.getNewWorkflow(this, REPLICATE_QUOTA_DIR_SETTINGS_TO_TARGET_WF_NAME, false, taskId, completer);
        updateTargetFileSystem(workflow, systemTarget, targetFileShare);
        String successMessage = String.format("Replicating source file system : %s, directory quota settings to target file system finished successfully.", sourceFileShare.getLabel());
        workflow.executePlan(completer, successMessage);
    } catch (Exception ex) {
        s_logger.error("Could not replicate source filesystem directory quota settings: " + fsURI, ex);
        String opName = ResourceOperationTypeEnum.FILE_PROTECTION_ACTION_FAILOVER.getName();
        ServiceError serviceError = DeviceControllerException.errors.unableToUpdateFileSystem(opName, ex);
        completer.error(s_dbClient, this._locker, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) FileWorkflowCompleter(com.emc.storageos.volumecontroller.impl.file.FileWorkflowCompleter) ArrayList(java.util.ArrayList) Workflow(com.emc.storageos.workflow.Workflow) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) WorkflowException(com.emc.storageos.workflow.WorkflowException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException)

Example 43 with Workflow

use of com.emc.storageos.workflow.Workflow in project coprhd-controller by CoprHD.

the class FileOrchestrationDeviceController method createFileSystems.

/*
     * (non-Javadoc)
     * 
     * @see com.emc.storageos.fileorchestrationcontroller.FileOrchestrationController#createFileSystems(java.util.List,
     * java.lang.String)
     */
/**
 * Creates one or more filesystem
 * (FileShare, FileMirroring). This method is responsible for creating
 * a Workflow and invoking the FileOrchestrationInterface.addStepsForCreateFileSystems
 *
 * @param fileDescriptors
 * @param taskId
 * @throws ControllerException
 */
@Override
public void createFileSystems(List<FileDescriptor> fileDescriptors, String taskId) throws ControllerException {
    // Generate the Workflow.
    Workflow workflow = null;
    List<URI> fsUris = FileDescriptor.getFileSystemURIs(fileDescriptors);
    FileCreateWorkflowCompleter completer = new FileCreateWorkflowCompleter(fsUris, taskId, fileDescriptors);
    try {
        // Generate the Workflow.
        workflow = _workflowService.getNewWorkflow(this, CREATE_FILESYSTEMS_WF_NAME, false, taskId);
        // the wait for key returned by previous call
        String waitFor = null;
        s_logger.info("Generating steps for create FileSystem");
        // First, call the FileDeviceController to add its methods.
        waitFor = _fileDeviceController.addStepsForCreateFileSystems(workflow, waitFor, fileDescriptors, taskId);
        // second, check for policies that has to applied on this file system..
        waitFor = addStepsForApplyingPolicies(workflow, waitFor, fileDescriptors);
        // Finish up and execute the plan.
        // The Workflow will handle the TaskCompleter
        String successMessage = "Create filesystems successful for: " + fsUris.toString();
        Object[] callbackArgs = new Object[] { fsUris };
        workflow.executePlan(completer, successMessage, new WorkflowCallback(), callbackArgs, null, null);
    } catch (Exception ex) {
        s_logger.error("Could not create filesystems: " + fsUris, ex);
        releaseWorkflowLocks(workflow);
        String opName = ResourceOperationTypeEnum.CREATE_FILE_SYSTEM.getName();
        ServiceError serviceError = DeviceControllerException.errors.createFileSharesFailed(fsUris.toString(), opName, ex);
        completer.error(s_dbClient, _locker, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) FileCreateWorkflowCompleter(com.emc.storageos.volumecontroller.impl.file.FileCreateWorkflowCompleter) Workflow(com.emc.storageos.workflow.Workflow) FileObject(com.emc.storageos.db.client.model.FileObject) URI(java.net.URI) WorkflowException(com.emc.storageos.workflow.WorkflowException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException)

Example 44 with Workflow

use of com.emc.storageos.workflow.Workflow 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 45 with Workflow

use of com.emc.storageos.workflow.Workflow in project coprhd-controller by CoprHD.

the class FileReplicationDeviceController method createMethod.

/**
 * Common method used to create Controller methods that would be executed by workflow service
 *
 * @param workflow
 * @param stepGroup
 * @param waitFor - String
 * @param methodName - Name of the method to be executed
 * @param stepId - String unique id of the step
 * @param stepDescription - String description of the step
 * @param storage - URI of the StorageSystem
 * @param args - Parameters of the method that has to be executed by workflow
 * @return waitForStep
 */
public String createMethod(Workflow workflow, String stepGroup, String waitFor, String methodName, String stepId, String stepDescription, URI storage, Object[] args) {
    StorageSystem system = this.dbClient.queryObject(StorageSystem.class, storage);
    Workflow.Method method = new Workflow.Method(methodName, args);
    String waitForStep = workflow.createStep(stepGroup, stepDescription, waitFor, storage, system.getSystemType(), getClass(), method, null, stepId);
    return waitForStep;
}
Also used : Workflow(com.emc.storageos.workflow.Workflow) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

Workflow (com.emc.storageos.workflow.Workflow)285 URI (java.net.URI)204 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)171 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)127 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)126 ControllerException (com.emc.storageos.volumecontroller.ControllerException)126 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)124 ArrayList (java.util.ArrayList)123 WorkflowException (com.emc.storageos.workflow.WorkflowException)119 NamedURI (com.emc.storageos.db.client.model.NamedURI)102 Volume (com.emc.storageos.db.client.model.Volume)76 TaskCompleter (com.emc.storageos.volumecontroller.TaskCompleter)72 HashMap (java.util.HashMap)66 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)65 ExportGroup (com.emc.storageos.db.client.model.ExportGroup)61 ExportMask (com.emc.storageos.db.client.model.ExportMask)54 ExportTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter)54 List (java.util.List)54 BlockObject (com.emc.storageos.db.client.model.BlockObject)41 InternalServerErrorException (com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException)41