Search in sources :

Example 6 with NfsACE

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

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

the class NfsACLUtility method getNFSAce.

/**
 * This function is to convert DB object into NfsACE object
 *
 * @param orig provided DB object
 * @return the REST representation of NFS ACE
 */
private NfsACE getNFSAce(NFSShareACL orig) {
    NfsACE dest = new NfsACE();
    dest.setDomain(orig.getDomain());
    dest.setPermissions(orig.getPermissions());
    dest.setPermissionType(FileControllerConstants.NFS_FILE_PERMISSION_TYPE_ALLOW);
    if (orig.getPermissionType() != null && !orig.getPermissionType().isEmpty()) {
        dest.setPermissionType(orig.getPermissionType());
    }
    dest.setType(REQUEST_PARAM_USER);
    if (orig.getType() != null && !orig.getType().isEmpty()) {
        dest.setType(orig.getType());
    }
    dest.setUser(orig.getUser());
    return dest;
}
Also used : NfsACE(com.emc.storageos.model.file.NfsACE)

Example 8 with NfsACE

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

the class IsilonFileStorageDevice method updateNfsACLs.

@Override
public BiosCommandResult updateNfsACLs(StorageSystem storage, FileDeviceInputOutput args) {
    try {
        // read nameToSid flag from controller config.
        Boolean sidEnable = customConfigHandler.getComputedCustomConfigBooleanValue(CustomConfigConstants.ISILON_USER_TO_SID_MAPPING_FOR_NFS_ENABLED, storage.getSystemType(), null);
        // get sid mapping based on Controller config and it belong to VirtualNAS.
        if (sidEnable && args.getvNAS() != null) {
            updateSidInfoForNfsACE(args, storage);
        }
        IsilonNFSACL isilonAcl = new IsilonNFSACL();
        ArrayList<Acl> aclCompleteList = new ArrayList<Acl>();
        List<NfsACE> aceToAdd = args.getNfsAclsToAdd();
        for (NfsACE nfsACE : aceToAdd) {
            Acl acl = getIsilonAclFromNfsACE(nfsACE);
            acl.setOp("add");
            aclCompleteList.add(acl);
        }
        List<NfsACE> aceToModify = args.getNfsAclsToModify();
        for (NfsACE nfsACE : aceToModify) {
            Acl acl = getIsilonAclFromNfsACE(nfsACE);
            acl.setOp("replace");
            aclCompleteList.add(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: modify NFS Acl for {}, acl  {}", args.getFileSystemPath(), isilonAcl);
        isi.modifyNFSACL(path, isilonAcl);
        _log.info("End updateNfsACLs");
        BiosCommandResult result = BiosCommandResult.createSuccessfulResult();
        return result;
    } catch (IsilonException e) {
        _log.error("updateNfsACLs failed ", e);
        return BiosCommandResult.createErrorResult(e);
    } catch (Exception e) {
        _log.error("updateNfsACLs failed ", e);
        final ServiceCoded serviceCoded = DeviceControllerException.errors.jobFailedOpMsg(OperationTypeEnum.UPDATE_FILE_SYSTEM_NFS_ACL.toString(), e.getMessage());
        return BiosCommandResult.createErrorResult(serviceCoded);
    }
}
Also used : NfsACE(com.emc.storageos.model.file.NfsACE) ArrayList(java.util.ArrayList) Acl(com.emc.storageos.isilon.restapi.IsilonNFSACL.Acl) IsilonException(com.emc.storageos.isilon.restapi.IsilonException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) URISyntaxException(java.net.URISyntaxException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) IsilonCollectionException(com.emc.storageos.plugins.metering.isilon.IsilonCollectionException) IsilonNFSACL(com.emc.storageos.isilon.restapi.IsilonNFSACL) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Example 9 with NfsACE

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

the class FileSystems method saveNfsAce.

@FlashException(referrer = { "fileSystem" })
public static void saveNfsAce(NfsACLForm nfsACL) {
    String name = params.get("name");
    String type = params.get("type");
    String domain = params.get("domain");
    String subDir = params.get("subDir");
    String fsMountPath = params.get("fsMountPath");
    String fileSystemId = params.get("fileSystemId");
    Set<String> permissions = nfsACL.permissions;
    String permissionType = nfsACL.permissionType;
    String strPer = "";
    nfsACL.validate("nfsACL");
    if (Validation.hasErrors()) {
        Common.handleError();
    }
    for (String permission : permissions) {
        strPer = strPer + permission.toLowerCase() + ",";
    }
    strPer = strPer.substring(0, strPer.length() - 1);
    List<NfsACE> aces = Lists.newArrayList();
    NfsACE nfsAce = new NfsACE();
    nfsAce.setType(type.toLowerCase());
    nfsAce.setUser(name);
    nfsAce.setPermissions(strPer);
    nfsAce.setPermissionType(permissionType);
    if (domain != null && !"".equals(domain) && !"null".equals(domain)) {
        nfsAce.setDomain(domain);
    }
    aces.add(nfsAce);
    FileNfsACLUpdateParams input = new FileNfsACLUpdateParams();
    input.setAcesToModify(aces);
    if (subDir != null && !"null".equals(subDir)) {
        input.setSubDir(subDir);
    }
    ViPRCoreClient client = BourneUtil.getViprClient();
    client.fileSystems().updateNfsACL(uri(fileSystemId), input);
    listNfsAcl(fileSystemId, fsMountPath, subDir);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) NfsACE(com.emc.storageos.model.file.NfsACE) FileNfsACLUpdateParams(com.emc.storageos.model.file.FileNfsACLUpdateParams) FlashException(controllers.util.FlashException)

Example 10 with NfsACE

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

the class FileSystems method createNfsAclParams.

private static FileNfsACLUpdateParams createNfsAclParams(String formData) {
    String[] uiAcls = formData.split(",");
    List<NfsACE> aces = Lists.newArrayList();
    for (String uiAce : uiAcls) {
        String[] uiData = uiAce.split("~~~");
        String uiType = uiData[0];
        String uiName = uiData[1];
        String uiDomain = uiData[2];
        String uiPermissions = uiData[3];
        String uiPermissiontype = uiData[4];
        NfsACE nfsAce = new NfsACE();
        nfsAce.setUser(uiName);
        if (uiDomain != null && !"".equals(uiDomain) && !"null".equals(uiDomain)) {
            nfsAce.setDomain(uiDomain);
        }
        if (uiType != null && !"".equals(uiType) && !"null".equals(uiType)) {
            nfsAce.setType(uiType);
        }
        if (uiPermissions != null && !"".equals(uiPermissions) && !"null".equals(uiPermissions)) {
            nfsAce.setPermissions(uiPermissions.replaceAll("/", ","));
        }
        nfsAce.setPermissionType(uiPermissiontype);
        aces.add(nfsAce);
    }
    FileNfsACLUpdateParams input = new FileNfsACLUpdateParams();
    input.setAcesToAdd(aces);
    return input;
}
Also used : NfsACE(com.emc.storageos.model.file.NfsACE) FileNfsACLUpdateParams(com.emc.storageos.model.file.FileNfsACLUpdateParams)

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