Search in sources :

Example 1 with UnManagedNFSShareACL

use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedNFSShareACL 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 2 with UnManagedNFSShareACL

use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedNFSShareACL in project coprhd-controller by CoprHD.

the class IsilonCommunicationInterface method discoverUmanagedFileSystems.

private void discoverUmanagedFileSystems(AccessProfile profile) throws BaseCollectionException {
    List<UnManagedFileSystem> newUnManagedFileSystems = new ArrayList<>();
    List<UnManagedFileSystem> existingUnManagedFileSystems = new ArrayList<>();
    List<UnManagedFileQuotaDirectory> newUnManagedFileQuotaDir = new ArrayList<>();
    List<UnManagedFileQuotaDirectory> existingUnManagedFileQuotaDir = new ArrayList<>();
    List<UnManagedCifsShareACL> newUnManagedCifsShareACLList = new ArrayList<>();
    List<UnManagedCifsShareACL> oldUnManagedCifsShareACLList = new ArrayList<>();
    List<UnManagedNFSShareACL> newUnManagedNfsShareACLList = new ArrayList<>();
    List<UnManagedNFSShareACL> oldUnManagedNfsShareACLList = new ArrayList<>();
    List<UnManagedFileExportRule> newUnManagedExportRules = new ArrayList<>();
    List<UnManagedFileExportRule> oldUnManagedExportRules = new ArrayList<>();
    _log.debug("Access Profile Details :  IpAddress : PortNumber : {}, namespace : {}", profile.getIpAddress() + profile.getPortNumber(), profile.getnamespace());
    URI storageSystemId = profile.getSystemId();
    StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storageSystemId);
    if (null == storageSystem) {
        return;
    }
    Set<URI> allDiscoveredUnManagedFileSystems = new HashSet<>();
    String detailedStatusMessage = "Discovery of Isilon Unmanaged FileSystem started";
    long unmanagedFsCount = 0;
    try {
        IsilonApi isilonApi = getIsilonDevice(storageSystem);
        URIQueryResultList storagePoolURIs = new URIQueryResultList();
        _dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStoragePoolConstraint(storageSystem.getId()), storagePoolURIs);
        ArrayList<StoragePool> pools = new ArrayList<>();
        Iterator<URI> poolsItr = storagePoolURIs.iterator();
        while (poolsItr.hasNext()) {
            URI storagePoolURI = poolsItr.next();
            StoragePool storagePool = _dbClient.queryObject(StoragePool.class, storagePoolURI);
            if (storagePool != null && !storagePool.getInactive()) {
                pools.add(storagePool);
            }
        }
        StoragePool storagePool = null;
        if (pools != null && !pools.isEmpty()) {
            storagePool = pools.get(0);
        }
        StoragePort storagePort = getStoragePortPool(storageSystem);
        int totalIsilonFSDiscovered = 0;
        // get the associated storage port for vnas Server
        List<IsilonAccessZone> isilonAccessZones = isilonApi.getAccessZones(null);
        Map<String, NASServer> nasServers = validateAndGetNASServer(storageSystem, isilonAccessZones);
        // update the path from controller configuration
        updateDiscoveryPathForUnManagedFS(nasServers, storageSystem);
        // NFSv4 enabled on storage system!!!
        boolean isNfsV4Enabled = isilonApi.nfsv4Enabled(storageSystem.getFirmwareVersion());
        List<FileShare> discoveredFS = new ArrayList<>();
        String resumeToken = null;
        for (String umfsDiscoverPath : _discPathsForUnManaged) {
            IsilonAccessZone isilonAccessZone = getAccessZoneCorresDiscoveryPath(isilonAccessZones, umfsDiscoverPath);
            String isilonAccessZoneName;
            if (isilonAccessZone == null) {
                // System access zone
                isilonAccessZoneName = null;
            } else {
                isilonAccessZoneName = isilonAccessZone.getName();
            }
            // Get All SMB for this path access zone
            HashMap<String, HashSet<String>> zoneSMBShares = discoverAccessZoneSMBShares(storageSystem, isilonAccessZoneName);
            // Get all NFS Export for this path access zone
            HashMap<String, HashSet<Integer>> zoneNFSExports = discoverAccessZoneExports(storageSystem, isilonAccessZoneName);
            do {
                HashMap<String, Object> discoverdFileDetails = discoverAllFileSystem(storageSystem, resumeToken, umfsDiscoverPath);
                IsilonApi.IsilonList<FileShare> discoveredIsilonFS = (IsilonApi.IsilonList<FileShare>) discoverdFileDetails.get(UMFS_DETAILS);
                ArrayList<UnManagedFileQuotaDirectory> discoveredUmfsQd = (ArrayList<UnManagedFileQuotaDirectory>) discoverdFileDetails.get(UMFSQD_DETAILS);
                HashMap<String, HashSet<String>> umfsfileQuotaMap = (HashMap<String, HashSet<String>>) discoverdFileDetails.get(UMFS_QD_MAP);
                resumeToken = discoveredIsilonFS.getToken();
                discoveredFS = discoveredIsilonFS.getList();
                totalIsilonFSDiscovered += discoveredFS.size();
                for (FileShare fs : discoveredFS) {
                    if (!checkStorageFileSystemExistsInDB(fs.getNativeGuid())) {
                        // Create UnManaged FS
                        String fsPathName = fs.getPath();
                        UnManagedFileSystem unManagedFs = checkUnManagedFileSystemExistsInDB(fs.getNativeGuid());
                        if (unManagedFs != null) {
                            existingUnManagedFileSystems.add(unManagedFs);
                        }
                        // get the matched vNAS Server
                        NASServer nasServer = getMatchedNASServer(nasServers, fsPathName);
                        if (nasServer != null) {
                            // Get valid storage port from the NAS server!!!
                            _log.info("fs path {} and nas server details {}", fs.getPath(), nasServer.toString());
                            storagePort = getStoragePortFromNasServer(nasServer);
                            if (storagePort == null) {
                                _log.info("No valid storage port found for nas server {}", nasServer.toString());
                                continue;
                            }
                        } else {
                            _log.info("fs path {} and vnas server not found", fs.getPath());
                            // Skip further ingestion steps on this file share & move to next file share
                            continue;
                        }
                        unManagedFs = createUnManagedFileSystem(unManagedFs, fs.getNativeGuid(), storageSystem, storagePool, nasServer, fs);
                        unManagedFs.setHasNFSAcl(false);
                        newUnManagedFileSystems.add(unManagedFs);
                        /**
                         * Set and create the NFS ACLs only if the system is enabled with NFSv4!!!
                         */
                        HashMap<String, HashSet<Integer>> exportWithIdMap = getExportsIncludingSubDir(fs.getPath(), zoneNFSExports, umfsfileQuotaMap);
                        if (isNfsV4Enabled) {
                            Set<String> fsExportPaths = exportWithIdMap.keySet();
                            setUnmanagedNfsShareACL(unManagedFs, storageSystem, isilonApi, fsExportPaths, newUnManagedNfsShareACLList, oldUnManagedNfsShareACLList);
                        }
                        /**
                         * Set and Create Export Rules and export Map
                         */
                        if (!exportWithIdMap.keySet().isEmpty()) {
                            setUnManagedFSExportMap(unManagedFs, exportWithIdMap, storagePort, fs.getPath(), nasServer.getNasName(), isilonApi, storageSystem, newUnManagedExportRules, oldUnManagedExportRules);
                            _log.info("Number of exports discovered for file system {} is {}", unManagedFs.getId(), newUnManagedExportRules.size());
                            if (!newUnManagedExportRules.isEmpty()) {
                                unManagedFs.setHasExports(true);
                                _log.info("File System {} has Exports and their size is {}", unManagedFs.getId(), newUnManagedExportRules.size());
                            }
                        }
                        /**
                         * Create and set CIFS ACLS and SMB Share MAP
                         */
                        HashSet<String> shareIDs = getSharesIncludingSubDir(fs.getPath(), zoneSMBShares, umfsfileQuotaMap);
                        setUnmanagedCifsShareACL(unManagedFs, shareIDs, newUnManagedCifsShareACLList, storagePort, fs.getName(), nasServer.getNasName(), storageSystem, isilonApi, oldUnManagedCifsShareACLList);
                        _log.info("Number of shares ACLs discovered for file system {} is {}", unManagedFs.getId(), newUnManagedCifsShareACLList.size());
                        if (unManagedFs.getHasExports() || unManagedFs.getHasShares()) {
                            _log.info("FS {} is having exports/shares", fs.getPath());
                            unManagedFs.putFileSystemCharacterstics(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_FILESYSTEM_EXPORTED.toString(), TRUE);
                        } else {
                            _log.info("FS {} does not have export or share", fs.getPath());
                        }
                        /**
                         * Persist 200 objects and clear them to avoid memory issue
                         */
                        // save bunch of export rules in db
                        validateSizeLimitAndPersist(newUnManagedExportRules, oldUnManagedExportRules, Constants.DEFAULT_PARTITION_SIZE * 2);
                        // save bunch of ACLs in db
                        validateSizeLimitAndPersist(newUnManagedCifsShareACLList, oldUnManagedCifsShareACLList, Constants.DEFAULT_PARTITION_SIZE * 2);
                        // save bunch of NFS ACLs in db
                        validateSizeLimitAndPersist(newUnManagedNfsShareACLList, newUnManagedNfsShareACLList, Constants.DEFAULT_PARTITION_SIZE * 2);
                        allDiscoveredUnManagedFileSystems.add(unManagedFs.getId());
                        // save bunch of file system in db
                        validateListSizeLimitAndPersist(newUnManagedFileSystems, existingUnManagedFileSystems, Constants.DEFAULT_PARTITION_SIZE * 2);
                    }
                }
                for (UnManagedFileQuotaDirectory umfsQd : discoveredUmfsQd) {
                    if (!checkStorageQuotaDirectoryExistsInDB(umfsQd.getNativeGuid())) {
                        String fsUnManagedQdNativeGuid = NativeGUIDGenerator.generateNativeGuidForUnManagedQuotaDir(storageSystem.getSystemType(), storageSystem.getSerialNumber(), umfsQd.getNativeId(), "");
                        UnManagedFileQuotaDirectory unManagedFileQd = checkUnManagedFileSystemQuotaDirectoryExistsInDB(fsUnManagedQdNativeGuid);
                        boolean umfsQdExists = (unManagedFileQd == null) ? false : true;
                        if (umfsQdExists) {
                            umfsQd.setId(unManagedFileQd.getId());
                            existingUnManagedFileQuotaDir.add(umfsQd);
                        } else if (null != umfsQd) {
                            umfsQd.setId(URIUtil.createId(UnManagedFileQuotaDirectory.class));
                            newUnManagedFileQuotaDir.add(umfsQd);
                        }
                    }
                }
                // save bunch of QDs in db
                validateSizeLimitAndPersist(newUnManagedFileQuotaDir, existingUnManagedFileQuotaDir, Constants.DEFAULT_PARTITION_SIZE * 2);
            } while (resumeToken != null);
        }
        // Saving bunch of Unmanaged objects!!!
        if (!newUnManagedExportRules.isEmpty()) {
            _log.info("Saving Number of UnManagedFileExportRule(s) {}", newUnManagedExportRules.size());
            _dbClient.createObject(newUnManagedExportRules);
            newUnManagedExportRules.clear();
        }
        if (!oldUnManagedExportRules.isEmpty()) {
            _log.info("Saving Number of UnManagedFileExportRule(s) {}", newUnManagedExportRules.size());
            _dbClient.updateObject(newUnManagedExportRules);
            oldUnManagedExportRules.clear();
        }
        // save ACLs in db
        if (!newUnManagedCifsShareACLList.isEmpty()) {
            _log.info("Saving Number of UnManagedCifsShareACL(s) {}", newUnManagedCifsShareACLList.size());
            _dbClient.createObject(newUnManagedCifsShareACLList);
            newUnManagedCifsShareACLList.clear();
        }
        // save old acls
        if (!oldUnManagedCifsShareACLList.isEmpty()) {
            _log.info("Saving Number of UnManagedFileExportRule(s) {}", oldUnManagedCifsShareACLList.size());
            _dbClient.updateObject(oldUnManagedCifsShareACLList);
            oldUnManagedCifsShareACLList.clear();
        }
        // save NFS ACLs in db
        if (!newUnManagedNfsShareACLList.isEmpty()) {
            _log.info("Saving Number of UnManagedNfsShareACL(s) {}", newUnManagedNfsShareACLList.size());
            _dbClient.createObject(newUnManagedNfsShareACLList);
            newUnManagedNfsShareACLList.clear();
        }
        // save old acls
        if (!oldUnManagedNfsShareACLList.isEmpty()) {
            _log.info("Saving Number of NFS UnManagedFileExportRule(s) {}", oldUnManagedNfsShareACLList.size());
            _dbClient.updateObject(oldUnManagedNfsShareACLList);
            oldUnManagedNfsShareACLList.clear();
        }
        // save new QDs to DB
        if (!newUnManagedFileQuotaDir.isEmpty()) {
            _log.info("New unmanaged Isilon file systems QuotaDirecotry  count: {}", newUnManagedFileQuotaDir.size());
            _dbClient.createObject(newUnManagedFileQuotaDir);
        }
        // save old QDs
        if (!existingUnManagedFileQuotaDir.isEmpty()) {
            _log.info("Update unmanaged Isilon file systems QuotaDirectory count: {}", existingUnManagedFileQuotaDir.size());
            _dbClient.updateObject(existingUnManagedFileQuotaDir);
        }
        // save new FS
        if (!newUnManagedFileSystems.isEmpty()) {
            _dbClient.createObject(newUnManagedFileSystems);
        }
        // save old FS
        if (!existingUnManagedFileSystems.isEmpty()) {
            _dbClient.updateObject(existingUnManagedFileSystems);
        }
        _log.info("Discovered {} Isilon file systems.", totalIsilonFSDiscovered);
        // discovery succeeds
        detailedStatusMessage = String.format("Discovery completed successfully for Isilon: %s; new unmanaged file systems count: %s", storageSystemId.toString(), unmanagedFsCount);
        _log.info(detailedStatusMessage);
    } catch (IsilonException ex) {
        detailedStatusMessage = String.format("Discovery failed for Isilon %s because %s", storageSystemId.toString(), ex.getLocalizedMessage());
        _log.error(detailedStatusMessage, ex);
        throw ex;
    } catch (Exception e) {
        detailedStatusMessage = String.format("Discovery failed for Isilon %s because %s", storageSystemId.toString(), e.getLocalizedMessage());
        _log.error(detailedStatusMessage, e);
        throw new IsilonCollectionException(detailedStatusMessage);
    } finally {
        if (storageSystem != null) {
            try {
                // set detailed message
                storageSystem.setLastDiscoveryStatusMessage(detailedStatusMessage);
                _dbClient.updateObject(storageSystem);
            } catch (Exception ex) {
                _log.error("Error while persisting object to DB", ex);
            }
        }
    }
}
Also used : UnManagedFileExportRule(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileExportRule) StoragePool(com.emc.storageos.db.client.model.StoragePool) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) IsilonCollectionException(com.emc.storageos.plugins.metering.isilon.IsilonCollectionException) UnManagedNFSShareACL(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedNFSShareACL) URI(java.net.URI) IsilonList(com.emc.storageos.isilon.restapi.IsilonApi.IsilonList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) UnManagedFileSystem(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) HashSet(java.util.HashSet) UnManagedCifsShareACL(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedCifsShareACL) UnManagedFileQuotaDirectory(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileQuotaDirectory) IsilonStoragePort(com.emc.storageos.isilon.restapi.IsilonStoragePort) StoragePort(com.emc.storageos.db.client.model.StoragePort) IsilonAccessZone(com.emc.storageos.isilon.restapi.IsilonAccessZone) FileShare(com.emc.storageos.db.client.model.FileShare) UnManagedSMBFileShare(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBFileShare) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) 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) NASServer(com.emc.storageos.db.client.model.NASServer) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) DataObject(com.emc.storageos.db.client.model.DataObject) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Example 3 with UnManagedNFSShareACL

