use of com.emc.storageos.volumecontroller.impl.file.FileSystemAssignPolicyWorkflowCompleter in project coprhd-controller by CoprHD.
the class FileOrchestrationDeviceController method assignFilePolicyToFileSystem.
@Override
public void assignFilePolicyToFileSystem(FilePolicy filePolicy, List<FileDescriptor> fileDescriptors, String taskId) throws ControllerException {
FileShare sourceFS = null;
Workflow workflow = null;
List<URI> fsURIs = FileDescriptor.getFileSystemURIs(fileDescriptors);
FileSystemAssignPolicyWorkflowCompleter completer = new FileSystemAssignPolicyWorkflowCompleter(filePolicy.getId(), fsURIs, taskId);
try {
workflow = _workflowService.getNewWorkflow(this, ASSIGN_FILE_POLICY_TO_FS_WF_NAME, false, taskId);
String waitFor = null;
s_logger.info("Generating steps for creating mirror filesystems...");
for (FileDescriptor fileDescriptor : fileDescriptors) {
if (fileDescriptor.getType().toString().equals(FileDescriptor.Type.FILE_EXISTING_MIRROR_SOURCE.name()) || fileDescriptor.getType().toString().equals(FileDescriptor.Type.FILE_EXISTING_SOURCE.name())) {
sourceFS = s_dbClient.queryObject(FileShare.class, fileDescriptor.getFsURI());
break;
}
}
// then we have to create mirror file system first..
if (filePolicy.getFilePolicyType().equals(FilePolicyType.file_replication.name())) {
waitFor = _fileDeviceController.addStepsForCreateFileSystems(workflow, waitFor, fileDescriptors, taskId);
}
// 2. Apply the file protection policy
String stepDescription = String.format("applying file policy : %s for file system : %s", filePolicy.getId(), sourceFS.getId());
String applyFilePolicyStep = workflow.createStepId();
Object[] args = new Object[] { sourceFS.getStorageDevice(), sourceFS.getId(), filePolicy.getId() };
_fileDeviceController.createMethod(workflow, waitFor, APPLY_FILE_POLICY_METHOD, applyFilePolicyStep, stepDescription, sourceFS.getStorageDevice(), args);
// Finish up and execute the plan.
String successMessage = String.format("Assigning file policy : %s, to file system: %s successful.", filePolicy.getId(), sourceFS.getId());
workflow.executePlan(completer, successMessage);
} catch (Exception ex) {
s_logger.error(String.format("Assigning file policy : %s to file system : %s failed", filePolicy.getId(), sourceFS.getId()), ex);
ServiceError serviceError = DeviceControllerException.errors.assignFilePolicyFailed(filePolicy.toString(), FilePolicyApplyLevel.file_system.name(), ex);
completer.error(s_dbClient, _locker, serviceError);
}
}
Aggregations