Search in sources :

Example 26 with UnManagedFileSystem

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

the class IsilonCommunicationInterface method createUnManagedFileSystem.

/**
 * create StorageFileSystem Info Object
 *
 * @param unManagedFileSystem
 * @param unManagedFileSystemNativeGuid
 * @param storageSystem
 * @param fileSystem
 * @return UnManagedFileSystem
 * @throws IOException
 * @throws IsilonCollectionException
 */
private UnManagedFileSystem createUnManagedFileSystem(UnManagedFileSystem unManagedFileSystem, String unManagedFileSystemNativeGuid, StorageSystem storageSystem, StoragePool pool, NASServer nasServer, FileShare fileSystem) throws IOException, IsilonCollectionException {
    if (null == unManagedFileSystem) {
        unManagedFileSystem = new UnManagedFileSystem();
        unManagedFileSystem.setId(URIUtil.createId(UnManagedFileSystem.class));
        unManagedFileSystem.setNativeGuid(unManagedFileSystemNativeGuid);
        unManagedFileSystem.setStorageSystemUri(storageSystem.getId());
        if (null != pool) {
            unManagedFileSystem.setStoragePoolUri(pool.getId());
        }
        unManagedFileSystem.setHasExports(false);
        unManagedFileSystem.setHasShares(false);
        unManagedFileSystem.setHasNFSAcl(false);
    }
    if (null == unManagedFileSystem.getExtensions()) {
        unManagedFileSystem.setExtensions(new StringMap());
    }
    Map<String, StringSet> unManagedFileSystemInformation = new HashMap<String, StringSet>();
    StringMap unManagedFileSystemCharacteristics = new StringMap();
    unManagedFileSystemCharacteristics.put(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_SNAP_SHOT.toString(), FALSE);
    unManagedFileSystemCharacteristics.put(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_THINLY_PROVISIONED.toString(), TRUE);
    unManagedFileSystemCharacteristics.put(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_FILESYSTEM_EXPORTED.toString(), FALSE);
    if (null != pool) {
        StringSet pools = new StringSet();
        pools.add(pool.getId().toString());
        unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.STORAGE_POOL.toString(), pools);
        StringSet matchedVPools = DiscoveryUtils.getMatchedVirtualPoolsForPool(_dbClient, pool.getId(), unManagedFileSystemCharacteristics.get(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_THINLY_PROVISIONED.toString()));
        _log.debug("Matched Pools : {}", Joiner.on("\t").join(matchedVPools));
        if (null == matchedVPools || matchedVPools.isEmpty()) {
            // clear all existing supported vpools.
            unManagedFileSystem.getSupportedVpoolUris().clear();
        } else {
            // replace with new StringSet
            unManagedFileSystem.getSupportedVpoolUris().replace(matchedVPools);
            _log.info("Replaced Pools :" + Joiner.on("\t").join(unManagedFileSystem.getSupportedVpoolUris()));
        }
    }
    if (null != nasServer) {
        StringSet storagePorts = new StringSet();
        if (nasServer.getStoragePorts() != null && !nasServer.getStoragePorts().isEmpty()) {
            storagePorts.addAll(nasServer.getStoragePorts());
            unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.STORAGE_PORT.toString(), storagePorts);
            _log.info("StoragePorts :" + Joiner.on("\t").join(storagePorts));
        }
        StringSet nasServerSet = new StringSet();
        nasServerSet.add(nasServer.getId().toString());
        unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.NAS.toString(), nasServerSet);
        _log.debug("nasServer uri id {}", nasServer.getId().toString());
    }
    unManagedFileSystemCharacteristics.put(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_INGESTABLE.toString(), TRUE);
    if (null != storageSystem) {
        StringSet systemTypes = new StringSet();
        systemTypes.add(storageSystem.getSystemType());
        unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.SYSTEM_TYPE.toString(), systemTypes);
    }
    // Set attributes of FileSystem
    StringSet fsPath = new StringSet();
    fsPath.add(fileSystem.getNativeId());
    StringSet fsMountPath = new StringSet();
    fsMountPath.add(fileSystem.getMountPath());
    StringSet fsName = new StringSet();
    fsName.add(fileSystem.getName());
    StringSet fsId = new StringSet();
    fsId.add(fileSystem.getNativeId());
    StringSet softLimit = new StringSet();
    softLimit.add(fileSystem.getSoftLimit().toString());
    StringSet softGrace = new StringSet();
    softGrace.add(fileSystem.getSoftGracePeriod().toString());
    StringSet notificationLimit = new StringSet();
    notificationLimit.add(fileSystem.getNotificationLimit().toString());
    unManagedFileSystem.setLabel(fileSystem.getName());
    unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.NAME.toString(), fsName);
    unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.NATIVE_ID.toString(), fsId);
    unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.DEVICE_LABEL.toString(), fsName);
    unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.PATH.toString(), fsPath);
    unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.MOUNT_PATH.toString(), fsMountPath);
    unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.SOFT_LIMIT.toString(), softLimit);
    unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.SOFT_GRACE.toString(), softGrace);
    unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.NOTIFICATION_LIMIT.toString(), notificationLimit);
    StringSet provisionedCapacity = new StringSet();
    long capacity = 0;
    if (fileSystem.getCapacity() != null) {
        capacity = fileSystem.getCapacity();
    }
    provisionedCapacity.add(String.valueOf(capacity));
    unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.PROVISIONED_CAPACITY.toString(), provisionedCapacity);
    StringSet allocatedCapacity = new StringSet();
    long usedCapacity = 0;
    if (fileSystem.getUsedCapacity() != null) {
        usedCapacity = fileSystem.getUsedCapacity();
    }
    allocatedCapacity.add(String.valueOf(usedCapacity));
    unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.ALLOCATED_CAPACITY.toString(), allocatedCapacity);
    String quotaId = fileSystem.getExtensions().get(QUOTA);
    if (quotaId != null) {
        unManagedFileSystem.getExtensions().put(QUOTA, quotaId);
    }
    _log.debug("Quota : {}  : {}", quotaId, fileSystem.getPath());
    // Add fileSystemInformation and Characteristics.
    unManagedFileSystem.addFileSystemInformation(unManagedFileSystemInformation);
    unManagedFileSystem.addFileSystemCharacterstcis(unManagedFileSystemCharacteristics);
    // Initialize ExportMap
    unManagedFileSystem.setFsUnManagedExportMap(new UnManagedFSExportMap());
    // Initialize SMBMap
    unManagedFileSystem.setUnManagedSmbShareMap(new UnManagedSMBShareMap());
    return unManagedFileSystem;
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) UnManagedSMBShareMap(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBShareMap) StringSet(com.emc.storageos.db.client.model.StringSet) UnManagedFileSystem(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem) UnManagedFSExportMap(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFSExportMap)

