Search in sources :

Example 1 with MountInfo

use of com.emc.storageos.model.file.MountInfo in project coprhd-controller by CoprHD.

the class FileDeviceController method CheckIfExportIsMounted.

public void CheckIfExportIsMounted(URI fsId, String subDir, boolean allDirs, String opId) {
    WorkflowStepCompleter.stepExecuting(opId);
    List<MountInfo> mountList = FileOperationUtils.queryDBFSMounts(fsId, _dbClient);
    if (mountList == null || mountList.isEmpty()) {
        WorkflowStepCompleter.stepSucceded(opId);
    }
    if (allDirs) {
        WorkflowStepCompleter.stepFailed(opId, APIException.badRequests.cannotDeleteDuetoExistingMounts());
    }
    if (subDir != null) {
        for (MountInfo mount : mountList) {
            if (subDir.equalsIgnoreCase(mount.getSubDirectory())) {
                WorkflowStepCompleter.stepFailed(opId, APIException.badRequests.cannotDeleteDuetoExistingMounts());
            }
        }
    } else {
        for (MountInfo mount : mountList) {
            if (StringUtils.isEmpty(mount.getSubDirectory())) {
                WorkflowStepCompleter.stepFailed(opId, APIException.badRequests.cannotDeleteDuetoExistingMounts());
            }
        }
    }
    WorkflowStepCompleter.stepSucceded(opId);
}
Also used : FileMountInfo(com.emc.storageos.db.client.model.FileMountInfo) MountInfo(com.emc.storageos.model.file.MountInfo)

Example 2 with MountInfo

use of com.emc.storageos.model.file.MountInfo in project coprhd-controller by CoprHD.

the class FileDeviceController method getRulesToUnmount.

private List<MountInfo> getRulesToUnmount(ExportRules rules, List<MountInfo> mountList, URI fsId, String subDir) {
    List<MountInfo> unmountList = new ArrayList<MountInfo>();
    List<ExportRule> exportList = new ArrayList<ExportRule>();
    exportList.addAll(rules.getExportRules());
    Map<ExportRule, List<String>> filteredExports = filterExportRules(exportList, FileOperationUtils.getExportRules(fsId, false, subDir, _dbClient));
    for (MountInfo mount : mountList) {
        String hostname = _dbClient.queryObject(Host.class, mount.getHostId()).getHostName();
        if (StringUtils.isEmpty(subDir) && StringUtils.isEmpty(mount.getSubDirectory()) || (!StringUtils.isEmpty(mount.getSubDirectory()) && mount.getSubDirectory().equals(subDir))) {
            for (Entry<ExportRule, List<String>> rule : filteredExports.entrySet()) {
                if (rule.getValue().contains(hostname) && rule.getKey().getSecFlavor().equals(mount.getSecurityType())) {
                    unmountList.add(mount);
                }
            }
        }
    }
    return unmountList;
}
Also used : ArrayList(java.util.ArrayList) FileExportRule(com.emc.storageos.db.client.model.FileExportRule) ExportRule(com.emc.storageos.model.file.ExportRule) Arrays.asList(java.util.Arrays.asList) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) List(java.util.List) Host(com.emc.storageos.db.client.model.Host) FileMountInfo(com.emc.storageos.db.client.model.FileMountInfo) MountInfo(com.emc.storageos.model.file.MountInfo)

Example 3 with MountInfo

use of com.emc.storageos.model.file.MountInfo in project coprhd-controller by CoprHD.

the class FileDeviceController method getAllMountedExports.

public List<MountInfo> getAllMountedExports(URI id, String subDir, boolean allDirs) {
    List<MountInfo> mountList = FileOperationUtils.queryDBFSMounts(id, _dbClient);
    List<MountInfo> unmountList = new ArrayList<MountInfo>();
    if (allDirs) {
        return mountList;
    }
    for (MountInfo mount : mountList) {
        if ((StringUtils.isEmpty(mount.getSubDirectory()) && StringUtils.isEmpty(subDir)) || (!StringUtils.isEmpty(subDir) && subDir.equalsIgnoreCase(mount.getSubDirectory()))) {
            unmountList.add(mount);
        }
    }
    return unmountList;
}
Also used : ArrayList(java.util.ArrayList) FileMountInfo(com.emc.storageos.db.client.model.FileMountInfo) MountInfo(com.emc.storageos.model.file.MountInfo)

Example 4 with MountInfo

use of com.emc.storageos.model.file.MountInfo 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 5 with MountInfo

use of com.emc.storageos.model.file.MountInfo in project coprhd-controller by CoprHD.

the class FileOperationUtils method queryDBFSMounts.

public static List<MountInfo> queryDBFSMounts(URI fsId, DbClient dbClient) {
    _log.info("Querying File System mounts using FsId {}", fsId);
    List<MountInfo> fsMounts = new ArrayList<MountInfo>();
    try {
        ContainmentConstraint containmentConstraint = ContainmentConstraint.Factory.getFileMountsConstraint(fsId);
        List<FileMountInfo> fsDBMounts = CustomQueryUtility.queryActiveResourcesByConstraint(dbClient, FileMountInfo.class, containmentConstraint);
        if (fsDBMounts != null && !fsDBMounts.isEmpty()) {
            for (FileMountInfo dbMount : fsDBMounts) {
                MountInfo mountInfo = new MountInfo();
                getMountInfo(dbMount, mountInfo);
                fsMounts.add(mountInfo);
            }
        }
        return fsMounts;
    } catch (Exception e) {
        _log.error("Error while querying {}", e);
    }
    return fsMounts;
}
Also used : ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) ArrayList(java.util.ArrayList) FileMountInfo(com.emc.storageos.db.client.model.FileMountInfo) FileMountInfo(com.emc.storageos.db.client.model.FileMountInfo) MountInfo(com.emc.storageos.model.file.MountInfo)

Aggregations

MountInfo (com.emc.storageos.model.file.MountInfo)11 FileMountInfo (com.emc.storageos.db.client.model.FileMountInfo)6 ArrayList (java.util.ArrayList)5 FileObject (com.emc.storageos.db.client.model.FileObject)3 FileShare (com.emc.storageos.db.client.model.FileShare)3 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)3 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)2 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)2 Snapshot (com.emc.storageos.db.client.model.Snapshot)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 TaskCompleter (com.emc.storageos.volumecontroller.TaskCompleter)2 FileSnapshotWorkflowCompleter (com.emc.storageos.volumecontroller.impl.file.FileSnapshotWorkflowCompleter)2 FileWorkflowCompleter (com.emc.storageos.volumecontroller.impl.file.FileWorkflowCompleter)2 MirrorFileFailbackTaskCompleter (com.emc.storageos.volumecontroller.impl.file.MirrorFileFailbackTaskCompleter)2 MirrorFileFailoverTaskCompleter (com.emc.storageos.volumecontroller.impl.file.MirrorFileFailoverTaskCompleter)2 VNXeFSSnapshotTaskCompleter (com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFSSnapshotTaskCompleter)2 Workflow (com.emc.storageos.workflow.Workflow)2