Search in sources :

Example 6 with FileWorkflowCompleter

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);
    }
}
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 7 with FileWorkflowCompleter

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);
    }
}
Also used : 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) 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) 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 8 with FileWorkflowCompleter

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);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) FileWorkflowCompleter(com.emc.storageos.volumecontroller.impl.file.FileWorkflowCompleter) Workflow(com.emc.storageos.workflow.Workflow) FileObject(com.emc.storageos.db.client.model.FileObject) 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)

Example 9 with FileWorkflowCompleter

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);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) FileWorkflowCompleter(com.emc.storageos.volumecontroller.impl.file.FileWorkflowCompleter) 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)

Example 10 with FileWorkflowCompleter

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);
    }
}
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) FileExportUpdateParams(com.emc.storageos.model.file.FileExportUpdateParams) ExportRules(com.emc.storageos.model.file.ExportRules) ExportRule(com.emc.storageos.model.file.ExportRule) List(java.util.List) ArrayList(java.util.ArrayList)

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