Search in sources :

Example 1 with UpdateFileSystemExport

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

the class FileStorageUtils method updateFileSystemExport.

public static String updateFileSystemExport(URI fileSystemId, String subDirectory, FileExportRule[] fileExportRules, boolean bypassDnsCheck) {
    List<ExportRule> exportRuleList = getFileSystemExportRules(fileSystemId, false, subDirectory);
    Set<String> existingRuleSet = Sets.newHashSet();
    for (ExportRule rule : exportRuleList) {
        existingRuleSet.add(rule.getSecFlavor());
    }
    List<ExportRule> exportRuleListToAdd = Lists.newArrayList();
    List<ExportRule> exportRuleListToModify = Lists.newArrayList();
    for (FileExportRule rule : fileExportRules) {
        ExportRule exportRule = new ExportRule();
        exportRule.setFsID(fileSystemId);
        exportRule.setSecFlavor(rule.security);
        String rootUserMapping = rule.rootUserMapping;
        String domain = rule.domain;
        if (StringUtils.isNotBlank(domain)) {
            rootUserMapping = domain.trim() + "\\" + rootUserMapping.trim();
        }
        exportRule.setAnon(rootUserMapping);
        Set<String> exportHosts = new HashSet<String>(rule.exportHosts);
        switch(rule.getPermission()) {
            case "ro":
                exportRule.setReadOnlyHosts(exportHosts);
                break;
            case "rw":
                exportRule.setReadWriteHosts(exportHosts);
                break;
            case "root":
                exportRule.setRootHosts(exportHosts);
                break;
            default:
                break;
        }
        if (existingRuleSet.contains(exportRule.getSecFlavor())) {
            exportRuleListToModify.add(exportRule);
        } else {
            exportRuleListToAdd.add(exportRule);
        }
    }
    FileShareExportUpdateParams params = new FileShareExportUpdateParams();
    if (!exportRuleListToAdd.isEmpty()) {
        ExportRules exportRulesToAdd = new ExportRules();
        exportRulesToAdd.setExportRules(exportRuleListToAdd);
        params.setExportRulesToAdd(exportRulesToAdd);
    }
    if (!exportRuleListToModify.isEmpty()) {
        ExportRules exportRulesToModify = new ExportRules();
        exportRulesToModify.setExportRules(exportRuleListToModify);
        params.setExportRulesToModify(exportRulesToModify);
    }
    params.setBypassDnsCheck(bypassDnsCheck);
    Task<FileShareRestRep> task = execute(new UpdateFileSystemExport(fileSystemId, subDirectory, params));
    addAffectedResource(task);
    String exportId = task.getResourceId().toString();
    logInfo("file.storage.export.task", exportId, task.getOpId());
    return exportId;
}
Also used : UpdateFileSystemExport(com.emc.sa.service.vipr.file.tasks.UpdateFileSystemExport) FindFileSnapshotExportRules(com.emc.sa.service.vipr.file.tasks.FindFileSnapshotExportRules) FindFileSystemExportRules(com.emc.sa.service.vipr.file.tasks.FindFileSystemExportRules) ExportRules(com.emc.storageos.model.file.ExportRules) FileShareExportUpdateParams(com.emc.storageos.model.file.FileShareExportUpdateParams) DeactivateFileSystemExportRule(com.emc.sa.service.vipr.file.tasks.DeactivateFileSystemExportRule) DeactivateFileSnapshotExportRule(com.emc.sa.service.vipr.file.tasks.DeactivateFileSnapshotExportRule) ExportRule(com.emc.storageos.model.file.ExportRule) FileShareRestRep(com.emc.storageos.model.file.FileShareRestRep) HashSet(java.util.HashSet)

Aggregations

DeactivateFileSnapshotExportRule (com.emc.sa.service.vipr.file.tasks.DeactivateFileSnapshotExportRule)1 DeactivateFileSystemExportRule (com.emc.sa.service.vipr.file.tasks.DeactivateFileSystemExportRule)1 FindFileSnapshotExportRules (com.emc.sa.service.vipr.file.tasks.FindFileSnapshotExportRules)1 FindFileSystemExportRules (com.emc.sa.service.vipr.file.tasks.FindFileSystemExportRules)1 UpdateFileSystemExport (com.emc.sa.service.vipr.file.tasks.UpdateFileSystemExport)1 ExportRule (com.emc.storageos.model.file.ExportRule)1 ExportRules (com.emc.storageos.model.file.ExportRules)1 FileShareExportUpdateParams (com.emc.storageos.model.file.FileShareExportUpdateParams)1 FileShareRestRep (com.emc.storageos.model.file.FileShareRestRep)1 HashSet (java.util.HashSet)1