use of com.emc.storageos.model.file.FileShareExportUpdateParams in project coprhd-controller by CoprHD.
the class FileSystems method save.
@FlashException(referrer = { "fileSystem" })
public static void save(Boolean edit, String id, String fsPath, String exportPath, String security, String anon, String subDir, @As(",") List<String> ro, @As(",") List<String> rw, @As(",") List<String> root, Boolean bypassDnsCheck) {
ExportRule rule = new ExportRule();
rule.setFsID(uri(id));
rule.setMountPoint(fsPath);
rule.setExportPath(exportPath);
rule.setAnon(anon);
rule.setSecFlavor(security);
// Clean up endpoints list by removing all empty items
List<String> empty = Arrays.asList("");
rw.removeAll(empty);
ro.removeAll(empty);
root.removeAll(empty);
if (!ro.isEmpty()) {
rule.setReadOnlyHosts(FileUtils.buildEndpointList(ro));
}
if (!rw.isEmpty()) {
rule.setReadWriteHosts(FileUtils.buildEndpointList(rw));
}
if (!root.isEmpty()) {
rule.setRootHosts(FileUtils.buildEndpointList(root));
}
List<ExportRule> addRules = Lists.newArrayList();
addRules.add(rule);
ExportRules exportRules = new ExportRules();
exportRules.setExportRules(addRules);
FileShareExportUpdateParams params = new FileShareExportUpdateParams();
params.setBypassDnsCheck(bypassDnsCheck);
if (!edit) {
params.setExportRulesToAdd(exportRules);
} else {
params.setExportRulesToModify(exportRules);
subDir = FileUtils.findSubDirectory(fsPath, exportPath);
}
ViPRCoreClient client = BourneUtil.getViprClient();
client.fileSystems().updateExport(uri(id), subDir, params);
flash.put("info", MessagesUtils.get("resources.filesystem.export.update"));
fileSystem(id);
}
use of com.emc.storageos.model.file.FileShareExportUpdateParams 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;
}
use of com.emc.storageos.model.file.FileShareExportUpdateParams in project coprhd-controller by CoprHD.
the class FileSystems method deleteFileSystemExport.
@FlashException(referrer = { "fileSystem" })
public static void deleteFileSystemExport(String fileSystemId, String security, String exportPath) {
ViPRCoreClient client = BourneUtil.getViprClient();
ExportRule rule = new ExportRule();
rule.setSecFlavor(security);
List<ExportRule> list = Lists.newArrayList();
list.add(rule);
ExportRules exportRules = new ExportRules();
exportRules.setExportRules(list);
FileShareExportUpdateParams params = new FileShareExportUpdateParams();
params.setExportRulesToDelete(exportRules);
FileShareRestRep fileSystem = client.fileSystems().get(uri(fileSystemId));
String subDir = FileUtils.findSubDirectory(fileSystem.getMountPath(), exportPath);
client.fileSystems().updateExport(uri(fileSystemId), subDir, params);
flash.put("info", MessagesUtils.get("resources.filesystem.export.deactivate"));
fileSystem(fileSystemId);
}
Aggregations