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);
}
}
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);
}
}
Aggregations