Search in sources :

Example 16 with NfsACE

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

the class FileSystems method removeNfsAcl.

@FlashException(referrer = { "fileSystem" })
public static void removeNfsAcl(@As(",") String[] ids) {
    List<NfsACE> aces = Lists.newArrayList();
    String fileSystem = null;
    String subDir = null;
    String fsMountPath = null;
    if (ids != null && ids.length > 0) {
        for (String id : ids) {
            String type = NfsACLForm.extractTypeFromId(id);
            String name = NfsACLForm.extractNameFromId(id);
            String domain = NfsACLForm.extractDomainFromId(id);
            String permissions = NfsACLForm.extractPermissionsFromId(id);
            String permissionType = NfsACLForm.extractPermissionTypeFromId(id);
            fileSystem = NfsACLForm.extractFileSystemFromId(id);
            subDir = NfsACLForm.extractSubDirFromId(id);
            fsMountPath = NfsACLForm.extractMounPathFromId(id);
            NfsACE ace = new NfsACE();
            ace.setUser(name);
            ace.setType(type);
            ace.setPermissions(permissions.replaceAll("/", ","));
            ace.setPermissionType(permissionType);
            if (domain != null && !"".equals(domain) && !"null".equals(domain)) {
                ace.setDomain(domain);
            }
            aces.add(ace);
        }
        FileNfsACLUpdateParams input = new FileNfsACLUpdateParams();
        input.setAcesToDelete(aces);
        if (subDir != null && !"null".equals(subDir)) {
            input.setSubDir(subDir);
        }
        ViPRCoreClient client = BourneUtil.getViprClient();
        client.fileSystems().updateNfsACL(uri(fileSystem), input);
    }
    flash.success(MessagesUtils.get(DELETED));
    listNfsAcl(fileSystem, 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 17 with NfsACE

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

the class NfsACLUtility method validateNfsAceSyntax.

/**
 * To verify the syntax of payload
 *
 * @param nfsAces list of the ACE need to be validated
 */
private void validateNfsAceSyntax(List<NfsACE> nfsAces) {
    for (NfsACE ace : nfsAces) {
        // PermissionType is optional , if provided check it is proper
        if (ace.getPermissionType() != null && !ace.getPermissionType().isEmpty()) {
            if (!isValidEnum(ace.getPermissionType(), NfsPermissionType.class)) {
                throw APIException.badRequests.invalidPermissionType(ace.getPermissionType());
            }
        }
        // user type is optional , if provided check it is proper
        if (ace.getType() != null && !ace.getType().isEmpty()) {
            if (!isValidEnum(ace.getType(), NfsUserType.class)) {
                throw APIException.badRequests.invalidUserType(ace.getType());
            }
        }
        for (String permission : ace.getPermissionSet()) {
            if (!isValidEnum(permission, NfsPermission.class)) {
                throw APIException.badRequests.invalidNFSPermission(permission);
            }
        }
        // check if two times domain is provided
        int index = ace.getUser().indexOf("\\");
        if (index >= 0) {
            if (ace.getDomain() != null && !ace.getDomain().isEmpty()) {
                throw APIException.badRequests.multipleDomainsFound("update", ace.getDomain(), ace.getUser().substring(0, index));
            } else {
                // verify the username provided with domain and user
                String[] domainAndUser = ace.getUser().split("\\");
                if (domainAndUser.length > 2) {
                    throw APIException.badRequests.multipleDomainsFound("update", domainAndUser[0], domainAndUser[1]);
                }
                // this is required to store value in DB in one format
                if (domainAndUser.length == 2) {
                    ace.setDomain(domainAndUser[0]);
                    ace.setUser(domainAndUser[1]);
                }
            }
        }
    }
}
Also used : NfsACE(com.emc.storageos.model.file.NfsACE) NfsUserType(com.emc.storageos.model.file.NfsACE.NfsUserType) NfsPermissionType(com.emc.storageos.model.file.NfsACE.NfsPermissionType) NfsPermission(com.emc.storageos.model.file.NfsACE.NfsPermission) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint)

Example 18 with NfsACE

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

the class NfsACLUtility method verifyNfsACLs.

/**
 * This function verify the NfsACLUpdateParams data provided by user to set ACL is valid or not
 * it throw exception for invalid NfsACLUpdateParams data
 *
 * @param param : input ACLs to be updated.
 */
public void verifyNfsACLs(NfsACLUpdateParams param) {
    List<NfsACE> addList = param.getAcesToAdd();
    List<NfsACE> modifyList = param.getAcesToModify();
    List<NfsACE> deleteList = param.getAcesToDelete();
    List<NFSShareACL> dbACLList = queryDBSFileNfsACLs(false);
    Set<String> userSetDB = new HashSet<String>();
    for (NFSShareACL dbAcl : dbACLList) {
        userSetDB.add(dbAcl.getUser());
    }
    if (addList != null && !addList.isEmpty()) {
        verifyNfsACLsAddList(addList, userSetDB);
    }
    if (modifyList != null && !modifyList.isEmpty()) {
        verifyNfsACLsModifyOrDeleteList(modifyList, userSetDB);
    }
    if (deleteList != null && !deleteList.isEmpty()) {
        verifyNfsACLsModifyOrDeleteList(deleteList, userSetDB);
    }
}
Also used : NfsACE(com.emc.storageos.model.file.NfsACE) NFSShareACL(com.emc.storageos.db.client.model.NFSShareACL) HashSet(java.util.HashSet)

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