Search in sources :

Example 1 with FileWorkflowCompleter

use of com.emc.storageos.volumecontroller.impl.file.FileWorkflowCompleter in project coprhd-controller by CoprHD.

the class FileOrchestrationDeviceController method failbackFileSystem.

@Override
public void failbackFileSystem(URI fsURI, StoragePort nfsPort, StoragePort cifsPort, boolean replicateConfiguration, String taskId) throws ControllerException {
    FileWorkflowCompleter completer = new FileWorkflowCompleter(fsURI, taskId);
    Workflow workflow = null;
    String stepDescription = null;
    try {
        FileShare sourceFileShare = s_dbClient.queryObject(FileShare.class, fsURI);
        List<String> targetfileUris = new ArrayList<String>();
        targetfileUris.addAll(sourceFileShare.getMirrorfsTargets());
        FileShare targetFileShare = s_dbClient.queryObject(FileShare.class, URI.create(targetfileUris.get(0)));
        StorageSystem systemSource = s_dbClient.queryObject(StorageSystem.class, sourceFileShare.getStorageDevice());
        workflow = this._workflowService.getNewWorkflow(this, FAILBACK_FILESYSTEMS_WF_NAME, false, taskId, completer);
        // Failback from Target File System
        s_logger.info("Generating steps for Failback Source File System from Target");
        String failbackStep = workflow.createStepId();
        stepDescription = String.format("Failback to source file System : %s from target system : %s.", sourceFileShare.getName(), targetFileShare.getName());
        Workflow.Method failbackMethod = new Workflow.Method(FAILBACK_FILE_SYSTEM_METHOD, systemSource.getId(), sourceFileShare.getId());
        String waitForFailback = workflow.createStep(null, stepDescription, null, systemSource.getId(), systemSource.getSystemType(), getClass(), failbackMethod, null, failbackStep);
        // Replicate directory quota setting
        stepDescription = String.format("Replicating directory quota settings from source file system : %s to file target system : %s", sourceFileShare.getId(), targetFileShare.getId());
        Workflow.Method replicateDirQuotaSettingsMethod = new Workflow.Method(REPLICATE_FILESYSTEM_DIRECTORY_QUOTA_SETTINGS_METHOD, systemSource.getId(), targetFileShare.getId());
        String replicateDirQuotaSettingsStep = workflow.createStepId();
        workflow.createStep(null, stepDescription, waitForFailback, systemSource.getId(), systemSource.getSystemType(), getClass(), replicateDirQuotaSettingsMethod, null, replicateDirQuotaSettingsStep);
        if (replicateConfiguration) {
            Map<String, List<NfsACE>> sourceNFSACL = FileOrchestrationUtils.queryNFSACL(sourceFileShare, s_dbClient);
            Map<String, List<NfsACE>> targetNFSACL = FileOrchestrationUtils.queryNFSACL(targetFileShare, s_dbClient);
            if (!sourceNFSACL.isEmpty() || !targetNFSACL.isEmpty()) {
                stepDescription = String.format("Replicating NFS ACL from source file system : %s to file target system : %s", sourceFileShare.getId(), targetFileShare.getId());
                Workflow.Method replicateNFSACLsMethod = new Workflow.Method(REPLICATE_FILESYSTEM_NFS_ACLS_METHOD, systemSource.getId(), targetFileShare.getId());
                String replicateNFSACLsStep = workflow.createStepId();
                workflow.createStep(null, stepDescription, waitForFailback, systemSource.getId(), systemSource.getSystemType(), getClass(), replicateNFSACLsMethod, null, replicateNFSACLsStep);
            }
            // Replicate NFS export and rules to Target Cluster.
            FSExportMap targetnfsExportMap = targetFileShare.getFsExports();
            FSExportMap sourcenfsExportMap = sourceFileShare.getFsExports();
            if (!(targetnfsExportMap == null && sourcenfsExportMap == null)) {
                // Both source and target export map shouldn't be null
                stepDescription = String.format("Replicating NFS exports from target file system : %s to source file system : %s", targetFileShare.getId(), sourceFileShare.getId());
                Workflow.Method replicateNFSExportMethod = new Workflow.Method(REPLICATE_FILESYSTEM_NFS_EXPORT_METHOD, systemSource.getId(), targetFileShare.getId(), nfsPort);
                String replicateNFSExportStep = workflow.createStepId();
                String waitForExport = workflow.createStep(null, stepDescription, waitForFailback, systemSource.getId(), systemSource.getSystemType(), getClass(), replicateNFSExportMethod, null, replicateNFSExportStep);
                stepDescription = String.format("Replicating NFS export rules from target file system : %s to source file system : %s", targetFileShare.getId(), sourceFileShare.getId());
                Workflow.Method replicateNFSExportRulesMethod = new Workflow.Method(REPLICATE_FILESYSTEM_NFS_EXPORT_RULE_METHOD, systemSource.getId(), targetFileShare.getId());
                String replicateNFSExportRulesStep = workflow.createStepId();
                workflow.createStep(null, stepDescription, waitForExport, systemSource.getId(), systemSource.getSystemType(), getClass(), replicateNFSExportRulesMethod, null, replicateNFSExportRulesStep);
            }
            // Replicate CIFS shares and ACLs from Target File System to Source.
            SMBShareMap targetSMBShareMap = targetFileShare.getSMBFileShares();
            SMBShareMap sourceSMBShareMap = sourceFileShare.getSMBFileShares();
            if (!(targetSMBShareMap == null && sourceSMBShareMap == null)) {
                // Both source and target share map shouldn't be null
                stepDescription = String.format("Replicating CIFS shares from target file system : %s to file source system : %s", targetFileShare.getId(), sourceFileShare.getId());
                Workflow.Method replicateCIFSShareMethod = new Workflow.Method(REPLICATE_FILESYSTEM_CIFS_SHARES_METHOD, systemSource.getId(), targetFileShare.getId(), cifsPort);
                String replicateCIFSShareStep = workflow.createStepId();
                String waitForShare = workflow.createStep(null, stepDescription, waitForFailback, systemSource.getId(), systemSource.getSystemType(), getClass(), replicateCIFSShareMethod, null, replicateCIFSShareStep);
                stepDescription = String.format("Replicating CIFS share ACLs from target file system : %s to source file system : %s", targetFileShare.getId(), sourceFileShare.getId());
                Workflow.Method replicateCIFSShareACLsMethod = new Workflow.Method(REPLICATE_FILESYSTEM_CIFS_SHARE_ACLS_METHOD, systemSource.getId(), targetFileShare.getId());
                String replicateCIFSShareACLsStep = workflow.createStepId();
                workflow.createStep(null, stepDescription, waitForShare, systemSource.getId(), systemSource.getSystemType(), getClass(), replicateCIFSShareACLsMethod, null, replicateCIFSShareACLsStep);
            }
        }
        String successMessage = "Failback FileSystem successful for: " + sourceFileShare.getLabel();
        workflow.executePlan(completer, successMessage);
    } catch (Exception ex) {
        s_logger.error("Could not failback filesystems: " + fsURI, ex);
        String opName = ResourceOperationTypeEnum.FILE_PROTECTION_ACTION_FAILBACK.getName();
        ServiceError serviceError = DeviceControllerException.errors.createFileSharesFailed(fsURI.toString(), opName, ex);
        completer.error(s_dbClient, this._locker, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) SMBShareMap(com.emc.storageos.db.client.model.SMBShareMap) ArrayList(java.util.ArrayList) Workflow(com.emc.storageos.workflow.Workflow) FSExportMap(com.emc.storageos.db.client.model.FSExportMap) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) WorkflowException(com.emc.storageos.workflow.WorkflowException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) FileWorkflowCompleter(com.emc.storageos.volumecontroller.impl.file.FileWorkflowCompleter) List(java.util.List) ArrayList(java.util.ArrayList) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 2 with FileWorkflowCompleter

use of com.emc.storageos.volumecontroller.impl.file.FileWorkflowCompleter in project coprhd-controller by CoprHD.

the class FileOrchestrationDeviceController method updateShareACLs.

@Override
public void updateShareACLs(URI storage, URI uri, String shareName, CifsShareACLUpdateParams param, 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("Updating file system : %s share : %s  ACLs: %s", uri, shareName, param.toString());
        successMessage = String.format("Updating file system : %s share : %s  ACLs: %s finished successfully.", uri, shareName, param.toString());
        opName = ResourceOperationTypeEnum.UPDATE_FILE_SYSTEM_SHARE_ACL.getName();
    } else {
        completer = new FileSnapshotWorkflowCompleter(uri, opId);
        fileObj = s_dbClient.queryObject(Snapshot.class, uri);
        stepDescription = String.format("Updating file system snapshot : %s share : %s  ACLs: %s", uri, shareName, param.toString());
        successMessage = String.format("Updating file system snapshot : %s share : %s  ACLs: %s finished successfully.", uri, shareName, param.toString());
        opName = ResourceOperationTypeEnum.UPDATE_FILE_SNAPSHOT_SHARE_ACL.getName();
    }
    try {
        Workflow workflow = _workflowService.getNewWorkflow(this, UPDATE_FILESYSTEM_CIFS_SHARE_ACLS_WF_NAME, false, opId, completer);
        String shareACLUpdateStep = workflow.createStepId();
        Object[] args = new Object[] { storage, uri, shareName, param };
        _fileDeviceController.createMethod(workflow, null, UPDATE_FILESYSTEM_SHARE_ACLS_METHOD, shareACLUpdateStep, stepDescription, storage, args);
        workflow.executePlan(completer, successMessage);
    } catch (Exception ex) {
        s_logger.error(String.format("Updating file system : %s share : %s  ACLs: %s failed.", uri, shareName, param.toString()), ex);
        ServiceError serviceError = DeviceControllerException.errors.updateFileShareCIFSACLsFailed(fileObj.toString(), opName, ex);
        completer.error(s_dbClient, _locker, serviceError);
    }
}
Also used : Snapshot(com.emc.storageos.db.client.model.Snapshot) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) FileWorkflowCompleter(com.emc.storageos.volumecontroller.impl.file.FileWorkflowCompleter) FileSnapshotWorkflowCompleter(com.emc.storageos.volumecontroller.impl.file.FileSnapshotWorkflowCompleter) Workflow(com.emc.storageos.workflow.Workflow) FileObject(com.emc.storageos.db.client.model.FileObject) FileObject(com.emc.storageos.db.client.model.FileObject) VNXeFSSnapshotTaskCompleter(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFSSnapshotTaskCompleter) MirrorFileFailoverTaskCompleter(com.emc.storageos.volumecontroller.impl.file.MirrorFileFailoverTaskCompleter) MirrorFileFailbackTaskCompleter(com.emc.storageos.volumecontroller.impl.file.MirrorFileFailbackTaskCompleter) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) WorkflowException(com.emc.storageos.workflow.WorkflowException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException)

