use of com.emc.storageos.model.file.ExportRule in project coprhd-controller by CoprHD.
the class FileUtils method getFSExportRulesInfo.
public static ExportRuleInfo getFSExportRulesInfo(URI id, String exportPath, String security) {
String path = StringUtils.defaultString(exportPath);
String sec = StringUtils.defaultString(security);
List<ExportRule> rules = getFSExportRules(id);
List<EndpointInfo> infos = Lists.newArrayList();
ExportRuleInfo exportRuleInfo = new ExportRuleInfo();
for (ExportRule rule : rules) {
if ((path.isEmpty() || rule.getExportPath().equals(path)) && (sec.isEmpty() || rule.getSecFlavor().equals(sec))) {
if (rule.getReadWriteHosts() != null && !rule.getReadWriteHosts().isEmpty()) {
for (String endpoint : rule.getReadWriteHosts()) {
infos.add(new EndpointInfo(endpoint, FileShareExport.Permissions.rw.name()));
}
}
if (rule.getReadOnlyHosts() != null && !rule.getReadOnlyHosts().isEmpty()) {
for (String endpoint : rule.getReadOnlyHosts()) {
infos.add(new EndpointInfo(endpoint, FileShareExport.Permissions.ro.name()));
}
}
if (rule.getRootHosts() != null && !rule.getRootHosts().isEmpty()) {
for (String endpoint : rule.getRootHosts()) {
infos.add(new EndpointInfo(endpoint, FileShareExport.Permissions.root.name()));
}
}
exportRuleInfo.setAnon(rule.getAnon());
exportRuleInfo.setSecurity(getSecurityFlavorList(rule.getSecFlavor()));
exportRuleInfo.setEndpointsInfo(infos);
}
}
return exportRuleInfo;
}
use of com.emc.storageos.model.file.ExportRule in project coprhd-controller by CoprHD.
the class FileUtils method getFSExportRules.
public static List<ExportRule> getFSExportRules(URI id) {
ViPRCoreClient client = BourneUtil.getViprClient();
List<ExportRule> rules = Lists.newArrayList();
if (URIUtil.isType(id, Snapshot.class)) {
rules = client.fileSnapshots().getExport(id, true, "");
} else if (URIUtil.isType(id, FileShare.class)) {
rules = client.fileSystems().getExport(id, true, "");
}
return rules;
}
use of com.emc.storageos.model.file.ExportRule in project coprhd-controller by CoprHD.
the class FileSnapshots method save.
@FlashException(referrer = { "snapshot" })
public static void save(Boolean edit, String id, String fsPath, String exportPath, String security, String anon, @As(",") List<String> ro, @As(",") List<String> rw, @As(",") List<String> root) {
ExportRule rule = new ExportRule();
rule.setAnon(anon);
rule.setSecFlavor(security);
// Clean up endpoints list by removing all empty items if any
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);
SnapshotExportUpdateParams params = new SnapshotExportUpdateParams();
if (!edit) {
params.setExportRulesToAdd(exportRules);
} else {
params.setExportRulesToModify(exportRules);
}
ViPRCoreClient client = BourneUtil.getViprClient();
client.fileSnapshots().updateExport(uri(id), null, params);
flash.put("info", MessagesUtils.get("resources.filesystem.export.update"));
snapshot(id);
}
use of com.emc.storageos.model.file.ExportRule in project coprhd-controller by CoprHD.
the class FileSnapshots method deleteSnapshotExport.
@FlashException(referrer = { "snapshot" })
public static void deleteSnapshotExport(String snapshotId, 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);
SnapshotExportUpdateParams params = new SnapshotExportUpdateParams();
params.setExportRulesToDelete(exportRules);
FileSnapshotRestRep snapshot = client.fileSnapshots().get(uri(snapshotId));
String subDir = FileUtils.findSubDirectory(snapshot.getMountPath(), exportPath);
client.fileSnapshots().updateExport(uri(snapshotId), subDir, params);
flash.put("info", MessagesUtils.get("resources.filesnapshot.export.deactivate"));
snapshot(snapshotId);
}
use of com.emc.storageos.model.file.ExportRule 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);
}
Aggregations