Search in sources :

Example 6 with MountInfo

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

the class FileProvider method getNFSMountsForHost.

@Asset("mountedNFSExport")
@AssetDependencies("linuxFileHost")
public List<AssetOption> getNFSMountsForHost(AssetOptionsContext ctx, URI host) {
    List<AssetOption> options = Lists.newArrayList();
    List<MountInfo> hostMounts = api(ctx).fileSystems().getNfsMountsByHost(host);
    for (MountInfo mountInfo : hostMounts) {
        String mountString = mountInfo.getMountString();
        options.add(new AssetOption(mountString, getDisplayMount(ctx, mountInfo)));
    }
    AssetOptionsUtils.sortOptionsByLabel(options);
    return options;
}
Also used : AssetOption(com.emc.vipr.model.catalog.AssetOption) MountInfo(com.emc.storageos.model.file.MountInfo) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 7 with MountInfo

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

the class MachineTagUtils method getMountInfo.

public static MountInfo getMountInfo(String strMountInfo) {
    if (strMountInfo != null && !strMountInfo.isEmpty()) {
        MountInfo mountInfo = new MountInfo();
        String[] mountAttrs = strMountInfo.split(";");
        if (mountAttrs.length > 0) {
            mountInfo.setHostId(URIUtil.uri(mountAttrs[0]));
        }
        if (mountAttrs.length > 1) {
            mountInfo.setFsId(URIUtil.uri(mountAttrs[1]));
        }
        if (mountAttrs.length > 2) {
            mountInfo.setSecurityType(mountAttrs[2]);
        }
        if (mountAttrs.length > 3) {
            mountInfo.setMountPath(mountAttrs[3]);
        }
        if (mountAttrs.length > 4) {
            mountInfo.setSubDirectory(mountAttrs[4]);
            if (StringUtils.isEmpty(mountAttrs[4])) {
                mountInfo.setSubDirectory(null);
            }
        }
        return mountInfo;
    }
    return null;
}
Also used : MountInfo(com.emc.storageos.model.file.MountInfo)

Example 8 with MountInfo

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

the class UnmountNFSExportHelper method unmountExports.

public void unmountExports() {
    for (MountInfo mount : mountList) {
        logInfo("linux.mount.file.export.unmount", mount.getMountPath(), hostname);
        FileStorageUtils.unmountNFSExport(mount.getFsId(), mount.getHostId(), mount.getMountPath());
    }
}
Also used : MountInfo(com.emc.storageos.model.file.MountInfo)

Example 9 with MountInfo

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

the class FileOperationUtils method queryDBHostMounts.

/**
 * Method to get the list file system mounts which are mount on a host
 *
 * @param host
 *            host system URI
 * @return List<MountInfo> List of mount infos
 */
public static List<MountInfo> queryDBHostMounts(URI host, DbClient dbClient) {
    _log.info("Querying NFS mounts for host {}", host);
    List<MountInfo> hostMounts = new ArrayList<MountInfo>();
    try {
        ContainmentConstraint containmentConstraint = ContainmentConstraint.Factory.getHostFileMountsConstraint(host);
        List<FileMountInfo> fileMounts = CustomQueryUtility.queryActiveResourcesByConstraint(dbClient, FileMountInfo.class, containmentConstraint);
        if (fileMounts != null && !fileMounts.isEmpty()) {
            for (FileMountInfo dbMount : fileMounts) {
                MountInfo mountInfo = new MountInfo();
                getMountInfo(dbMount, mountInfo);
                hostMounts.add(mountInfo);
            }
        }
        return hostMounts;
    } catch (Exception e) {
        _log.error("Error while querying {}", e);
    }
    return hostMounts;
}
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)

Example 10 with MountInfo

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

the class FileOrchestrationDeviceController method updateExportRules.

@Override
public void updateExportRules(URI storage, URI uri, FileExportUpdateParams param, 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("Updating file system : %s export rules: %s", uri, param.toString());
        successMessage = String.format("Updating file system : %s export rules: %s finished successfully.", uri, param.toString());
        opName = ResourceOperationTypeEnum.UPDATE_EXPORT_RULES_FILE_SYSTEM.getName();
    } else {
        completer = new FileSnapshotWorkflowCompleter(uri, opId);
        fileObj = s_dbClient.queryObject(Snapshot.class, uri);
        stepDescription = String.format("Updating file system : %s export rules: %s", uri, param.toString());
        successMessage = String.format("Updating file system : %s export rules: %s finished successfully.", uri, param.toString());
        opName = ResourceOperationTypeEnum.UPDATE_EXPORT_RULES_FILE_SNAPSHOT.getName();
    }
    try {
        Workflow workflow = _workflowService.getNewWorkflow(this, UPDATE_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.getMountedExports(uri, param.getSubDir(), param);
            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 rule is mounted and throw an error if mounted
            Object[] args = new Object[] { uri, param };
            waitFor = _fileDeviceController.createMethod(workflow, waitFor, VERIFY_MOUNT_DEPENDENCIES_METHOD, null, "Verifying mount dependencies", storage, args);
        }
        Object[] args = new Object[] { storage, uri, param };
        _fileDeviceController.createMethod(workflow, waitFor, UPDATE_FILESYSTEM_EXPORT_RULES_METHOD, null, stepDescription, storage, args);
        workflow.executePlan(completer, successMessage);
    } catch (Exception ex) {
        s_logger.error(String.format("Updating file system : %s export rules: %s failed.", uri, param.toString()), ex);
        ServiceError serviceError = DeviceControllerException.errors.updateFileShareExportRulesFailed(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

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