Example 3 with FileWorkflowCompleter

use of com.emc.storageos.volumecontroller.impl.file.FileWorkflowCompleter 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);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) NfsACE(com.emc.storageos.model.file.NfsACE) FileNfsACLUpdateParams(com.emc.storageos.model.file.FileNfsACLUpdateParams) ArrayList(java.util.ArrayList) Workflow(com.emc.storageos.workflow.Workflow) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) WorkflowException(com.emc.storageos.workflow.WorkflowException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) FileWorkflowCompleter(com.emc.storageos.volumecontroller.impl.file.FileWorkflowCompleter) List(java.util.List) ArrayList(java.util.ArrayList)

Example 4 with FileWorkflowCompleter

use of com.emc.storageos.volumecontroller.impl.file.FileWorkflowCompleter 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);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Workflow(com.emc.storageos.workflow.Workflow) FSExportMap(com.emc.storageos.db.client.model.FSExportMap) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) WorkflowException(com.emc.storageos.workflow.WorkflowException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) FileWorkflowCompleter(com.emc.storageos.volumecontroller.impl.file.FileWorkflowCompleter) FileExport(com.emc.storageos.db.client.model.FileExport) List(java.util.List) ArrayList(java.util.ArrayList)

Example 5 with FileWorkflowCompleter

