Search in sources :

Example 1 with MirrorFileFailoverTaskCompleter

use of com.emc.storageos.volumecontroller.impl.file.MirrorFileFailoverTaskCompleter 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);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) MirrorFileFailbackTaskCompleter(com.emc.storageos.volumecontroller.impl.file.MirrorFileFailbackTaskCompleter) ArrayList(java.util.ArrayList) MirrorFileFailoverTaskCompleter(com.emc.storageos.volumecontroller.impl.file.MirrorFileFailoverTaskCompleter) Workflow(com.emc.storageos.workflow.Workflow) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) URI(java.net.URI) 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) StringSet(com.emc.storageos.db.client.model.StringSet) 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) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 2 with MirrorFileFailoverTaskCompleter

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

the class FileOrchestrationDeviceController method failoverFileSystem.

@Override
public void failoverFileSystem(URI fsURI, StoragePort nfsPort, StoragePort cifsPort, boolean replicateConfiguration, String taskId) throws ControllerException {
    FileWorkflowCompleter completer = new FileWorkflowCompleter(fsURI, taskId);
    Workflow workflow = null;
    String stepDescription = null;
    MirrorFileFailoverTaskCompleter failoverCompleter = 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 systemTarget = s_dbClient.queryObject(StorageSystem.class, targetFileShare.getStorageDevice());
        workflow = this._workflowService.getNewWorkflow(this, FAILOVER_FILESYSTEMS_WF_NAME, false, taskId, completer);
        // Failover File System to Target
        s_logger.info("Generating steps for Failover File System to Target");
        String failoverStep = workflow.createStepId();
        List<URI> combined = Arrays.asList(sourceFileShare.getId(), targetFileShare.getId());
        failoverCompleter = new MirrorFileFailoverTaskCompleter(FileShare.class, combined, failoverStep);
        stepDescription = String.format("Failover Source File System %s to Target System.", sourceFileShare.getLabel());
        Object[] args = new Object[] { systemTarget.getId(), targetFileShare.getId(), failoverCompleter };
        String waitForFailover = _fileDeviceController.createMethod(workflow, null, FAILOVER_FILE_SYSTEM_METHOD, failoverStep, stepDescription, systemTarget.getId(), args);
        // Replicate 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, systemTarget.getId(), fsURI);
        String replicateDirQuotaSettingsStep = workflow.createStepId();
        workflow.createStep(null, stepDescription, waitForFailover, systemTarget.getId(), systemTarget.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, systemTarget.getId(), fsURI);
                String replicateNFSACLsStep = workflow.createStepId();
                workflow.createStep(null, stepDescription, waitForFailover, systemTarget.getId(), systemTarget.getSystemType(), getClass(), replicateNFSACLsMethod, null, replicateNFSACLsStep);
            }
            SMBShareMap sourceSMBShareMap = sourceFileShare.getSMBFileShares();
            SMBShareMap targetSMBShareMap = targetFileShare.getSMBFileShares();
            if (sourceSMBShareMap != null || targetSMBShareMap != null) {
                // Both source and target share map shouldn't be null
                stepDescription = String.format("Replicating CIFS shares from source file system : %s to target file system : %s", sourceFileShare.getId(), targetFileShare.getId());
                Workflow.Method replicateCIFSShareMethod = new Workflow.Method(REPLICATE_FILESYSTEM_CIFS_SHARES_METHOD, systemTarget.getId(), fsURI, cifsPort);
                String replicateCIFSShareStep = workflow.createStepId();
                String waitForShare = workflow.createStep(null, stepDescription, waitForFailover, systemTarget.getId(), systemTarget.getSystemType(), getClass(), replicateCIFSShareMethod, null, replicateCIFSShareStep);
                stepDescription = String.format("Replicating CIFS share ACLs from source file system : %s to file target system : %s", sourceFileShare.getId(), targetFileShare.getId());
                Workflow.Method replicateCIFSShareACLsMethod = new Workflow.Method(REPLICATE_FILESYSTEM_CIFS_SHARE_ACLS_METHOD, systemTarget.getId(), fsURI);
                String replicateCIFSShareACLsStep = workflow.createStepId();
                workflow.createStep(null, stepDescription, waitForShare, systemTarget.getId(), systemTarget.getSystemType(), getClass(), replicateCIFSShareACLsMethod, null, replicateCIFSShareACLsStep);
            }
            // Replicate NFS export and rules to Target Cluster.
            FSExportMap sourceNFSExportMap = sourceFileShare.getFsExports();
            FSExportMap targetNFSExportMap = targetFileShare.getFsExports();
            if (sourceNFSExportMap != null || targetNFSExportMap != null) {
                // Both source and target export map shouldn't be null
                stepDescription = String.format("Replicating NFS exports from source file system : %s to target file system : %s", sourceFileShare.getId(), targetFileShare.getId());
                Workflow.Method replicateNFSExportMethod = new Workflow.Method(REPLICATE_FILESYSTEM_NFS_EXPORT_METHOD, systemTarget.getId(), fsURI, nfsPort);
                String replicateNFSExportStep = workflow.createStepId();
                String waitForExport = workflow.createStep(null, stepDescription, waitForFailover, systemTarget.getId(), systemTarget.getSystemType(), getClass(), replicateNFSExportMethod, null, replicateNFSExportStep);
                stepDescription = String.format("Replicating NFS export rules from source file system : %s to target file system : %s", sourceFileShare.getId(), targetFileShare.getId());
                Workflow.Method replicateNFSExportRulesMethod = new Workflow.Method(REPLICATE_FILESYSTEM_NFS_EXPORT_RULE_METHOD, systemTarget.getId(), fsURI);
                String replicateNFSExportRulesStep = workflow.createStepId();
                workflow.createStep(null, stepDescription, waitForExport, systemTarget.getId(), systemTarget.getSystemType(), getClass(), replicateNFSExportRulesMethod, null, replicateNFSExportRulesStep);
            }
        }
        String successMessage = "Failover FileSystem successful for: " + sourceFileShare.getLabel();
        workflow.executePlan(completer, successMessage);
    } catch (Exception ex) {
        s_logger.error("Could not failover filesystems: " + fsURI, ex);
        String opName = ResourceOperationTypeEnum.FILE_PROTECTION_ACTION_FAILOVER.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) MirrorFileFailoverTaskCompleter(com.emc.storageos.volumecontroller.impl.file.MirrorFileFailoverTaskCompleter) 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) URI(java.net.URI) 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) FileObject(com.emc.storageos.db.client.model.FileObject) List(java.util.List) ArrayList(java.util.ArrayList) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

FileObject (com.emc.storageos.db.client.model.FileObject)2 FileShare (com.emc.storageos.db.client.model.FileShare)2 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)2 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)2 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)2 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)2 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)2 ControllerException (com.emc.storageos.volumecontroller.ControllerException)2 MirrorFileFailoverTaskCompleter (com.emc.storageos.volumecontroller.impl.file.MirrorFileFailoverTaskCompleter)2 Workflow (com.emc.storageos.workflow.Workflow)2 WorkflowException (com.emc.storageos.workflow.WorkflowException)2 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2 FSExportMap (com.emc.storageos.db.client.model.FSExportMap)1 SMBShareMap (com.emc.storageos.db.client.model.SMBShareMap)1 StringSet (com.emc.storageos.db.client.model.StringSet)1 TaskCompleter (com.emc.storageos.volumecontroller.TaskCompleter)1 FileWorkflowCompleter (com.emc.storageos.volumecontroller.impl.file.FileWorkflowCompleter)1 MirrorFileFailbackTaskCompleter (com.emc.storageos.volumecontroller.impl.file.MirrorFileFailbackTaskCompleter)1 VNXeFSSnapshotTaskCompleter (com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFSSnapshotTaskCompleter)1