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