use of com.emc.vipr.client.ViPRCoreClient in project coprhd-controller by CoprHD.
the class FileSystems method fileSystemSnapshotPolicies.
@FlashException(referrer = { "fileSystem" })
public static void fileSystemSnapshotPolicies(String fileSystemId) {
ViPRCoreClient client = BourneUtil.getViprClient();
List<FilePolicyRestRep> filePolicies = Lists.newArrayList();
FileShareRestRep fs = client.fileSystems().get(uri(fileSystemId));
if (fs != null) {
// Get file system snapshot policies!!
if (fs.getFilePolicies() != null && !fs.getFilePolicies().isEmpty()) {
for (String uriPolicy : fs.getFilePolicies()) {
FilePolicyRestRep policyRestRep = client.fileProtectionPolicies().get(uri(uriPolicy));
if (policyRestRep != null) {
filePolicies.add(policyRestRep);
}
}
}
}
render(filePolicies);
}
use of com.emc.vipr.client.ViPRCoreClient in project coprhd-controller by CoprHD.
the class FileSystems method listAclJson.
/**
* This method called during population of Datatable for ACL data.
*
* @param aclURL
* URL of the file system share.
*/
public static void listAclJson(String aclURL) {
String fileSystem = null;
String shareName = null;
if (StringUtils.isNotBlank(aclURL)) {
String[] parts = aclURL.split("/");
if (parts.length == 7) {
fileSystem = parts[3];
shareName = parts[5];
}
}
ViPRCoreClient client = BourneUtil.getViprClient();
List<ShareACL> shareAcls = client.fileSystems().getShareACLs(uri(fileSystem), shareName);
List<ShareACLDataTable.AclInfo> acl = Lists.newArrayList();
for (ShareACL shareAcl : shareAcls) {
String userOrGroup = shareAcl.getUser();
String type = "User";
if (shareAcl.getGroup() != null && shareAcl.getGroup() != "") {
type = "Group";
userOrGroup = shareAcl.getGroup();
}
acl.add(new ShareACLDataTable.AclInfo(userOrGroup, type, shareAcl.getPermission(), fileSystem, shareName, shareAcl.getDomain()));
}
renderJSON(DataTablesSupport.createJSON(acl, params));
}
use of com.emc.vipr.client.ViPRCoreClient 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.vipr.client.ViPRCoreClient in project coprhd-controller by CoprHD.
the class FileSystems method listNfsAcl.
public static void listNfsAcl(String fileSystemId, String fsMountPath, String subDir) {
renderArgs.put("dataTable", new NfsACLDataTable());
renderArgs.put("subDir", subDir);
renderArgs.put("fileSystemId", uri(fileSystemId));
renderArgs.put("fsMountPath", fsMountPath);
renderArgs.put("fileSystemSubDirAndPath", fileSystemId + "~~~" + subDir + "~~~" + fsMountPath);
renderArgs.put("permissionOptions", StringOption.options(new String[] { "read", "write", "execute", "fullControl" }));
ViPRCoreClient client = BourneUtil.getViprClient();
NfsACLForm nfsACL = new NfsACLForm();
FileShareRestRep restRep = client.fileSystems().get(uri(fileSystemId));
renderArgs.put("fileSystemName", restRep.getName());
render(nfsACL);
}
use of com.emc.vipr.client.ViPRCoreClient in project coprhd-controller by CoprHD.
the class FileSystems method listNfsAclJson.
public static void listNfsAclJson(String fileSystemSubDirAndPath) {
renderArgs.put("dataTable", new NfsACLDataTable());
String fileSystemId = null;
String subDir = null;
String fsMountPath = null;
if (StringUtils.isNotBlank(fileSystemSubDirAndPath)) {
String[] parts = fileSystemSubDirAndPath.split("~~~");
if (parts.length == 3) {
fileSystemId = parts[0];
subDir = parts[1];
fsMountPath = parts[2];
}
}
renderArgs.put("subDir", subDir);
renderArgs.put("fsMountPath", fsMountPath);
renderArgs.put("fileSystemId", uri(fileSystemId));
renderArgs.put("fileSystemName", uri(fileSystemId));
ViPRCoreClient client = BourneUtil.getViprClient();
List<NfsACL> nfsAcls = client.fileSystems().getNfsACLs(uri(fileSystemId), subDir);
NfsACL nfsAcl = new NfsACL();
List<NfsACLDataTable.NfsAclInfo> nfsAccessControlList = Lists.newArrayList();
if (nfsAcls.size() > 0) {
nfsAcl = nfsAcls.get(0);
List<NfsACE> acl = nfsAcl.getNfsAces();
for (NfsACE ace : acl) {
String name = ace.getUser();
String type = ace.getType();
String permissions = ace.getPermissions();
String domain = ace.getDomain();
String permissionType = ace.getPermissionType();
nfsAccessControlList.add(new NfsACLDataTable.NfsAclInfo(name, type, permissions, fileSystemId, subDir, domain, fsMountPath, permissionType));
}
}
renderJSON(DataTablesSupport.createJSON(nfsAccessControlList, params));
}
Aggregations