Example 27 with UnManagedFileSystem

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

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

the class IsilonCommunicationInterface method checkUnManagedFileSystemExistsInDB.

/**
 * check Pre Existing Storage filesystem exists in DB
 *
 * @param nativeGuid
 * @return unManageFileSystem
 * @throws IOException
 */
protected UnManagedFileSystem checkUnManagedFileSystemExistsInDB(String nativeGuid) throws IOException {
    UnManagedFileSystem filesystemInfo = null;
    URIQueryResultList result = new URIQueryResultList();
    _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getFileSystemInfoNativeGUIdConstraint(nativeGuid), result);
    List<URI> filesystemUris = new ArrayList<URI>();
    Iterator<URI> iter = result.iterator();
    while (iter.hasNext()) {
        URI unFileSystemtURI = iter.next();
        filesystemUris.add(unFileSystemtURI);
    }
    for (URI fileSystemURI : filesystemUris) {
        filesystemInfo = _dbClient.queryObject(UnManagedFileSystem.class, fileSystemURI);
        if (filesystemInfo != null && !filesystemInfo.getInactive()) {
            return filesystemInfo;
        }
    }
    return null;
}
Also used : ArrayList(java.util.ArrayList) URI(java.net.URI) UnManagedFileSystem(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 29 with UnManagedFileSystem

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

the class NetAppClusterModeCommIntf method createUnManagedFileSystem.

/**
 * create StorageFileSystem Info Object
 *
 * @param unManagedFileSystem
 * @param unManagedFileSystemNativeGuid
 * @param storageSystemUri
 * @param storagePool
 * @param fileSystem
 * @param storagePort
 * @param fileSystemChars
 * @return UnManagedFileSystem
 * @throws IOException
 * @throws NetAppCException
 */
private UnManagedFileSystem createUnManagedFileSystem(UnManagedFileSystem unManagedFileSystem, AccessProfile profile, String unManagedFileSystemNativeGuid, String unManangedFileSystemNativeId, StorageSystem system, StoragePool pool, String fileSystem, StoragePort storagePort, Map<String, String> fileSystemChars) throws IOException, NetAppCException {
    if (null == unManagedFileSystem) {
        unManagedFileSystem = new UnManagedFileSystem();
        unManagedFileSystem.setId(URIUtil.createId(UnManagedFileSystem.class));
        unManagedFileSystem.setNativeGuid(unManagedFileSystemNativeGuid);
        unManagedFileSystem.setStorageSystemUri(system.getId());
        unManagedFileSystem.setHasExports(false);
        unManagedFileSystem.setHasShares(false);
    }
    Map<String, StringSet> unManagedFileSystemInformation = new HashMap<String, StringSet>();
    StringMap unManagedFileSystemCharacteristics = new StringMap();
    unManagedFileSystemCharacteristics.put(SupportedFileSystemCharacterstics.IS_SNAP_SHOT.toString(), FALSE);
    if (fileSystemChars.get(SupportedNtpFileSystemInformation.getFileSystemInformation(SupportedNtpFileSystemInformation.SPACE_GUARANTEE.toString())).equalsIgnoreCase(SPACE_GUARANTEE_NONE)) {
        unManagedFileSystemCharacteristics.put(SupportedFileSystemCharacterstics.IS_THINLY_PROVISIONED.toString(), TRUE);
    } else {
        unManagedFileSystemCharacteristics.put(SupportedFileSystemCharacterstics.IS_THINLY_PROVISIONED.toString(), FALSE);
    }
    unManagedFileSystemCharacteristics.put(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_INGESTABLE.toString(), TRUE);
    unManagedFileSystemCharacteristics.put(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_FILESYSTEM_EXPORTED.toString(), FALSE);
    if (null != storagePort) {
        StringSet storagePorts = new StringSet();
        storagePorts.add(storagePort.getId().toString());
        unManagedFileSystemInformation.put(SupportedFileSystemInformation.STORAGE_PORT.toString(), storagePorts);
    }
    if (null != pool) {
        StringSet pools = new StringSet();
        pools.add(pool.getId().toString());
        unManagedFileSystemInformation.put(UnManagedFileSystem.SupportedFileSystemInformation.STORAGE_POOL.toString(), pools);
        unManagedFileSystem.setStoragePoolUri(pool.getId());
        StringSet matchedVPools = DiscoveryUtils.getMatchedVirtualPoolsForPool(_dbClient, pool.getId());
        _logger.debug("Matched Pools : {}", Joiner.on("\t").join(matchedVPools));
        if (null == matchedVPools || matchedVPools.isEmpty()) {
            // Clear all existing matching vpools.
            unManagedFileSystem.getSupportedVpoolUris().clear();
        } else {
            // replace with new StringSet
            unManagedFileSystem.getSupportedVpoolUris().replace(matchedVPools);
            _logger.info("Replaced Pools :" + Joiner.on("\t").join(unManagedFileSystem.getSupportedVpoolUris()));
        }
    }
    if (null != system) {
        StringSet systemTypes = new StringSet();
        systemTypes.add(system.getSystemType());
        unManagedFileSystemInformation.put(SupportedFileSystemInformation.SYSTEM_TYPE.toString(), systemTypes);
    }
    // Get FileSystem used Space.
    if (null != fileSystemChars.get(SupportedNtpFileSystemInformation.getFileSystemInformation(SupportedNtpFileSystemInformation.ALLOCATED_CAPACITY.toString()))) {
        StringSet allocatedCapacity = new StringSet();
        allocatedCapacity.add(fileSystemChars.get(SupportedNtpFileSystemInformation.getFileSystemInformation(SupportedNtpFileSystemInformation.ALLOCATED_CAPACITY.toString())));
        unManagedFileSystemInformation.put(SupportedFileSystemInformation.ALLOCATED_CAPACITY.toString(), allocatedCapacity);
    }
    // Get FileSystem used Space.
    if (null != fileSystemChars.get(SupportedNtpFileSystemInformation.getFileSystemInformation(SupportedNtpFileSystemInformation.PROVISIONED_CAPACITY.toString()))) {
        StringSet provisionedCapacity = new StringSet();
        provisionedCapacity.add(fileSystemChars.get(SupportedNtpFileSystemInformation.getFileSystemInformation(SupportedNtpFileSystemInformation.PROVISIONED_CAPACITY.toString())));
        unManagedFileSystemInformation.put(SupportedFileSystemInformation.PROVISIONED_CAPACITY.toString(), provisionedCapacity);
    }
    // Save off FileSystem Name, Path, Mount and label information
    if (null != fileSystemChars.get(SupportedNtpFileSystemInformation.getFileSystemInformation(SupportedNtpFileSystemInformation.NAME.toString()))) {
        StringSet fsName = new StringSet();
        String fileSystemName = fileSystemChars.get(SupportedNtpFileSystemInformation.getFileSystemInformation(SupportedNtpFileSystemInformation.NAME.toString()));
        fsName.add(fileSystemName);
        unManagedFileSystem.setLabel(fileSystemName);
        StringSet fsPath = new StringSet();
        fsPath.add(unManangedFileSystemNativeId);
        StringSet fsMountPath = new StringSet();
        fsMountPath.add(unManangedFileSystemNativeId);
        unManagedFileSystemInformation.put(SupportedFileSystemInformation.NAME.toString(), fsName);
        unManagedFileSystemInformation.put(SupportedFileSystemInformation.NATIVE_ID.toString(), fsPath);
        unManagedFileSystemInformation.put(SupportedFileSystemInformation.DEVICE_LABEL.toString(), fsName);
        unManagedFileSystemInformation.put(SupportedFileSystemInformation.PATH.toString(), fsPath);
        unManagedFileSystemInformation.put(SupportedFileSystemInformation.MOUNT_PATH.toString(), fsMountPath);
    }
    // Add fileSystemInformation and Characteristics.
    unManagedFileSystem.addFileSystemInformation(unManagedFileSystemInformation);
    unManagedFileSystem.setFileSystemCharacterstics(unManagedFileSystemCharacteristics);
    return unManagedFileSystem;
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) HashMap(java.util.HashMap) StringSet(com.emc.storageos.db.client.model.StringSet) UnManagedFileSystem(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem)

Example 30 with UnManagedFileSystem

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

the class NetAppClusterModeCommIntf method discoverUmanagedFileSystems.

private void discoverUmanagedFileSystems(AccessProfile profile) {
    URI storageSystemId = profile.getSystemId();
    StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storageSystemId);
    if (null == storageSystem) {
        return;
    }
    String detailedStatusMessage = "Discovery of NetApp Cluster Mode Unmanaged FileSystem started";
    List<UnManagedFileSystem> unManagedFileSystems = new ArrayList<UnManagedFileSystem>();
    List<UnManagedFileSystem> existingUnManagedFileSystems = new ArrayList<UnManagedFileSystem>();
    int newFileSystemsCount = 0;
    int existingFileSystemsCount = 0;
    Set<URI> allDiscoveredUnManagedFileSystems = new HashSet<URI>();
    NetAppClusterApi netAppCApi = new NetAppClusterApi.Builder(storageSystem.getIpAddress(), storageSystem.getPortNumber(), storageSystem.getUsername(), storageSystem.getPassword()).https(true).build();
    Collection<String> attrs = new ArrayList<String>();
    for (String property : ntpPropertiesList) {
        attrs.add(SupportedNtpFileSystemInformation.getFileSystemInformation(property));
    }
    try {
        StoragePort storagePort = getStoragePortPool(storageSystem);
        URIQueryResultList storagePoolURIs = new URIQueryResultList();
        _dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStoragePoolConstraint(storageSystem.getId()), storagePoolURIs);
        HashMap<String, StoragePool> pools = new HashMap();
        Iterator<URI> poolsItr = storagePoolURIs.iterator();
        while (poolsItr.hasNext()) {
            URI storagePoolURI = poolsItr.next();
            StoragePool storagePool = _dbClient.queryObject(StoragePool.class, storagePoolURI);
            pools.put(storagePool.getNativeGuid(), storagePool);
        }
        // Retrieve all the file system and SVM info.
        List<Map<String, String>> fileSystemInfo = netAppCApi.listVolumeInfo(null, attrs);
        List<StorageVirtualMachineInfo> svms = netAppCApi.listSVM();
        for (Map<String, String> fileSystemChar : fileSystemInfo) {
            String poolName = fileSystemChar.get(SupportedNtpFileSystemInformation.getFileSystemInformation(SupportedNtpFileSystemInformation.STORAGE_POOL.toString()));
            String filesystem = fileSystemChar.get(SupportedNtpFileSystemInformation.getFileSystemInformation(SupportedNtpFileSystemInformation.NAME.toString()));
            boolean isSVMRootVolume = Boolean.valueOf(fileSystemChar.get(SupportedNtpFileSystemInformation.getFileSystemInformation(SupportedNtpFileSystemInformation.IS_SVM_ROOT.toString())));
            boolean isNodeRootVolume = Boolean.valueOf(fileSystemChar.get(SupportedNtpFileSystemInformation.getFileSystemInformation(SupportedNtpFileSystemInformation.IS_NODE_ROOT.toString())));
            String path = fileSystemChar.get(SupportedNtpFileSystemInformation.getFileSystemInformation(SupportedNtpFileSystemInformation.PATH.toString()));
            String state = fileSystemChar.get(SupportedNtpFileSystemInformation.getFileSystemInformation(SupportedNtpFileSystemInformation.STATE.toString()));
            String poolNativeGuid = NativeGUIDGenerator.generateNativeGuid(storageSystem, poolName, NativeGUIDGenerator.POOL);
            StoragePool pool = pools.get(poolNativeGuid);
            String nativeId;
            if ("".equals(filesystem)) {
                continue;
            }
            if (filesystem.startsWith(VOL_ROOT)) {
                nativeId = filesystem;
            } else {
                nativeId = VOL_ROOT + filesystem;
            }
            String fsNativeGuid = NativeGUIDGenerator.generateNativeGuid(storageSystem.getSystemType(), storageSystem.getSerialNumber(), nativeId);
            // Ignore export for root volume and don't pull it into ViPR db.
            if (isNodeRootVolume || isSVMRootVolume) {
                _logger.info("Ignore and not discover root" + filesystem + "on NTP array");
                continue;
            }
            // Ignore volume that is offline and don't pull it into ViPR db.
            if (state.equalsIgnoreCase(VOLUME_STATE_OFFLINE)) {
                _logger.info("Ignoring volume " + filesystem + " as it is offline");
                continue;
            }
            // to create an UnManaged Filesystems.
            if (checkStorageFileSystemExistsInDB(fsNativeGuid)) {
                continue;
            }
            _logger.debug("retrieve info for file system: " + filesystem);
            String svm = getOwningSVM(filesystem, fileSystemInfo);
            String address = getSVMAddress(svm, svms);
            if (svm != null && !svm.isEmpty()) {
                // Need to use storage port for SVM.
                String portNativeGuid = NativeGUIDGenerator.generateNativeGuid(storageSystem, address, NativeGUIDGenerator.PORT);
                storagePort = getSVMStoragePort(storageSystem, portNativeGuid, svm);
            }
            String fsUnManagedFsNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileSystem(storageSystem.getSystemType(), storageSystem.getSerialNumber().toUpperCase(), nativeId);
            UnManagedFileSystem unManagedFs = checkUnManagedFileSystemExistsInDB(fsUnManagedFsNativeGuid);
            boolean alreadyExist = unManagedFs == null ? false : true;
            unManagedFs = createUnManagedFileSystem(unManagedFs, profile, fsUnManagedFsNativeGuid, nativeId, storageSystem, pool, filesystem, storagePort, fileSystemChar);
            if (alreadyExist) {
                existingUnManagedFileSystems.add(unManagedFs);
                existingFileSystemsCount++;
            } else {
                unManagedFileSystems.add(unManagedFs);
                newFileSystemsCount++;
            }
            allDiscoveredUnManagedFileSystems.add(unManagedFs.getId());
            /**
             * Persist 200 objects and clear them to avoid memory issue
             */
            validateListSizeLimitAndPersist(unManagedFileSystems, existingUnManagedFileSystems, Constants.DEFAULT_PARTITION_SIZE * 2);
        }
        // Process those active unmanaged fs objects available in database but not in newly discovered items, to
        // mark them inactive.
        markUnManagedFSObjectsInActive(storageSystem, allDiscoveredUnManagedFileSystems);
        _logger.info("New unmanaged NetappC file systems count: {}", newFileSystemsCount);
        _logger.info("Update unmanaged NetappC file systems count: {}", existingFileSystemsCount);
        if (!unManagedFileSystems.isEmpty()) {
            // Add UnManagedFileSystem
            _partitionManager.insertInBatches(unManagedFileSystems, Constants.DEFAULT_PARTITION_SIZE, _dbClient, UNMANAGED_FILESYSTEM);
        }
        if (!existingUnManagedFileSystems.isEmpty()) {
            // Update UnManagedFilesystem
            _partitionManager.updateAndReIndexInBatches(existingUnManagedFileSystems, Constants.DEFAULT_PARTITION_SIZE, _dbClient, UNMANAGED_FILESYSTEM);
        }
        // discovery succeeds
        detailedStatusMessage = String.format("Discovery completed successfully for NetAppC: %s", storageSystemId.toString());
    } catch (NetAppCException ve) {
        if (null != storageSystem) {
            cleanupDiscovery(storageSystem);
        }
        _logger.error("discoverStorage failed.  Storage system: " + storageSystemId);
        throw ve;
    } catch (Exception e) {
        if (null != storageSystem) {
            cleanupDiscovery(storageSystem);
        }
        _logger.error("discoverStorage failed. Storage system: " + storageSystemId, e);
        throw NetAppCException.exceptions.discoveryFailed(storageSystemId.toString(), e);
    } finally {
        if (storageSystem != null) {
            try {
                // set detailed message
                storageSystem.setLastDiscoveryStatusMessage(detailedStatusMessage);
                _dbClient.persistObject(storageSystem);
            } catch (Exception ex) {
                _logger.error("Error while persisting object to DB", ex);
            }
        }
    }
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) StorageVirtualMachineInfo(com.iwave.ext.netappc.StorageVirtualMachineInfo) UnManagedFileSystem(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) HashSet(java.util.HashSet) StoragePort(com.emc.storageos.db.client.model.StoragePort) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) NetAppException(com.emc.storageos.netapp.NetAppException) NetAppCException(com.emc.storageos.netappc.NetAppCException) IOException(java.io.IOException) NetAppClusterApi(com.emc.storageos.netappc.NetAppClusterApi) NetAppCException(com.emc.storageos.netappc.NetAppCException) UnManagedFSExportMap(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFSExportMap) Map(java.util.Map) HashMap(java.util.HashMap) UnManagedSMBShareMap(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBShareMap) StringMap(com.emc.storageos.db.client.model.StringMap)

Aggregations

UnManagedFileSystem (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem)48 URI (java.net.URI)27 ArrayList (java.util.ArrayList)27 HashMap (java.util.HashMap)25 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)21 IOException (java.io.IOException)21 StoragePort (com.emc.storageos.db.client.model.StoragePort)20 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)19 StringMap (com.emc.storageos.db.client.model.StringMap)18 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)18 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)16 StringSet (com.emc.storageos.db.client.model.StringSet)14 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)13 UnManagedFSExportMap (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFSExportMap)12 HashSet (java.util.HashSet)12 UnManagedSMBShareMap (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBShareMap)11 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)10 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)10 Map (java.util.Map)10 StoragePool (com.emc.storageos.db.client.model.StoragePool)9