Search in sources :

Example 1 with NfsACL

use of com.emc.storageos.model.file.NfsACL in project coprhd-controller by CoprHD.

the class NfsACLUtility method getNfsAclFromDB.

/**
 * This function return all the ACL in the DB in the format of xml Object
 *
 * @param allDirs if true function will return complete list of ACL including its SubDir
 * @return list of NFS ACLs.
 */
public NfsACLs getNfsAclFromDB(boolean allDirs) {
    NfsACLs acls = new NfsACLs();
    List<NfsACL> nfsAclList = new ArrayList<NfsACL>();
    Map<String, List<NfsACE>> nfsAclMap = new HashMap<String, List<NfsACE>>();
    _log.info("Sub-directory {} and allDirs {}", this.subDir, allDirs);
    // Query All ACl Specific to a File System.
    List<NFSShareACL> nfsAcls = queryDBSFileNfsACLs(allDirs);
    _log.info("Number of existing ACL found : {} ", nfsAcls.size());
    // Group the ACLs based on file system path!!!
    for (NFSShareACL nfsAcl : nfsAcls) {
        String fsPath = nfsAcl.getFileSystemPath();
        List<NfsACE> nfsAceList = nfsAclMap.get(fsPath);
        if (nfsAceList == null) {
            nfsAceList = new ArrayList<NfsACE>();
        }
        NfsACE ace = getNFSAce(nfsAcl);
        nfsAceList.add(ace);
        nfsAclMap.put(fsPath, nfsAceList);
    }
    // Convert all ACE to ACLs!!
    for (Map.Entry<String, List<NfsACE>> pathAcls : nfsAclMap.entrySet()) {
        String mountPath = pathAcls.getKey();
        NfsACL nfsAcl = new NfsACL(mountPath, pathAcls.getValue());
        if (mountPath.length() > fs.getPath().length()) {
            nfsAcl.setSubDir(mountPath.substring(fs.getPath().length() + 1));
        }
        nfsAclList.add(nfsAcl);
    }
    if (!nfsAclList.isEmpty()) {
        acls.setNfsACLs(nfsAclList);
    }
    return acls;
}
Also used : NfsACLs(com.emc.storageos.model.file.NfsACLs) NfsACL(com.emc.storageos.model.file.NfsACL) NfsACE(com.emc.storageos.model.file.NfsACE) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) NFSShareACL(com.emc.storageos.db.client.model.NFSShareACL)

Example 2 with NfsACL

use of com.emc.storageos.model.file.NfsACL 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));
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) NfsACL(com.emc.storageos.model.file.NfsACL) NfsACE(com.emc.storageos.model.file.NfsACE) NfsACLDataTable(models.datatable.NfsACLDataTable)

Example 3 with NfsACL

use of com.emc.storageos.model.file.NfsACL in project coprhd-controller by CoprHD.

the class FileSystems method fileSystemNfsACLs.

public static void fileSystemNfsACLs(String fileSystemId) {
    ViPRCoreClient client = BourneUtil.getViprClient();
    List<NfsACL> nfsAcls = client.fileSystems().getAllNfsACLs(uri(fileSystemId));
    render(nfsAcls);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) NfsACL(com.emc.storageos.model.file.NfsACL)

Aggregations

NfsACL (com.emc.storageos.model.file.NfsACL)3 NfsACE (com.emc.storageos.model.file.NfsACE)2 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)2 NFSShareACL (com.emc.storageos.db.client.model.NFSShareACL)1 NfsACLs (com.emc.storageos.model.file.NfsACLs)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 NfsACLDataTable (models.datatable.NfsACLDataTable)1