use of com.emc.storageos.volumecontroller.impl.file.FileWorkflowCompleter in project coprhd-controller by CoprHD.

the class FileOrchestrationDeviceController method deleteExportRules.

@Override
public void deleteExportRules(URI storage, URI uri, boolean allDirs, String subDirs, boolean unmountExport, 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("Deleting export rules for file system : %s ", uri);
        successMessage = String.format("Deleting export rules for file system : %s finished successfully.", uri);
        opName = ResourceOperationTypeEnum.UNEXPORT_FILE_SYSTEM.getName();
    } else {
        completer = new FileSnapshotWorkflowCompleter(uri, opId);
        fileObj = s_dbClient.queryObject(Snapshot.class, uri);
        stepDescription = String.format("Deleting export rules for file system snapshot : %s ", uri);
        successMessage = String.format("Deleting export rules for file system snapshot : %s finished successfully.", uri);
        opName = ResourceOperationTypeEnum.UNEXPORT_FILE_SNAPSHOT.getName();
    }
    try {
        Workflow workflow = _workflowService.getNewWorkflow(this, DELETE_FILESYSTEM_EXPORT_RULES_WF_NAME, false, opId, completer);
        String waitFor = null;
        // Check if the export should be unmounted before deleting
        if (unmountExport) {
            // get all the mounts and generate steps for unmounting them
            List<MountInfo> mountList = _fileDeviceController.getAllMountedExports(uri, subDirs, allDirs);
            for (MountInfo mount : mountList) {
                Object[] args = new Object[] { mount.getHostId(), mount.getFsId(), mount.getMountPath() };
                waitFor = _fileDeviceController.createMethod(workflow, waitFor, UNMOUNT_FILESYSTEM_EXPORT_METHOD, null, "Unmounting path:" + mount.getMountPath(), storage, args);
            }
        } else if (URIUtil.isType(uri, FileShare.class)) {
            // Check if the export is mounted and throw an error if mounted
            Object[] args = new Object[] { uri, subDirs, allDirs };
            waitFor = _fileDeviceController.createMethod(workflow, waitFor, CHECK_IF_EXPORT_IS_MOUNTED, null, "Checking if the export is mounted", storage, args);
        }
        Object[] args = new Object[] { storage, uri, allDirs, subDirs };
        _fileDeviceController.createMethod(workflow, waitFor, DELETE_FILESYSTEM_EXPORT_RULES, null, stepDescription, storage, args);
        workflow.executePlan(completer, successMessage);
    } catch (Exception ex) {
        s_logger.error(String.format("Deleting export rules for file system snapshot : %s failed. ", uri), ex);
        ServiceError serviceError = DeviceControllerException.errors.deleteExportRuleFailed(fileObj.toString(), opName, ex);
        completer.error(s_dbClient, _locker, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) FileSnapshotWorkflowCompleter(com.emc.storageos.volumecontroller.impl.file.FileSnapshotWorkflowCompleter) Workflow(com.emc.storageos.workflow.Workflow) MountInfo(com.emc.storageos.model.file.MountInfo) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) WorkflowException(com.emc.storageos.workflow.WorkflowException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) Snapshot(com.emc.storageos.db.client.model.Snapshot) FileWorkflowCompleter(com.emc.storageos.volumecontroller.impl.file.FileWorkflowCompleter) FileObject(com.emc.storageos.db.client.model.FileObject) FileObject(com.emc.storageos.db.client.model.FileObject) VNXeFSSnapshotTaskCompleter(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFSSnapshotTaskCompleter) MirrorFileFailoverTaskCompleter(com.emc.storageos.volumecontroller.impl.file.MirrorFileFailoverTaskCompleter) MirrorFileFailbackTaskCompleter(com.emc.storageos.volumecontroller.impl.file.MirrorFileFailbackTaskCompleter) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter)

