use of com.emc.storageos.model.file.ExportRules 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.ExportRules 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.ExportRules 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.ExportRules in project coprhd-controller by CoprHD.
the class FileSystems method getExport.
/**
* Gets the list of export rules for the given file system by ID.
* <p>
* API Call: <tt>GET /file/filesystems/{id}/export</tt>
*
* @param id
* the ID of the file system.
* @param allDirs
* boolean value for indicating for all directories
* @param subDir
* string indicating on what subdirectory to query
* @return the list of export rules for the file system.
*/
public List<ExportRule> getExport(URI id, boolean allDirs, String subDir) {
UriBuilder builder = client.uriBuilder(getExportUrl());
if (allDirs) {
builder.queryParam(ALLDIR_PARAM, allDirs);
} else if (subDir != null) {
builder.queryParam(SUBDIR_PARAM, subDir);
}
URI targetUri = builder.build(id);
ExportRules response = client.getURI(ExportRules.class, targetUri);
return defaultList(response.getExportRules());
}
use of com.emc.storageos.model.file.ExportRules in project coprhd-controller by CoprHD.
the class FileSnapshots method getExport.
/**
* Gets the list of export rules for the given file system by ID.
* <p>
* API Call: <tt>GET /file/snapshots/{id}/exports</tt>
*
* @param id
* the ID of the snapshot.
* @param allDirs
* boolean value for indicating for all directories
* @param subDir
* string indicating on what subdirectory to query
* @return the list of export rules for the file system.
*/
public List<ExportRule> getExport(URI id, boolean allDirs, String subDir) {
UriBuilder builder = client.uriBuilder(getExportUrl());
if (allDirs) {
builder.queryParam(ALLDIR_PARAM, allDirs);
} else if (subDir != null) {
builder.queryParam(SUBDIR_PARAM, subDir);
}
URI targetUri = builder.build(id);
ExportRules response = client.getURI(ExportRules.class, targetUri);
return defaultList(response.getExportRules());
}
Aggregations