Search in sources :

Example 1 with IsilonNFSACL

use of com.emc.storageos.isilon.restapi.IsilonNFSACL in project coprhd-controller by CoprHD.

the class IsilonFileStorageDevice method getIsilonAclFromNfsACE.

/**
 * getIsilonAclFromNfsACE function will convert the nfsACE object to Isilon
 * ACL object.
 *
 * @param nfsACE
 *            vipr ACE object.
 * @return
 */
private Acl getIsilonAclFromNfsACE(NfsACE nfsACE) {
    IsilonNFSACL isilonAcl = new IsilonNFSACL();
    Acl acl = isilonAcl.new Acl();
    ArrayList<String> inheritFlags = new ArrayList<String>();
    // Set empty inherit flag for now TODO make it user configurable.
    acl.setInherit_flags(inheritFlags);
    acl.setAccessrights(getIsilonAccessList(nfsACE.getPermissionSet()));
    acl.setOp("add");
    acl.setAccesstype(nfsACE.getPermissionType());
    String user = nfsACE.getUser();
    String domain = nfsACE.getDomain();
    if (domain != null && !domain.isEmpty()) {
        user = domain + "\\" + user;
    }
    String sid = null;
    if (nfsACE.getSid() != null && !nfsACE.getSid().isEmpty()) {
        sid = nfsACE.getSid();
    }
    IsilonNFSACL.Persona trustee = isilonAcl.new Persona(nfsACE.getType(), sid, user);
    acl.setTrustee(trustee);
    return acl;
}
Also used : IsilonNFSACL(com.emc.storageos.isilon.restapi.IsilonNFSACL) ArrayList(java.util.ArrayList) Acl(com.emc.storageos.isilon.restapi.IsilonNFSACL.Acl)

Example 2 with IsilonNFSACL

use of com.emc.storageos.isilon.restapi.IsilonNFSACL 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 3 with IsilonNFSACL

use of com.emc.storageos.isilon.restapi.IsilonNFSACL in project coprhd-controller by CoprHD.

the class IsilonCommunicationInterface method setUnmanagedNfsShareACL.

/**
 * get UnManaged NFS Shares and their ACLs
 *
 * @param unManagedFileSystem
 * @param unManagedNfsACLList
 * @param storagePort
 * @param fs
 * @param isilonApi
 */
private void setUnmanagedNfsShareACL(UnManagedFileSystem unManagedFileSystem, StorageSystem storageSystem, IsilonApi isilonApi, Set<String> fsExportPaths, List<UnManagedNFSShareACL> unManagedNfsACLList, List<UnManagedNFSShareACL> oldunManagedNfsShareACLList) {
    UnManagedNFSShareACL existingNfsACL;
    for (String exportPath : fsExportPaths) {
        _log.info("getUnmanagedNfsShareACL for UnManagedFileSystem file path{} - start", exportPath);
        if (exportPath == null || exportPath.isEmpty()) {
            _log.info("Export path is empty");
            continue;
        }
        try {
            IsilonNFSACL isilonNFSAcl = isilonApi.getNFSACL(exportPath);
            for (IsilonNFSACL.Acl tempAcl : isilonNFSAcl.getAcl()) {
                if (tempAcl.getTrustee() != null) {
                    UnManagedNFSShareACL unmanagedNFSAcl = new UnManagedNFSShareACL();
                    unmanagedNFSAcl.setFileSystemPath(exportPath);
                    // and avoid null pointers too
                    if (tempAcl.getTrustee().getName() != null) {
                        String[] tempUname = StringUtils.split(tempAcl.getTrustee().getName(), "\\");
                        if (tempUname.length > 1) {
                            unmanagedNFSAcl.setDomain(tempUname[0]);
                            unmanagedNFSAcl.setUser(tempUname[1]);
                        } else {
                            unmanagedNFSAcl.setUser(tempUname[0]);
                        }
                        unmanagedNFSAcl.setType(tempAcl.getTrustee().getType());
                        unmanagedNFSAcl.setPermissionType(tempAcl.getAccesstype());
                        unmanagedNFSAcl.setPermissions(StringUtils.join(getIsilonAccessList(tempAcl.getAccessrights()), ","));
                        unmanagedNFSAcl.setFileSystemId(unManagedFileSystem.getId());
                        unmanagedNFSAcl.setId(URIUtil.createId(UnManagedNFSShareACL.class));
                        _log.info("Unmanaged File share acls : {}", unmanagedNFSAcl);
                        String fsShareNativeId = unmanagedNFSAcl.getFileSystemNfsACLIndex();
                        _log.info("UMFS Share ACL index {}", fsShareNativeId);
                        String fsUnManagedFileShareNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileShare(storageSystem, fsShareNativeId);
                        _log.info("Native GUID {}", fsUnManagedFileShareNativeGuid);
                        // set native guid, so each entry unique
                        unmanagedNFSAcl.setNativeGuid(fsUnManagedFileShareNativeGuid);
                        unManagedNfsACLList.add(unmanagedNFSAcl);
                        // Check whether the NFS share ACL was present in ViPR DB.
                        existingNfsACL = checkUnManagedFsNfssACLExistsInDB(_dbClient, unmanagedNFSAcl.getNativeGuid());
                        if (existingNfsACL != null) {
                            // delete the existing acl
                            existingNfsACL.setInactive(true);
                            oldunManagedNfsShareACLList.add(existingNfsACL);
                        }
                    } else {
                        _log.warn("Trustee name is null, and so skipping the File share ACL entry");
                    }
                }
                if (unManagedNfsACLList != null && !unManagedNfsACLList.isEmpty()) {
                    unManagedFileSystem.setHasNFSAcl(true);
                }
            }
        } catch (Exception ex) {
            _log.warn("Unble to access NFS ACLs for path {}", exportPath);
        }
    }
}
Also used : IsilonNFSACL(com.emc.storageos.isilon.restapi.IsilonNFSACL) UnManagedNFSShareACL(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedNFSShareACL) IsilonException(com.emc.storageos.isilon.restapi.IsilonException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) IOException(java.io.IOException) JSONException(org.codehaus.jettison.json.JSONException) URISyntaxException(java.net.URISyntaxException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) IsilonCollectionException(com.emc.storageos.plugins.metering.isilon.IsilonCollectionException)

Example 4 with IsilonNFSACL

use of com.emc.storageos.isilon.restapi.IsilonNFSACL 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)

Aggregations

IsilonNFSACL (com.emc.storageos.isilon.restapi.IsilonNFSACL)4 Acl (com.emc.storageos.isilon.restapi.IsilonNFSACL.Acl)3 ArrayList (java.util.ArrayList)3 IsilonApi (com.emc.storageos.isilon.restapi.IsilonApi)2 IsilonException (com.emc.storageos.isilon.restapi.IsilonException)2 NfsACE (com.emc.storageos.model.file.NfsACE)2 IsilonCollectionException (com.emc.storageos.plugins.metering.isilon.IsilonCollectionException)2 BiosCommandResult (com.emc.storageos.volumecontroller.impl.BiosCommandResult)2 URISyntaxException (java.net.URISyntaxException)2 UnManagedNFSShareACL (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedNFSShareACL)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)1 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)1 ServiceCoded (com.emc.storageos.svcs.errorhandling.model.ServiceCoded)1 ControllerException (com.emc.storageos.volumecontroller.ControllerException)1 IOException (java.io.IOException)1 JSONException (org.codehaus.jettison.json.JSONException)1