Aggregations

DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)17 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)17 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)17 ControllerException (com.emc.storageos.volumecontroller.ControllerException)17 FileWorkflowCompleter (com.emc.storageos.volumecontroller.impl.file.FileWorkflowCompleter)17 Workflow (com.emc.storageos.workflow.Workflow)17 WorkflowException (com.emc.storageos.workflow.WorkflowException)17 FileShare (com.emc.storageos.db.client.model.FileShare)14 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)14 FileObject (com.emc.storageos.db.client.model.FileObject)10 MirrorFileFailoverTaskCompleter (com.emc.storageos.volumecontroller.impl.file.MirrorFileFailoverTaskCompleter)8 ArrayList (java.util.ArrayList)8 TaskCompleter (com.emc.storageos.volumecontroller.TaskCompleter)7 FileSnapshotWorkflowCompleter (com.emc.storageos.volumecontroller.impl.file.FileSnapshotWorkflowCompleter)7 MirrorFileFailbackTaskCompleter (com.emc.storageos.volumecontroller.impl.file.MirrorFileFailbackTaskCompleter)7 VNXeFSSnapshotTaskCompleter (com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFSSnapshotTaskCompleter)7 Snapshot (com.emc.storageos.db.client.model.Snapshot)6 List (java.util.List)6 FSExportMap (com.emc.storageos.db.client.model.FSExportMap)4 SMBShareMap (com.emc.storageos.db.client.model.SMBShareMap)4