Search in sources :

Example 16 with FileWorkflowCompleter

use of com.emc.storageos.volumecontroller.impl.file.FileWorkflowCompleter in project coprhd-controller by CoprHD.

the class FileOrchestrationDeviceController method createCIFSShare.

@Override
public void createCIFSShare(URI storageSystem, URI uri, FileSMBShare smbShare, String taskId) throws ControllerException {
    FileObject fileObj = null;
    String stepDescription = null;
    String successMessage = null;
    String opName = null;
    TaskCompleter completer = null;
    if (URIUtil.isType(uri, FileShare.class)) {
        completer = new FileWorkflowCompleter(uri, taskId);
        fileObj = s_dbClient.queryObject(FileShare.class, uri);
        stepDescription = String.format("Creating CIFS share for file system : %s, share name: %s ", uri, smbShare.getName());
        successMessage = String.format("Creating CIFS share for file system : %s, share name: %s finished succesfully.", uri, smbShare.getName());
        opName = ResourceOperationTypeEnum.CREATE_FILE_SYSTEM_SHARE.getName();
    } else {
        completer = new FileSnapshotWorkflowCompleter(uri, taskId);
        fileObj = s_dbClient.queryObject(Snapshot.class, uri);
        stepDescription = String.format("Creating CIFS share for file system snapshot : %s, share name: %s ", uri, smbShare.getName());
        successMessage = String.format("Creating CIFS share for file system : %s, share name: %s finished succesfully.", uri, smbShare.getName());
        opName = ResourceOperationTypeEnum.CREATE_FILE_SNAPSHOT_SHARE.getName();
    }
    try {
        Workflow workflow = _workflowService.getNewWorkflow(this, CREATE_FILESYSTEM_CIFS_SHARE_WF_NAME, false, taskId, completer);
        String shareStep = workflow.createStepId();
        Object[] args = new Object[] { storageSystem, uri, smbShare };
        _fileDeviceController.createMethod(workflow, null, CREATE_FILESYSTEM_SHARE_METHOD, shareStep, stepDescription, storageSystem, args);
        workflow.executePlan(completer, successMessage);
    } catch (Exception ex) {
        s_logger.error(String.format("Creating CIFS share for file system : %s, share name: %s failed.", uri, smbShare.getName()), ex);
        ServiceError serviceError = DeviceControllerException.errors.createFileSharesFailed(fileObj.toString(), opName, ex);
        completer.error(s_dbClient, _locker, serviceError);
    }
}
Also used : Snapshot(com.emc.storageos.db.client.model.Snapshot) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) FileWorkflowCompleter(com.emc.storageos.volumecontroller.impl.file.FileWorkflowCompleter) FileSnapshotWorkflowCompleter(com.emc.storageos.volumecontroller.impl.file.FileSnapshotWorkflowCompleter) Workflow(com.emc.storageos.workflow.Workflow) FileObject(com.emc.storageos.db.client.model.FileObject) FileObject(com.emc.storageos.db.client.model.FileObject) VNXeFSSnapshotTaskCompleter(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFSSnapshotTaskCompleter) MirrorFileFailoverTaskCompleter(com.emc.storageos.volumecontroller.impl.file.MirrorFileFailoverTaskCompleter) MirrorFileFailbackTaskCompleter(com.emc.storageos.volumecontroller.impl.file.MirrorFileFailbackTaskCompleter) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) 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 17 with FileWorkflowCompleter

use of com.emc.storageos.volumecontroller.impl.file.FileWorkflowCompleter in project coprhd-controller by CoprHD.

the class FileOrchestrationDeviceController method reduceFileSystem.

/**
 * This method is responsible for reduction of fileshare quota
 *
 * a Workflow and invoking the FileOrchestrationInterface.addStepsForReduceFileSystems
 *
 * @param fileDescriptors
 * @param taskId
 * @throws ControllerException
 */
@Override
public void reduceFileSystem(List<FileDescriptor> fileDescriptors, String taskId) throws ControllerException {
    List<URI> fileShareUris = FileDescriptor.getFileSystemURIs(fileDescriptors);
    FileWorkflowCompleter completer = new FileWorkflowCompleter(fileShareUris, taskId);
    Workflow workflow = null;
    // the wait for key returned by previous call
    String waitFor = null;
    try {
        // Generate the Workflow.
        workflow = _workflowService.getNewWorkflow(this, REDUCE_FILESYSTEMS_WF_NAME, false, taskId);
        // Next, call the FileDeviceController
        waitFor = _fileDeviceController.addStepsForReduceFileSystems(workflow, waitFor, fileDescriptors, taskId);
        // Finish up and execute the plan.
        // The Workflow will handle the TaskCompleter
        String successMessage = "Reduce 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 Reduce FileShares: " + fileShareUris, ex);
        releaseWorkflowLocks(workflow);
        String opName = ResourceOperationTypeEnum.REDUCE_FILE_SYSTEM.getName();
        ServiceError serviceError = DeviceControllerException.errors.reduceFileShareFailed(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)

Aggregations

DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)17 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)17 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)17 ControllerException (com.emc.storageos.volumecontroller.ControllerException)17 FileWorkflowCompleter (com.emc.storageos.volumecontroller.impl.file.FileWorkflowCompleter)17 Workflow (com.emc.storageos.workflow.Workflow)17 WorkflowException (com.emc.storageos.workflow.WorkflowException)17 FileShare (com.emc.storageos.db.client.model.FileShare)14 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)14 FileObject (com.emc.storageos.db.client.model.FileObject)10 MirrorFileFailoverTaskCompleter (com.emc.storageos.volumecontroller.impl.file.MirrorFileFailoverTaskCompleter)8 ArrayList (java.util.ArrayList)8 TaskCompleter (com.emc.storageos.volumecontroller.TaskCompleter)7 FileSnapshotWorkflowCompleter (com.emc.storageos.volumecontroller.impl.file.FileSnapshotWorkflowCompleter)7 MirrorFileFailbackTaskCompleter (com.emc.storageos.volumecontroller.impl.file.MirrorFileFailbackTaskCompleter)7 VNXeFSSnapshotTaskCompleter (com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFSSnapshotTaskCompleter)7 Snapshot (com.emc.storageos.db.client.model.Snapshot)6 List (java.util.List)6 FSExportMap (com.emc.storageos.db.client.model.FSExportMap)4 SMBShareMap (com.emc.storageos.db.client.model.SMBShareMap)4