Search in sources :

Example 11 with NfsACE

use of com.emc.storageos.model.file.NfsACE 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 12 with NfsACE

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

the class IsilonFileStorageDevice method updateSidInfoForNfsACE.

private void updateSidInfoForNfsACE(FileDeviceInputOutput args, StorageSystem storage) {
    IsilonApi isi = getIsilonDevice(storage);
    List<NfsACE> list = new ArrayList<NfsACE>();
    list.addAll(args.getNfsAclsToAdd());
    list.addAll(args.getNfsAclsToModify());
    list.addAll(args.getNfsAclsToDelete());
    for (NfsACE nfsACE : list) {
        String id = getIdForDomainUserOrGroup(isi, args.getvNAS(), nfsACE.getDomain(), nfsACE.getUser(), nfsACE.getType(), true);
        if (!id.isEmpty()) {
            nfsACE.setSid(id);
        }
    }
}
Also used : NfsACE(com.emc.storageos.model.file.NfsACE) ArrayList(java.util.ArrayList) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi)

Example 13 with NfsACE

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

the class IsilonFileStorageDevice method deleteNfsACLs.

@Override
public BiosCommandResult deleteNfsACLs(StorageSystem storage, FileDeviceInputOutput args) {
    IsilonNFSACL isilonAcl = new IsilonNFSACL();
    ArrayList<Acl> aclCompleteList = new ArrayList<Acl>();
    List<NfsACE> aceToDelete = args.getNfsAclsToDelete();
    for (NfsACE nfsACE : aceToDelete) {
        Acl acl = getIsilonAclFromNfsACE(nfsACE);
        acl.setOp("delete");
        aclCompleteList.add(acl);
    }
    isilonAcl.setAction("update");
    isilonAcl.setAuthoritative("acl");
    isilonAcl.setAcl(aclCompleteList);
    String path = args.getFileSystemPath();
    if (args.getSubDirectory() != null && !args.getSubDirectory().isEmpty()) {
        path = path + "/" + args.getSubDirectory();
    }
    // Process new ACLs
    IsilonApi isi = getIsilonDevice(storage);
    _log.info("Calling Isilon API: to delete NFS Acl for  {}, acl  {}", args.getFileSystemPath(), isilonAcl);
    isi.modifyNFSACL(path, isilonAcl);
    _log.info("End deleteNfsACLs");
    BiosCommandResult result = BiosCommandResult.createSuccessfulResult();
    return result;
}
Also used : NfsACE(com.emc.storageos.model.file.NfsACE) IsilonNFSACL(com.emc.storageos.isilon.restapi.IsilonNFSACL) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) ArrayList(java.util.ArrayList) Acl(com.emc.storageos.isilon.restapi.IsilonNFSACL.Acl) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi)

Example 14 with NfsACE

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

the class FileOrchestrationUtils method convertNFSShareACLToNfsACE.

public static NfsACE convertNFSShareACLToNfsACE(NFSShareACL dbNFSAcl) {
    NfsACE dest = new NfsACE();
    dest.setDomain(dbNFSAcl.getDomain());
    dest.setPermissions(dbNFSAcl.getPermissions());
    dest.setPermissionType(FileControllerConstants.NFS_FILE_PERMISSION_TYPE_ALLOW);
    if (dbNFSAcl.getPermissionType() != null && !dbNFSAcl.getPermissionType().isEmpty()) {
        dest.setPermissionType(dbNFSAcl.getPermissionType());
    }
    dest.setType("user");
    if (dbNFSAcl.getType() != null && !dbNFSAcl.getType().isEmpty()) {
        dest.setType(dbNFSAcl.getType());
    }
    dest.setUser(dbNFSAcl.getUser());
    return dest;
}
Also used : NfsACE(com.emc.storageos.model.file.NfsACE)

Example 15 with NfsACE

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

the class FileOrchestrationUtils method queryNFSACL.

public static Map<String, List<NfsACE>> queryNFSACL(FileShare fs, DbClient dbClient) {
    Map<String, List<NfsACE>> map = new HashMap<String, List<NfsACE>>();
    ContainmentConstraint containmentConstraint = ContainmentConstraint.Factory.getFileNfsAclsConstraint(fs.getId());
    List<NFSShareACL> nfsAclList = CustomQueryUtility.queryActiveResourcesByConstraint(dbClient, NFSShareACL.class, containmentConstraint);
    if (nfsAclList != null) {
        Iterator<NFSShareACL> aclIter = nfsAclList.iterator();
        while (aclIter.hasNext()) {
            NFSShareACL dbNFSAcl = aclIter.next();
            String fsPath = dbNFSAcl.getFileSystemPath();
            NfsACE ace = convertNFSShareACLToNfsACE(dbNFSAcl);
            if (map.get(fsPath) == null) {
                List<NfsACE> acl = new ArrayList<NfsACE>();
                acl.add(ace);
                map.put(fsPath, acl);
            } else {
                map.get(fsPath).add(ace);
            }
        }
    }
    return map;
}
Also used : ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) NfsACE(com.emc.storageos.model.file.NfsACE) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) NFSShareACL(com.emc.storageos.db.client.model.NFSShareACL)

Aggregations

NfsACE (com.emc.storageos.model.file.NfsACE)18 ArrayList (java.util.ArrayList)7 NFSShareACL (com.emc.storageos.db.client.model.NFSShareACL)6 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)4 FileNfsACLUpdateParams (com.emc.storageos.model.file.FileNfsACLUpdateParams)4 ControllerException (com.emc.storageos.volumecontroller.ControllerException)4 IsilonApi (com.emc.storageos.isilon.restapi.IsilonApi)3 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)3 WorkflowException (com.emc.storageos.workflow.WorkflowException)3 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)3 URISyntaxException (java.net.URISyntaxException)3 HashMap (java.util.HashMap)3 List (java.util.List)3 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)2 FileShare (com.emc.storageos.db.client.model.FileShare)2 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)2 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)2 IsilonNFSACL (com.emc.storageos.isilon.restapi.IsilonNFSACL)2 Acl (com.emc.storageos.isilon.restapi.IsilonNFSACL.Acl)2 NfsACL (com.emc.storageos.model.file.NfsACL)2