Search in sources :

Example 1 with IsilonPool

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

the class IsilonCommunicationInterface method discoverPools.

private Map<String, List<StoragePool>> discoverPools(StorageSystem storageSystem, List<StoragePool> poolsToMatchWithVpool) throws IsilonCollectionException {
    // Discover storage pools
    Map<String, List<StoragePool>> storagePools = new HashMap<String, List<StoragePool>>();
    List<StoragePool> newPools = new ArrayList<StoragePool>();
    List<StoragePool> existingPools = new ArrayList<StoragePool>();
    URI storageSystemId = storageSystem.getId();
    try {
        _log.info("discoverPools for storage system {} - start", storageSystemId);
        IsilonApi isilonApi = getIsilonDevice(storageSystem);
        boolean isNfsV4Enabled = isilonApi.nfsv4Enabled(storageSystem.getFirmwareVersion());
        boolean syncLicenseValid = isValidLicense(isilonApi.getReplicationLicenseInfo(), storageSystem);
        boolean snapLicenseValid = isValidLicense(isilonApi.snapshotIQLicenseInfo(), storageSystem);
        // Set file replication type for Isilon storage system!!!
        if (syncLicenseValid) {
            StringSet supportReplicationTypes = new StringSet();
            supportReplicationTypes.add(SupportedFileReplicationTypes.REMOTE.name());
            supportReplicationTypes.add(SupportedFileReplicationTypes.LOCAL.name());
            storageSystem.setSupportedReplicationTypes(supportReplicationTypes);
        }
        _log.info("Isilon OneFS version: {}", storageSystem.getFirmwareVersion());
        List<? extends IsilonPool> isilonPools = null;
        if (VersionChecker.verifyVersionDetails(ONEFS_V7_2, storageSystem.getFirmwareVersion()) >= 0) {
            _log.info("Querying for Isilon storage pools...");
            isilonPools = isilonApi.getStoragePools();
        } else {
            _log.info("Querying for Isilon disk pools...");
            isilonPools = isilonApi.getDiskPools();
        }
        for (IsilonPool isilonPool : isilonPools) {
            // Check if this storage pool was already discovered
            StoragePool storagePool = null;
            String poolNativeGuid = NativeGUIDGenerator.generateNativeGuid(storageSystem, isilonPool.getNativeId(), NativeGUIDGenerator.POOL);
            @SuppressWarnings("deprecation") List<URI> poolURIs = _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePoolByNativeGuidConstraint(poolNativeGuid));
            for (URI poolUri : poolURIs) {
                StoragePool pool = _dbClient.queryObject(StoragePool.class, poolUri);
                if (!pool.getInactive() && pool.getStorageDevice().equals(storageSystemId)) {
                    storagePool = pool;
                    break;
                }
            }
            if (storagePool == null) {
                // New storage pool
                storagePool = new StoragePool();
                storagePool.setId(URIUtil.createId(StoragePool.class));
                storagePool.setNativeGuid(poolNativeGuid);
                storagePool.setLabel(poolNativeGuid);
                storagePool.setPoolClassName(POOL_TYPE);
                storagePool.setPoolServiceType(PoolServiceType.file.toString());
                storagePool.setStorageDevice(storageSystemId);
                StringSet protocols = new StringSet();
                protocols.add("NFS");
                protocols.add("CIFS");
                storagePool.setProtocols(protocols);
                storagePool.setPoolName(isilonPool.getNativeId());
                storagePool.setNativeId(isilonPool.getNativeId());
                storagePool.setLabel(poolNativeGuid);
                storagePool.setSupportedResourceTypes(StoragePool.SupportedResourceTypes.THIN_AND_THICK.toString());
                storagePool.setOperationalStatus(StoragePool.PoolOperationalStatus.READY.toString());
                storagePool.setRegistrationStatus(RegistrationStatus.REGISTERED.toString());
                _log.info("Creating new storage pool using NativeGuid : {}", poolNativeGuid);
                newPools.add(storagePool);
            } else {
                existingPools.add(storagePool);
            }
            if (isNfsV4Enabled) {
                storagePool.getProtocols().add(NFSv4);
            } else {
                storagePool.getProtocols().remove(NFSv4);
            }
            // Add the Copy type ASYNC, if the Isilon is enabled with SyncIQ service!!
            StringSet copyTypesSupported = new StringSet();
            if (syncLicenseValid) {
                copyTypesSupported.add(CopyTypes.ASYNC.name());
                storagePool.setSupportedCopyTypes(copyTypesSupported);
            } else {
                if (storagePool.getSupportedCopyTypes() != null && storagePool.getSupportedCopyTypes().contains(CopyTypes.ASYNC.name())) {
                    storagePool.getSupportedCopyTypes().remove(CopyTypes.ASYNC.name());
                }
            }
            // Add the Copy type ScheduleSnapshot, if the Isilon is enabled with SnapshotIQ
            if (snapLicenseValid) {
                copyTypesSupported.add(CHECKPOINT_SCHEDULE);
                storagePool.setSupportedCopyTypes(copyTypesSupported);
            } else {
                if (storagePool.getSupportedCopyTypes() != null && storagePool.getSupportedCopyTypes().contains(CHECKPOINT_SCHEDULE)) {
                    storagePool.getSupportedCopyTypes().remove(CHECKPOINT_SCHEDULE);
                }
            }
            // scale capacity size
            storagePool.setFreeCapacity(isilonPool.getAvailableBytes() / BYTESCONVERTER);
            storagePool.setTotalCapacity(isilonPool.getTotalBytes() / BYTESCONVERTER);
            storagePool.setSubscribedCapacity(isilonPool.getUsedBytes() / BYTESCONVERTER);
            if (ImplicitPoolMatcher.checkPoolPropertiesChanged(storagePool.getCompatibilityStatus(), DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name()) || ImplicitPoolMatcher.checkPoolPropertiesChanged(storagePool.getDiscoveryStatus(), DiscoveryStatus.VISIBLE.name())) {
                poolsToMatchWithVpool.add(storagePool);
            }
            storagePool.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
            storagePool.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
        }
        _log.info("discoverPools for storage system {} - complete", storageSystemId);
        storagePools.put(NEW, newPools);
        storagePools.put(EXISTING, existingPools);
        return storagePools;
    } catch (IsilonException ie) {
        _log.error("discoverPools failed. Storage system: {}", storageSystemId, ie);
        IsilonCollectionException ice = new IsilonCollectionException("discoverPools failed. Storage system: " + storageSystemId);
        ice.initCause(ie);
        throw ice;
    } catch (Exception e) {
        _log.error("discoverPools failed. Storage system: {}", storageSystemId, e);
        IsilonCollectionException ice = new IsilonCollectionException("discoverPools failed. Storage system: " + storageSystemId);
        ice.initCause(e);
        throw ice;
    }
}
Also used : IsilonPool(com.emc.storageos.isilon.restapi.IsilonPool) 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) URI(java.net.URI) 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) StringSet(com.emc.storageos.db.client.model.StringSet) IsilonList(com.emc.storageos.isilon.restapi.IsilonApi.IsilonList) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) List(java.util.List) IsilonApi(com.emc.storageos.isilon.restapi.IsilonApi) IsilonException(com.emc.storageos.isilon.restapi.IsilonException)

Aggregations

URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 StoragePool (com.emc.storageos.db.client.model.StoragePool)1 StringSet (com.emc.storageos.db.client.model.StringSet)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 IsilonApi (com.emc.storageos.isilon.restapi.IsilonApi)1 IsilonList (com.emc.storageos.isilon.restapi.IsilonApi.IsilonList)1 IsilonException (com.emc.storageos.isilon.restapi.IsilonException)1 IsilonPool (com.emc.storageos.isilon.restapi.IsilonPool)1 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)1 IsilonCollectionException (com.emc.storageos.plugins.metering.isilon.IsilonCollectionException)1 IOException (java.io.IOException)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 JSONException (org.codehaus.jettison.json.JSONException)1