use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedNFSShareACL in project coprhd-controller by CoprHD.

the class ExtendedCommunicationInterfaceImpl method checkUnManagedFsNfssACLExistsInDB.

/**
 * check Pre Existing Storage NFS ACLs exists in DB
 *
 * @param dbClient
 * @param nfsNativeGuid
 * @return UnManagedNFSShareACL
 * @throws java.io.IOException
 */
protected UnManagedNFSShareACL checkUnManagedFsNfssACLExistsInDB(DbClient dbClient, String nfsACLNativeGuid) {
    UnManagedNFSShareACL unManagedNfsAcl = null;
    URIQueryResultList result = new URIQueryResultList();
    dbClient.queryByConstraint(AlternateIdConstraint.Factory.getFileNfsACLNativeGUIdConstraint(nfsACLNativeGuid), result);
    Iterator<URI> iter = result.iterator();
    while (iter.hasNext()) {
        URI cifsAclURI = iter.next();
        unManagedNfsAcl = dbClient.queryObject(UnManagedNFSShareACL.class, cifsAclURI);
        return unManagedNfsAcl;
    }
    return unManagedNfsAcl;
}
Also used : UnManagedNFSShareACL(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedNFSShareACL) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 4 with UnManagedNFSShareACL

use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedNFSShareACL in project coprhd-controller by CoprHD.

