Search in sources :

Example 56 with ControllerException

use of com.emc.storageos.volumecontroller.ControllerException in project coprhd-controller by CoprHD.

the class FileOrchestrationDeviceController method assignFilePolicyToFileSystem.

@Override
public void assignFilePolicyToFileSystem(FilePolicy filePolicy, List<FileDescriptor> fileDescriptors, String taskId) throws ControllerException {
    FileShare sourceFS = null;
    Workflow workflow = null;
    List<URI> fsURIs = FileDescriptor.getFileSystemURIs(fileDescriptors);
    FileSystemAssignPolicyWorkflowCompleter completer = new FileSystemAssignPolicyWorkflowCompleter(filePolicy.getId(), fsURIs, taskId);
    try {
        workflow = _workflowService.getNewWorkflow(this, ASSIGN_FILE_POLICY_TO_FS_WF_NAME, false, taskId);
        String waitFor = null;
        s_logger.info("Generating steps for creating mirror filesystems...");
        for (FileDescriptor fileDescriptor : fileDescriptors) {
            if (fileDescriptor.getType().toString().equals(FileDescriptor.Type.FILE_EXISTING_MIRROR_SOURCE.name()) || fileDescriptor.getType().toString().equals(FileDescriptor.Type.FILE_EXISTING_SOURCE.name())) {
                sourceFS = s_dbClient.queryObject(FileShare.class, fileDescriptor.getFsURI());
                break;
            }
        }
        // then we have to create mirror file system first..
        if (filePolicy.getFilePolicyType().equals(FilePolicyType.file_replication.name())) {
            waitFor = _fileDeviceController.addStepsForCreateFileSystems(workflow, waitFor, fileDescriptors, taskId);
        }
        // 2. Apply the file protection policy
        String stepDescription = String.format("applying file policy : %s  for file system : %s", filePolicy.getId(), sourceFS.getId());
        String applyFilePolicyStep = workflow.createStepId();
        Object[] args = new Object[] { sourceFS.getStorageDevice(), sourceFS.getId(), filePolicy.getId() };
        _fileDeviceController.createMethod(workflow, waitFor, APPLY_FILE_POLICY_METHOD, applyFilePolicyStep, stepDescription, sourceFS.getStorageDevice(), args);
        // Finish up and execute the plan.
        String successMessage = String.format("Assigning file policy : %s, to file system: %s successful.", filePolicy.getId(), sourceFS.getId());
        workflow.executePlan(completer, successMessage);
    } catch (Exception ex) {
        s_logger.error(String.format("Assigning file policy : %s to file system : %s failed", filePolicy.getId(), sourceFS.getId()), ex);
        ServiceError serviceError = DeviceControllerException.errors.assignFilePolicyFailed(filePolicy.toString(), FilePolicyApplyLevel.file_system.name(), ex);
        completer.error(s_dbClient, _locker, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) FileSystemAssignPolicyWorkflowCompleter(com.emc.storageos.volumecontroller.impl.file.FileSystemAssignPolicyWorkflowCompleter) Workflow(com.emc.storageos.workflow.Workflow) FileObject(com.emc.storageos.db.client.model.FileObject) 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)

Example 57 with ControllerException

use of com.emc.storageos.volumecontroller.ControllerException 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 58 with ControllerException

use of com.emc.storageos.volumecontroller.ControllerException 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)

Example 59 with ControllerException

use of com.emc.storageos.volumecontroller.ControllerException 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 60 with ControllerException

use of com.emc.storageos.volumecontroller.ControllerException 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)

Aggregations

ControllerException (com.emc.storageos.volumecontroller.ControllerException)299 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)280 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)211 WorkflowException (com.emc.storageos.workflow.WorkflowException)188 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)182 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)151 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)121 ArrayList (java.util.ArrayList)93 URI (java.net.URI)87 TaskCompleter (com.emc.storageos.volumecontroller.TaskCompleter)75 Workflow (com.emc.storageos.workflow.Workflow)68 URISyntaxException (java.net.URISyntaxException)63 Volume (com.emc.storageos.db.client.model.Volume)62 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)61 DataBindingException (javax.xml.bind.DataBindingException)61 VolumeTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeTaskCompleter)55 CloneTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneTaskCompleter)52 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)51 NamedURI (com.emc.storageos.db.client.model.NamedURI)50 FileShare (com.emc.storageos.db.client.model.FileShare)49