Search in sources :

Example 1 with Mount

use of com.emc.sa.service.vipr.file.FileStorageUtils.Mount in project coprhd-controller by CoprHD.

the class CreateNFSExportAndMountService method execute.

@Override
public void execute() throws Exception {
    // set fs quotas
    int tempSoftLimit = (softLimit != null) ? softLimit.intValue() : 0;
    int tempAdvisoryLimit = (advisoryLimit != null) ? advisoryLimit.intValue() : 0;
    int tempGracePeriod = (gracePeriod != null) ? gracePeriod.intValue() : 0;
    // convert mount object to export
    List<FileExportRule> exportList = new ArrayList<FileExportRule>();
    for (Mount mount : mountList) {
        FileExportRule export = new FileExportRule();
        List<String> exportHosts = new ArrayList<String>();
        exportHosts.add(BlockStorageUtils.getHost(mount.getHost()).getHostName());
        export.setExportHosts(exportHosts);
        export.setPermission(mount.getPermission());
        export.setSecurity(mount.getSecurity());
        export.setDomain(mount.getDomain());
        export.setRootUserMapping(mount.getRootUserMapping());
        exportList.add(export);
    }
    // create filesystem
    URI fileSystemId = FileStorageUtils.createFileSystemWithoutRollBack(project, virtualArray, virtualPool, exportName, sizeInGb, tempAdvisoryLimit, tempSoftLimit, tempGracePeriod);
    // create nfs export
    if (exportList != null) {
        String rootUserMapping = exportList.get(0).getRootUserMapping().trim();
        String domain = exportList.get(0).getDomain();
        if (StringUtils.isNotBlank(domain)) {
            rootUserMapping = domain.trim() + "\\" + rootUserMapping.trim();
        }
        FileStorageUtils.createFileSystemExportWithoutRollBack(fileSystemId, comment, exportList.get(0).getSecurity(), exportList.get(0).getPermission(), rootUserMapping, exportList.get(0).getExportHosts(), null, false);
        if (!exportList.isEmpty()) {
            FileStorageUtils.updateFileSystemExport(fileSystemId, null, exportList.toArray(new FileExportRule[exportList.size()]), false);
        }
    }
    // mount the exports
    for (Mount mount : mountList) {
        Host host = BlockStorageUtils.getHost(mount.getHost());
        mountNFSExportHelper.mountExport(fileSystemId, mount.getHost(), null, mount.getMountPath(), mount.getSecurity(), host.getHostName(), mount.getFsType());
        ExecutionUtils.addAffectedResource(mount.getHost().toString());
    }
}
Also used : FileExportRule(com.emc.sa.service.vipr.file.FileStorageUtils.FileExportRule) ArrayList(java.util.ArrayList) Mount(com.emc.sa.service.vipr.file.FileStorageUtils.Mount) Host(com.emc.storageos.db.client.model.Host) URI(java.net.URI)

Aggregations

FileExportRule (com.emc.sa.service.vipr.file.FileStorageUtils.FileExportRule)1 Mount (com.emc.sa.service.vipr.file.FileStorageUtils.Mount)1 Host (com.emc.storageos.db.client.model.Host)1 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1