the class UnManagedFilesystemService method queryDBNfsShares.

/**
 * Query DB for UnManaged FileSystem's NFS ACL
 *
 * @param fs
 * @return List<UnManagedNFSShareACLs
 */
private List<UnManagedNFSShareACL> queryDBNfsShares(UnManagedFileSystem fs) {
    _logger.info("Querying All Nfs Share ACLs Using FsId {}", fs.getId());
    try {
        ContainmentConstraint containmentConstraint = ContainmentConstraint.Factory.getUnManagedNfsShareAclsConstraint(fs.getId());
        List<UnManagedNFSShareACL> nfsShareACLList = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, UnManagedNFSShareACL.class, containmentConstraint);
        return nfsShareACLList;
    } catch (Exception e) {
        _logger.error("Error while querying {}", e);
    }
    return new ArrayList<UnManagedNFSShareACL>();
}
Also used : ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) ArrayList(java.util.ArrayList) UnManagedNFSShareACL(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedNFSShareACL) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) IOException(java.io.IOException)

Example 5 with UnManagedNFSShareACL

use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedNFSShareACL in project coprhd-controller by CoprHD.

the class UnManagedFilesystemService method createNFSACL.

/**
 * copy unmanaged nfs share into new nfs share acls
 *
 * @param origACL
 * @param shareACLList
 * @param fileshare
 */
