use of com.emc.storageos.workflow.Workflow in project coprhd-controller by CoprHD.
the class FileOrchestrationDeviceController method addStepsToReplicateNFSACLs.
/**
* Child workflow for replicating source file system NFS ACL to target system.
*
* @param systemTarget
* - URI of target StorageSystem where source CIFS shares has to be replicated.
* @param fsURI
* -URI of the source FileSystem
* @param taskId
*/
public void addStepsToReplicateNFSACLs(URI systemTarget, URI fsURI, String taskId) {
s_logger.info("Generating steps for Replicating NFS ACLs to Target Cluster");
FileNfsACLUpdateParams params = null;
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());
}
workflow = this._workflowService.getNewWorkflow(this, REPLICATE_NFS_ACLS_TO_TARGET_WF_NAME, false, taskId, completer);
Map<String, List<NfsACE>> sourceFSACLMap = FileOrchestrationUtils.queryNFSACL(sourceFileShare, s_dbClient);
Map<String, List<NfsACE>> targetFSACLMap = FileOrchestrationUtils.queryNFSACL(targetFileShare, s_dbClient);
if (!sourceFSACLMap.isEmpty() && targetFSACLMap.isEmpty()) {
// target share doesn't have any ACLs but corresponding share on source does have ACL
s_logger.info("Target NFS doesn't have any ACL but corresponding NFS on source does have ACL.");
for (String fsPath : sourceFSACLMap.keySet()) {
List<NfsACE> aclToAdd = null;
params = FileOrchestrationUtils.getFileNfsACLUpdateParamWithSubDir(fsPath, sourceFileShare);
aclToAdd = sourceFSACLMap.get(fsPath);
params.setAcesToAdd(aclToAdd);
s_logger.info("Invoking updateNFSACL on FS: {}, with {}", targetFileShare.getName(), params);
updateNFSACLOnTarget(workflow, systemTarget, targetFileShare, params);
}
} else if (!targetFSACLMap.isEmpty() && sourceFSACLMap.isEmpty()) {
s_logger.info("Source NFS doesn't have any ACL but corresponding NFS on target has ACL.");
for (String fsPath : targetFSACLMap.keySet()) {
List<NfsACE> aclToDelete = null;
params = FileOrchestrationUtils.getFileNfsACLUpdateParamWithSubDir(fsPath, targetFileShare);
aclToDelete = targetFSACLMap.get(fsPath);
// TO FIX COP-26361 DU case
// params.setAcesToDelete(aclToDelete);
s_logger.info("Invoking updateNFSACL on FS: {}, with {}", targetFileShare.getName(), params);
updateNFSACLOnTarget(workflow, systemTarget, targetFileShare, params);
}
} else if (!sourceFSACLMap.isEmpty() && !targetFSACLMap.isEmpty()) {
// both source and target FS have some ACL
for (String sourceFSACLPath : sourceFSACLMap.keySet()) {
List<NfsACE> aclToAdd = new ArrayList<NfsACE>();
List<NfsACE> aclToDelete = new ArrayList<NfsACE>();
List<NfsACE> aclToModify = new ArrayList<NfsACE>();
// Segregate source and target NFS ACL
params = FileOrchestrationUtils.getFileNfsACLUpdateParamWithSubDir(sourceFSACLPath, sourceFileShare);
List<NfsACE> sourceNFSACL = sourceFSACLMap.get(sourceFSACLPath);
if (sourceNFSACL == null) {
sourceNFSACL = new ArrayList<NfsACE>();
}
String subDir = params.getSubDir();
String targetFSACLPath = targetFileShare.getPath();
if (subDir != null) {
targetFSACLPath += "/" + subDir;
}
List<NfsACE> targetNFSACL = targetFSACLMap.get(targetFSACLPath);
if (targetNFSACL == null) {
targetNFSACL = new ArrayList<NfsACE>();
}
HashMap<String, NfsACE> sourceUserToNFSACLMap = FileOrchestrationUtils.getUserToNFSACEMap(sourceNFSACL);
HashMap<String, NfsACE> targetUserToNFSACLMap = FileOrchestrationUtils.getUserToNFSACEMap(targetNFSACL);
// ACL To Add
for (String sourceACEUser : sourceUserToNFSACLMap.keySet()) {
if (targetUserToNFSACLMap.get(sourceACEUser) == null) {
NfsACE nfsACE = sourceUserToNFSACLMap.get(sourceACEUser);
aclToAdd.add(nfsACE);
}
}
// ACL To Delete
for (String targetACEUser : targetUserToNFSACLMap.keySet()) {
if (sourceUserToNFSACLMap.get(targetACEUser) == null) {
aclToDelete.add(targetUserToNFSACLMap.get(targetACEUser));
}
}
// ACL to Modify
targetNFSACL.removeAll(aclToDelete);
sourceNFSACL.removeAll(aclToAdd);
sourceUserToNFSACLMap = FileOrchestrationUtils.getUserToNFSACEMap(sourceNFSACL);
targetUserToNFSACLMap = FileOrchestrationUtils.getUserToNFSACEMap(targetNFSACL);
for (String sourceACEUser : sourceUserToNFSACLMap.keySet()) {
NfsACE targetACE = targetUserToNFSACLMap.get(sourceACEUser);
NfsACE sourceACE = sourceUserToNFSACLMap.get(sourceACEUser);
if (targetACE != null && (!targetACE.getPermissions().equals(sourceACE.getPermissions()) || !targetACE.getPermissionType().equals(sourceACE.getPermissionType()))) {
targetACE.setPermissions(sourceACE.getPermissions());
targetACE.setPermissionType(sourceACE.getPermissionType());
aclToModify.add(targetACE);
}
}
if (!aclToAdd.isEmpty()) {
params.setAcesToAdd(aclToAdd);
}
if (!aclToDelete.isEmpty()) {
// TO FIX COP-26361 DU case
// params.setAcesToDelete(aclToDelete);
}
if (!aclToModify.isEmpty()) {
params.setAcesToModify(aclToModify);
}
if (!params.retrieveAllACL().isEmpty()) {
s_logger.info("Invoking updateNFSACL on FS: {}, with {}", targetFileShare.getName(), params);
updateNFSACLOnTarget(workflow, systemTarget, targetFileShare, params);
}
}
}
String successMessage = String.format("Replicating source file system : %s, NFS ACL to target file system finished successfully", sourceFileShare.getLabel());
workflow.executePlan(completer, successMessage);
} catch (Exception ex) {
s_logger.error("Could not replicate source filesystem NFS ACL : " + fsURI, ex);
String opName = ResourceOperationTypeEnum.FILE_PROTECTION_ACTION_FAILOVER.getName();
ServiceError serviceError = DeviceControllerException.errors.updateFileShareNFSACLFailed(fsURI.toString(), 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 assignFileReplicationPolicyToVirtualPools.
@Override
public void assignFileReplicationPolicyToVirtualPools(List<FileStorageSystemAssociation> associations, List<URI> vpoolURIs, URI filePolicyToAssign, String taskId) {
FilePolicy filePolicy = s_dbClient.queryObject(FilePolicy.class, filePolicyToAssign);
FilePolicyAssignWorkflowCompleter completer = new FilePolicyAssignWorkflowCompleter(filePolicyToAssign, vpoolURIs, null, taskId);
try {
String waitFor = null;
String stepId = null;
String stepDes = null;
Workflow workflow = _workflowService.getNewWorkflow(this, ASSIGN_FILE_POLICY_WF_NAME, false, taskId, completer);
completer.setWorkFlowId(workflow.getWorkflowURI());
String usePhysicalNASForProvisioning = customConfigHandler.getComputedCustomConfigValue(CustomConfigConstants.USE_PHYSICAL_NAS_FOR_PROVISIONING, "isilon", null);
Boolean usePhysicalNAS = Boolean.valueOf(usePhysicalNASForProvisioning);
// Verify the associations have many to one storage system relation.
// If so, inform the user to configure cluster name in provisioning path!!
verifyClusterNameInPathForManyToOneRecommendations(associations, filePolicy);
s_logger.info("Generating steps for assigning file replication policy to vpool: {}.", filePolicyToAssign);
for (FileStorageSystemAssociation association : associations) {
StorageSystem sourceStoragesystem = s_dbClient.queryObject(StorageSystem.class, association.getSourceSystem());
URI vpoolURI = association.getAppliedAtResource();
List<TargetAssociation> targetAssociations = association.getTargets();
if (targetAssociations != null && !targetAssociations.isEmpty()) {
for (Iterator<TargetAssociation> iterator = targetAssociations.iterator(); iterator.hasNext(); ) {
TargetAssociation targetAssociation = iterator.next();
URI targetVNASURI = targetAssociation.getvNASURI();
URI targetStorage = targetAssociation.getStorageSystemURI();
URI targetVArray = targetAssociation.getvArrayURI();
if (targetVNASURI != null && association.getSourceVNAS() != null) {
stepId = workflow.createStepId();
stepDes = String.format("Assigning file policy: %s, to vpool: %s on storage system: %s with source vnas %s and target vnas %s", filePolicy.getId(), vpoolURI, association.getSourceSystem(), association.getSourceVNAS(), targetVNASURI);
Object[] args = new Object[] { association.getSourceSystem(), targetStorage, association.getSourceVNAS(), targetVArray, targetVNASURI, filePolicyToAssign, vpoolURI };
_fileDeviceController.createMethod(workflow, waitFor, ASSIGN_FILE_REPLICATION_POLICY_TO_VIRTUAL_POOLS_METHOD, stepId, stepDes, association.getSourceSystem(), args);
} else {
if (sourceStoragesystem.getSystemType().equals(Type.isilon.toString())) {
if (usePhysicalNAS) {
stepId = workflow.createStepId();
stepDes = String.format("Assigning file policy: %s, to vpool: %s on storage system: %s", filePolicy.getId(), vpoolURI, association.getSourceSystem());
// Let the all workflow steps be executed
// workflow completer should handle the unsuccessful steps
Object[] args = new Object[] { association.getSourceSystem(), targetStorage, association.getSourceVNAS(), targetVArray, null, filePolicyToAssign, vpoolURI };
_fileDeviceController.createMethod(workflow, waitFor, ASSIGN_FILE_REPLICATION_POLICY_TO_VIRTUAL_POOLS_METHOD, stepId, stepDes, association.getSourceSystem(), args);
}
}
}
}
}
}
String successMessage = String.format("Assigning file policy : %s, to vpool(s) successful.", filePolicy.getId());
workflow.executePlan(completer, successMessage);
} catch (Exception ex) {
// If no other resources are assigned to replication policy
// Remove the replication topology from the policy
FileOrchestrationUtils.removeTopologyInfo(filePolicy, s_dbClient);
s_logger.error(String.format("Assigning file policy : %s to vpool(s) failed", filePolicy.getId()), ex);
ServiceError serviceError = DeviceControllerException.errors.assignFilePolicyFailed(filePolicyToAssign.toString(), filePolicy.getApplyAt(), ex);
completer.error(s_dbClient, _locker, serviceError);
}
}
use of com.emc.storageos.workflow.Workflow in project coprhd-controller by CoprHD.
the class FileOrchestrationDeviceController method deleteSnapshot.
@Override
public void deleteSnapshot(URI storage, URI pool, URI uri, boolean forceDelete, String deleteType, String opId) throws ControllerException {
Snapshot snap = s_dbClient.queryObject(Snapshot.class, uri);
FileSnapshotWorkflowCompleter completer = new FileSnapshotWorkflowCompleter(uri, opId);
Workflow workflow = null;
try {
workflow = this._workflowService.getNewWorkflow(this, DELETE_FILESYSTEM_SNAPSHOT_WF_NAME, false, opId, completer);
String deleteSnapshotStep = workflow.createStepId();
String stepDescription = String.format("Deleting file System : %s snapshot: %s", snap.getParent(), uri);
Object[] args = new Object[] { storage, pool, uri, forceDelete, deleteType };
_fileDeviceController.createMethod(workflow, null, DELETE_FILESYSTEM_SNAPSHOT_METHOD, deleteSnapshotStep, stepDescription, storage, args);
String successMessage = String.format("Deleting file System : %s snapshot: %s finished successfully.", snap.getParent(), uri);
workflow.executePlan(completer, successMessage);
} catch (Exception ex) {
s_logger.error(String.format("Deleting file System : %s snapshot: %s failed.", snap.getParent(), uri), ex);
String opName = ResourceOperationTypeEnum.DELETE_FILE_SNAPSHOT.getName();
ServiceError serviceError = DeviceControllerException.errors.deleteFSSnapshotFailed(uri.toString(), 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 doFailBackMirrorSessionWF.
/**
* Child Workflow for failback
*
* @param systemURI
* @param fsURI source FS URI
* @param taskId
*/
public void doFailBackMirrorSessionWF(URI systemURI, URI fsURI, String taskId) {
TaskCompleter taskCompleter = null;
String stepDescription;
String stepId;
Object[] args;
try {
FileShare sourceFS = s_dbClient.queryObject(FileShare.class, fsURI);
StorageSystem primarysystem = s_dbClient.queryObject(StorageSystem.class, systemURI);
StringSet targets = sourceFS.getMirrorfsTargets();
List<URI> targetFSURI = new ArrayList<>();
for (String target : targets) {
targetFSURI.add(URI.create(target));
}
FileShare targetFS = s_dbClient.queryObject(FileShare.class, targetFSURI.get(0));
StorageSystem secondarySystem = s_dbClient.queryObject(StorageSystem.class, targetFS.getStorageDevice());
taskCompleter = new MirrorFileFailbackTaskCompleter(FileShare.class, sourceFS.getId(), taskId);
Workflow workflow = _workflowService.getNewWorkflow(this, FAILBACK_FILE_SYSTEM_METHOD, false, taskId, taskCompleter);
s_logger.info("Generating steps for failback to source file share: {} from target file share: {}", fsURI, targetFS.getId());
/*
* Step 1. Creates a mirror replication policy for the secondary cluster i.e Resync-prep on primary cluster , this will disable
* primary cluster replication policy.
*/
stepDescription = String.format("source resync-prep : creating mirror policy on target system: %s", secondarySystem.getId());
stepId = workflow.createStepId();
args = new Object[] { primarysystem.getId(), sourceFS.getId(), "resync" };
String waitFor = _fileDeviceController.createMethod(workflow, null, FILE_REPLICATION_OPERATIONS_METHOD, stepId, stepDescription, primarysystem.getId(), args);
/*
* Step 2. Start the mirror replication policy manually, this will replicate new data (written during failover) from secondary
* cluster to primary cluster.
*/
stepDescription = String.format("start mirror policy: replicate target file share: %s, data to source file share:%s", targetFS.getId(), sourceFS.getId());
stepId = workflow.createStepId();
args = new Object[] { secondarySystem.getId(), targetFS.getId(), "start" };
waitFor = _fileDeviceController.createMethod(workflow, waitFor, FILE_REPLICATION_OPERATIONS_METHOD, stepId, stepDescription, secondarySystem.getId(), args);
/*
* Step 3. Allow Write on Primary Cluster local target after replication from step 2
* i.e Fail over to Primary Cluster
*/
stepDescription = String.format("failover on source file system : allow write on source file share: %s", sourceFS.getId());
stepId = workflow.createStepId();
List<URI> combined = Arrays.asList(sourceFS.getId(), targetFS.getId());
MirrorFileFailoverTaskCompleter failoverCompleter = new MirrorFileFailoverTaskCompleter(FileShare.class, combined, stepId);
args = new Object[] { primarysystem.getId(), sourceFS.getId(), failoverCompleter };
waitFor = _fileDeviceController.createMethod(workflow, waitFor, FAILOVER_FILE_SYSTEM_METHOD, stepId, stepDescription, primarysystem.getId(), args);
/*
* Step 4. Resync-Prep on secondary cluster , same as step 1 but will be executed on secondary cluster instead of primary
* cluster.
*/
stepDescription = String.format(" target resync-prep : disabling mirror policy on target system: %s", secondarySystem.getId());
stepId = workflow.createStepId();
args = new Object[] { secondarySystem.getId(), targetFS.getId(), "resync" };
_fileDeviceController.createMethod(workflow, waitFor, FILE_REPLICATION_OPERATIONS_METHOD, stepId, stepDescription, secondarySystem.getId(), args);
String successMsg = String.format("Failback of %s to %s successful", sourceFS.getId(), targetFS.getId());
workflow.executePlan(taskCompleter, successMsg);
} catch (Exception ex) {
s_logger.error("Could not replicate source filesystem CIFS shares: " + fsURI, ex);
String opName = ResourceOperationTypeEnum.FILE_PROTECTION_ACTION_FAILBACK.getName();
ServiceError serviceError = DeviceControllerException.errors.createFileSharesFailed(fsURI.toString(), opName, ex);
taskCompleter.error(s_dbClient, this._locker, serviceError);
}
}
use of com.emc.storageos.workflow.Workflow in project coprhd-controller by CoprHD.
the class FileOrchestrationDeviceController method addStepsToReplicateNFSExports.
/**
* Child workflow for replicating source file system NFS export to target.
*
* @param systemTarget
* - URI of target StorageSystem where source NFS shares has to be replicated.
* @param fsURI
* -URI of the source FileSystem
* @param nfsPort
* -StoragePort, NFS port of target File System where new export has to be created.
* @param taskId
*/
public void addStepsToReplicateNFSExports(URI systemTarget, URI fsURI, StoragePort nfsPort, String taskId) {
s_logger.info("Generating steps for Replicating NFS exports 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_TO_TARGET_WF_NAME, false, taskId, completer);
FSExportMap sourceNFSExportMap = sourceFileShare.getFsExports();
FSExportMap targetNFSExportMap = targetFileShare.getFsExports();
if (targetNFSExportMap == null && sourceNFSExportMap != null) {
// No export on target i.e create all source export on target
List<FileExport> sourceNFSExports = new ArrayList<FileExport>(sourceNFSExportMap.values());
createNFSExportOnTarget(workflow, systemTarget, sourceNFSExports, nfsPort, targetFileShare, sourceFileShare);
} else if (sourceNFSExportMap != null && targetNFSExportMap != null) {
// both source and target have some exports
List<FileExport> sourceNFSExports = new ArrayList<FileExport>(sourceNFSExportMap.values());
List<FileExport> targetNFSExports = new ArrayList<FileExport>(targetNFSExportMap.values());
List<FileExport> targetNFSExportstoCreate = new ArrayList<FileExport>();
// Creating new map since FSExportMap key contains path+sec+user
HashMap<String, FileExport> sourceFileExportMap = FileOrchestrationUtils.getFileExportMap(sourceNFSExports);
HashMap<String, FileExport> targetFileExportMap = FileOrchestrationUtils.getFileExportMap(targetNFSExports);
String waitFor = null;
// Check for export to create on target
for (String exportPath : sourceFileExportMap.keySet()) {
if (exportPath.equals(sourceFileShare.getPath())) {
if (targetFileExportMap.get(targetFileShare.getPath()) == null) {
targetNFSExportstoCreate.add(sourceFileExportMap.get(exportPath));
}
} else {
ArrayList<String> subdirName = new ArrayList<String>();
subdirName.add(exportPath.split(sourceFileShare.getPath())[1]);
if (targetFileExportMap.get(targetFileShare.getPath() + subdirName.get(0)) == null) {
targetNFSExportstoCreate.add(sourceFileExportMap.get(exportPath));
}
}
}
if (!targetNFSExportstoCreate.isEmpty()) {
waitFor = createNFSExportOnTarget(workflow, systemTarget, targetNFSExportstoCreate, nfsPort, targetFileShare, sourceFileShare);
}
// Check for export to delete on target
for (String exportPath : targetFileExportMap.keySet()) {
String stepDescription = String.format("deleting NFS export : %s", exportPath);
String exportdeletionStep = workflow.createStepId();
if (exportPath.equals(targetFileShare.getPath())) {
if (sourceFileExportMap.get(sourceFileShare.getPath()) == null) {
Object[] args = new Object[] { systemTarget, targetFileShare.getId(), false, null };
waitFor = _fileDeviceController.createMethod(workflow, waitFor, DELETE_FILESYSTEM_EXPORT_METHOD, exportdeletionStep, stepDescription, systemTarget, args);
}
} else {
ArrayList<String> subdirName = new ArrayList<String>();
subdirName.add(exportPath.split(targetFileShare.getPath())[1]);
if (sourceFileExportMap.get(sourceFileShare.getPath() + subdirName.get(0)) == null) {
Object[] args = new Object[] { systemTarget, targetFileShare.getId(), false, subdirName.get(0).substring(1) };
waitFor = _fileDeviceController.createMethod(workflow, waitFor, DELETE_FILESYSTEM_EXPORT_METHOD, exportdeletionStep, stepDescription, systemTarget, args);
}
}
}
}
String successMessage = String.format("Replicating source File System : %s NFS Exports to Target System finished successfully", sourceFileShare.getId());
workflow.executePlan(completer, successMessage);
} catch (Exception ex) {
s_logger.error("Could not replicate source filesystem NFS Exports : " + 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