use of com.emc.storageos.volumecontroller.impl.file.FileWorkflowCompleter in project coprhd-controller by CoprHD.
the class FileOrchestrationDeviceController method createNFSExport.
@Override
public void createNFSExport(URI storage, URI uri, List<FileShareExport> exports, String opId) 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, opId);
fileObj = s_dbClient.queryObject(FileShare.class, uri);
stepDescription = String.format("Creating NFS export for file system : %s", uri);
successMessage = String.format("Creating NFS export for file system : %s finished succesfully.", uri);
opName = ResourceOperationTypeEnum.EXPORT_FILE_SYSTEM.getName();
} else {
completer = new FileSnapshotWorkflowCompleter(uri, opId);
fileObj = s_dbClient.queryObject(Snapshot.class, uri);
stepDescription = String.format("Creating NFS export for file system snapshot : %s", uri);
successMessage = String.format("Creating NFS export for file system snapshot : %s finished succesfully.", uri);
opName = ResourceOperationTypeEnum.EXPORT_FILE_SNAPSHOT.getName();
}
try {
Workflow workflow = _workflowService.getNewWorkflow(this, CREATE_FILESYSTEM_NFS_EXPORT_WF_NAME, false, opId, completer);
String exportStep = workflow.createStepId();
Object[] args = new Object[] { storage, uri, exports };
_fileDeviceController.createMethod(workflow, null, CREATE_FILESYSTEM_EXPORT_METHOD, exportStep, stepDescription, storage, args);
workflow.executePlan(completer, successMessage);
} catch (Exception ex) {
s_logger.error(String.format("Creating NFS export for file system/snapshot : %s failed", uri), ex);
ServiceError serviceError = DeviceControllerException.errors.exportFileShareFailed(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 deleteShareACLs.
@Override
public void deleteShareACLs(URI storage, URI uri, String shareName, String taskId) throws ControllerException {
String stepDescription = null;
String successMessage = null;
String opName = null;
TaskCompleter completer = null;
if (URIUtil.isType(uri, FileShare.class)) {
completer = new FileWorkflowCompleter(uri, taskId);
stepDescription = String.format("Deleting file system : %s share : %s ACLs", uri, shareName);
successMessage = String.format("Deleting file system : %s share : %s ACLs finished successfully", uri, shareName);
opName = ResourceOperationTypeEnum.DELETE_FILE_SYSTEM_SHARE_ACL.getName();
} else {
completer = new FileSnapshotWorkflowCompleter(uri, taskId);
stepDescription = String.format("Deleting file system snapshot : %s share: %s ACLs", uri, shareName);
successMessage = String.format("Deleting file system snapshot : %s share: %s ACLs: finished successfully", uri, shareName);
opName = ResourceOperationTypeEnum.DELETE_FILE_SNAPSHOT_SHARE_ACL.getName();
}
try {
Workflow workflow = this._workflowService.getNewWorkflow(this, DELETE_FILESYSTEM_SHARE_ACLS_WF_NAME, false, taskId, completer);
String shareACLDeleteStep = workflow.createStepId();
Object[] args = new Object[] { storage, uri, shareName };
_fileDeviceController.createMethod(workflow, null, DELETE_FILESYSTEM_SHARE_ACLS_METHOD, shareACLDeleteStep, stepDescription, storage, args);
workflow.executePlan(completer, successMessage);
} catch (Exception ex) {
s_logger.error(String.format("Deleting file system snapshot : %s share: %s ACLs failed.", uri, shareName), ex);
ServiceError serviceError = DeviceControllerException.errors.deleteShareACLFailed(uri.toString(), opName, ex);
completer.error(s_dbClient, this._locker, serviceError);
}
}
use of com.emc.storageos.volumecontroller.impl.file.FileWorkflowCompleter 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.volumecontroller.impl.file.FileWorkflowCompleter 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.volumecontroller.impl.file.FileWorkflowCompleter in project coprhd-controller by CoprHD.
the class FileOrchestrationDeviceController method addStepsToReplicateNFSExportRules.
/**
* Child workflow for replicating source file system NFS export Rules to target.
*
* @param systemTarget
* - URI of target StorageSystem where source NFS shares has to be replicated.
* @param fsURI
* -URI of the source FileSystem
* @param taskId
*/
public void addStepsToReplicateNFSExportRules(URI systemTarget, URI fsURI, String taskId) {
s_logger.info("Generating steps for Replicating NFS export rules to Target Cluster");
FileWorkflowCompleter completer = new FileWorkflowCompleter(fsURI, taskId);
Workflow workflow = null;
FileShare targetFileShare = 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());
}
workflow = this._workflowService.getNewWorkflow(this, REPLICATE_NFS_EXPORT_RULES_TO_TARGET_WF_NAME, false, taskId, completer);
FSExportMap sourceFSExportMap = sourceFileShare.getFsExports();
FSExportMap targetFSExportMap = targetFileShare.getFsExports();
if (sourceFSExportMap == null && targetFSExportMap != null) {
// There are no export rule on source but there are on target!!
List<ExportRule> exportRulesToDelete;
HashMap<String, List<ExportRule>> targetExportRuleMap = FileOrchestrationUtils.getFSExportRuleMap(targetFileShare, s_dbClient);
for (String exportPath : targetExportRuleMap.keySet()) {
FileExportUpdateParams params = new FileExportUpdateParams();
if (exportPath.equals(targetFileShare.getPath())) {
// File system export rules....
exportRulesToDelete = targetExportRuleMap.get(targetFileShare.getPath());
} else {
// Sub directory export rules....
String subDir = exportPath.split(targetFileShare.getPath())[1];
exportRulesToDelete = targetExportRuleMap.get(targetFileShare.getPath() + subDir);
params.setSubDir(subDir.substring(1));
}
ExportRules deleteExportRules = new ExportRules();
deleteExportRules.setExportRules(exportRulesToDelete);
params.setExportRulesToDelete(deleteExportRules);
updateFSExportRulesOnTarget(workflow, systemTarget, targetFileShare, exportPath, params);
}
} else if (targetFSExportMap != null && sourceFSExportMap != null) {
// Both source and target have export rules!!
HashMap<String, List<ExportRule>> sourceExportRuleMap = FileOrchestrationUtils.getFSExportRuleMap(sourceFileShare, s_dbClient);
HashMap<String, List<ExportRule>> targetExportRuleMap = FileOrchestrationUtils.getFSExportRuleMap(targetFileShare, s_dbClient);
for (String exportPath : sourceExportRuleMap.keySet()) {
FileExportUpdateParams params = new FileExportUpdateParams();
List<ExportRule> exportRulesToAdd = new ArrayList<ExportRule>();
List<ExportRule> exportRulesToDelete = new ArrayList<ExportRule>();
List<ExportRule> exportRulesToModify = new ArrayList<ExportRule>();
List<ExportRule> sourceExportRules;
List<ExportRule> targetExportRules;
HashMap<String, ExportRule> srcExportRuleSecFlvMap;
HashMap<String, ExportRule> trgtExportRuleSecFlvMap;
if (exportPath.equals(sourceFileShare.getPath())) {
// File system export rules....
sourceExportRules = sourceExportRuleMap.get(exportPath);
targetExportRules = targetExportRuleMap.get(targetFileShare.getPath());
} else {
// Sub directory export rules....
sourceExportRules = sourceExportRuleMap.get(exportPath);
String subDir = exportPath.split(sourceFileShare.getPath())[1];
targetExportRules = targetExportRuleMap.get(targetFileShare.getPath() + subDir);
params.setSubDir(subDir.substring(1));
}
if (sourceExportRules != null && targetExportRules != null) {
srcExportRuleSecFlvMap = FileOrchestrationUtils.getExportRuleSecFlvMap(sourceExportRules);
trgtExportRuleSecFlvMap = FileOrchestrationUtils.getExportRuleSecFlvMap(targetExportRules);
FileOrchestrationUtils.checkForExportRuleToAdd(sourceFileShare, targetFileShare, srcExportRuleSecFlvMap, trgtExportRuleSecFlvMap, exportRulesToAdd);
FileOrchestrationUtils.checkForExportRuleToDelete(srcExportRuleSecFlvMap, trgtExportRuleSecFlvMap, exportRulesToDelete);
sourceExportRules.removeAll(exportRulesToAdd);
targetExportRules.removeAll(exportRulesToDelete);
srcExportRuleSecFlvMap = FileOrchestrationUtils.getExportRuleSecFlvMap(sourceExportRules);
trgtExportRuleSecFlvMap = FileOrchestrationUtils.getExportRuleSecFlvMap(targetExportRules);
FileOrchestrationUtils.checkForExportRuleToModify(srcExportRuleSecFlvMap, trgtExportRuleSecFlvMap, exportRulesToModify);
if (!exportRulesToAdd.isEmpty()) {
ExportRules addExportRules = new ExportRules();
addExportRules.setExportRules(exportRulesToAdd);
params.setExportRulesToAdd(addExportRules);
}
if (!exportRulesToDelete.isEmpty()) {
ExportRules deleteExportRules = new ExportRules();
deleteExportRules.setExportRules(exportRulesToDelete);
params.setExportRulesToDelete(deleteExportRules);
}
if (!exportRulesToModify.isEmpty()) {
ExportRules modifyExportRules = new ExportRules();
modifyExportRules.setExportRules(exportRulesToModify);
params.setExportRulesToModify(modifyExportRules);
}
if (params.retrieveAllExports() != null && !params.retrieveAllExports().isEmpty()) {
updateFSExportRulesOnTarget(workflow, systemTarget, targetFileShare, exportPath, params);
}
}
}
}
String successMessage = String.format("Replicating source File System : %s, NFS Exports Rules to Target System finished successfully", sourceFileShare.getLabel());
workflow.executePlan(completer, successMessage);
} catch (Exception ex) {
s_logger.error("Could not replicate source filesystem NFS Exports Rules : " + fsURI, ex);
String opName = ResourceOperationTypeEnum.FILE_PROTECTION_ACTION_FAILOVER.getName();
ServiceError serviceError = DeviceControllerException.errors.updateFileShareExportRulesFailed(fsURI.toString(), opName, ex);
completer.error(s_dbClient, this._locker, serviceError);
}
}
Aggregations