private void createNFSACL(UnManagedNFSShareACL origACL, List<NFSShareACL> shareACLList, FileShare fileshare) {
    NFSShareACL shareACL = new NFSShareACL();
    // user, permission, permission type
    shareACL.setFileSystemPath(origACL.getFileSystemPath());
    shareACL.setDomain(origACL.getDomain());
    shareACL.setType(origACL.getType());
    shareACL.setPermissionType(origACL.getPermissionType());
    String user = origACL.getUser();
    if (user != null) {
        shareACL.setUser(user);
    }
    String aclPermissions = origACL.getPermissions();
    if (!StringUtils.isEmpty(aclPermissions)) {
        StringBuilder permissionText = new StringBuilder();
        boolean isFirstPermissionSet = false;
        for (String tempPermission : aclPermissions.toLowerCase().split(",")) {
            switch(tempPermission) {
                case "read":
                    tempPermission = FileControllerConstants.NFS_FILE_PERMISSION_READ;
                    break;
                case "write":
                    tempPermission = FileControllerConstants.NFS_FILE_PERMISSION_WRITE;
                    break;
                case "execute":
                    tempPermission = FileControllerConstants.NFS_FILE_PERMISSION_EXECUTE;
                    break;
                case "fullcontrol":
                    tempPermission = FileControllerConstants.NFS_FILE_PERMISSION_FULLCONTROL;
                    break;
            }
            if (!isFirstPermissionSet) {
                permissionText.append(tempPermission);
                isFirstPermissionSet = true;
            } else {
                permissionText.append("," + tempPermission);
            }
        }
        shareACL.setPermissions(permissionText.toString());
    } else {
        shareACL.setPermissions("");
    }
    shareACL.setFileSystemId(fileshare.getId());
    shareACL.setId(URIUtil.createId(NFSShareACL.class));
    // Add new acl into ACL list
    shareACLList.add(shareACL);
    _logger.info("share ACLs details {}", shareACL.toString());
}
Also used : NFSShareACL(com.emc.storageos.db.client.model.NFSShareACL) UnManagedNFSShareACL(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedNFSShareACL)

Aggregations

UnManagedNFSShareACL (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedNFSShareACL)6 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)4 IOException (java.io.IOException)4 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)3 URI (java.net.URI)3 ArrayList (java.util.ArrayList)3 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)2 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)2 FileShare (com.emc.storageos.db.client.model.FileShare)2 NFSShareACL (com.emc.storageos.db.client.model.NFSShareACL)2 StoragePool (com.emc.storageos.db.client.model.StoragePool)2 StoragePort (com.emc.storageos.db.client.model.StoragePort)2 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)2 UnManagedCifsShareACL (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedCifsShareACL)2 UnManagedFileExportRule (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileExportRule)2 UnManagedFileSystem (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem)2 IsilonException (com.emc.storageos.isilon.restapi.IsilonException)2 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)2 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)2 HashMap (java.util.HashMap)2