Search in sources :

Example 1 with NetAppFileCollectionException

use of com.emc.storageos.plugins.metering.netapp.NetAppFileCollectionException in project coprhd-controller by CoprHD.

the class NetAppFileCommunicationInterface method discoverPorts.

private Map<String, List<StoragePort>> discoverPorts(StorageSystem storageSystem, List<VFilerInfo> vFilers, List<StorageHADomain> haDomains) throws NetAppFileCollectionException {
    URI storageSystemId = storageSystem.getId();
    HashMap<String, List<StoragePort>> storagePorts = new HashMap<String, List<StoragePort>>();
    List<StoragePort> newStoragePorts = new ArrayList<StoragePort>();
    List<StoragePort> existingStoragePorts = new ArrayList<StoragePort>();
    // Discover storage ports
    try {
        _logger.info("discoverPorts for storage system {} - start", storageSystemId);
        StoragePort storagePort = null;
        if (vFilers != null && !vFilers.isEmpty()) {
            for (VFilerInfo filer : vFilers) {
                for (VFNetInfo intf : filer.getInterfaces()) {
                    if (intf.getNetInterface().equals(MANAGEMENT_INTERFACE)) {
                        continue;
                    }
                    URIQueryResultList results = new URIQueryResultList();
                    String portNativeGuid = NativeGUIDGenerator.generateNativeGuid(storageSystem, intf.getIpAddress(), NativeGUIDGenerator.PORT);
                    _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePortByNativeGuidConstraint(portNativeGuid), results);
                    storagePort = null;
                    if (results.iterator().hasNext()) {
                        StoragePort tmpPort = _dbClient.queryObject(StoragePort.class, results.iterator().next());
                        if (tmpPort.getStorageDevice().equals(storageSystem.getId()) && tmpPort.getPortGroup().equals(filer.getName())) {
                            storagePort = tmpPort;
                            _logger.debug("found duplicate intf {}", intf.getIpAddress());
                        }
                    }
                    if (storagePort == null) {
                        storagePort = new StoragePort();
                        storagePort.setId(URIUtil.createId(StoragePort.class));
                        storagePort.setTransportType("IP");
                        storagePort.setNativeGuid(portNativeGuid);
                        storagePort.setLabel(portNativeGuid);
                        storagePort.setStorageDevice(storageSystemId);
                        storagePort.setPortName(intf.getIpAddress());
                        storagePort.setPortNetworkId(intf.getIpAddress());
                        storagePort.setPortGroup(filer.getName());
                        storagePort.setStorageHADomain(findMatchingHADomain(filer.getName(), haDomains));
                        storagePort.setRegistrationStatus(RegistrationStatus.REGISTERED.toString());
                        _logger.info("Creating new storage port using NativeGuid : {}", portNativeGuid);
                        newStoragePorts.add(storagePort);
                    } else {
                        existingStoragePorts.add(storagePort);
                    }
                    storagePort.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
                    storagePort.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
                }
            }
        } else {
            // Check if storage port was already discovered
            URIQueryResultList results = new URIQueryResultList();
            String portNativeGuid = NativeGUIDGenerator.generateNativeGuid(storageSystem, storageSystem.getIpAddress(), NativeGUIDGenerator.PORT);
            _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePortByNativeGuidConstraint(portNativeGuid), results);
            if (results.iterator().hasNext()) {
                StoragePort tmpPort = _dbClient.queryObject(StoragePort.class, results.iterator().next());
                if (tmpPort.getStorageDevice().equals(storageSystem.getId()) && tmpPort.getPortGroup().equals(storageSystem.getSerialNumber())) {
                    storagePort = tmpPort;
                    _logger.debug("found duplicate dm intf {}", storageSystem.getSerialNumber());
                }
            }
            if (storagePort == null) {
                // Create NetApp storage port for IP address
                storagePort = new StoragePort();
                storagePort.setId(URIUtil.createId(StoragePort.class));
                storagePort.setTransportType("IP");
                storagePort.setNativeGuid(portNativeGuid);
                storagePort.setLabel(portNativeGuid);
                storagePort.setStorageDevice(storageSystemId);
                storagePort.setPortName(storageSystem.getIpAddress());
                storagePort.setPortNetworkId(storageSystem.getIpAddress());
                storagePort.setPortGroup(storageSystem.getSerialNumber());
                storagePort.setRegistrationStatus(RegistrationStatus.REGISTERED.toString());
                _logger.info("Creating new storage port using NativeGuid : {}", portNativeGuid);
                newStoragePorts.add(storagePort);
            } else {
                existingStoragePorts.add(storagePort);
            }
            storagePort.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
        }
        _logger.info("discoverPorts for storage system {} - complete", storageSystemId);
        storagePorts.put(NEW, newStoragePorts);
        storagePorts.put(EXISTING, existingStoragePorts);
        return storagePorts;
    } catch (Exception e) {
        _logger.error("discoverPorts failed. Storage system: " + storageSystemId, e);
        throw new NetAppFileCollectionException("discoverPorts failed. Storage system: " + storageSystemId, e);
    }
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) StoragePort(com.emc.storageos.db.client.model.StoragePort) ArrayList(java.util.ArrayList) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) NetAppException(com.emc.storageos.netapp.NetAppException) NetAppFileCollectionException(com.emc.storageos.plugins.metering.netapp.NetAppFileCollectionException) IOException(java.io.IOException) VFilerInfo(com.iwave.ext.netapp.VFilerInfo) VFNetInfo(com.iwave.ext.netapp.VFNetInfo) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) NetAppFileCollectionException(com.emc.storageos.plugins.metering.netapp.NetAppFileCollectionException)

Example 2 with NetAppFileCollectionException

use of com.emc.storageos.plugins.metering.netapp.NetAppFileCollectionException in project coprhd-controller by CoprHD.

the class NetAppFileCommunicationInterface method discoverFilerInfo.

/**
 * Discover the Control Station for the specified NTAP File storage array.
 * Since the StorageSystem object currently exists, this method updates
 * information in the object.
 *
 * @param system
 * @throws NetAppException
 */
private void discoverFilerInfo(StorageSystem system) throws NetAppFileCollectionException {
    _logger.info("Start Control Station discovery for storage system {}", system.getId());
    Map<String, String> systemInfo = new HashMap<String, String>();
    Map<String, String> systemVer = new HashMap<String, String>();
    NetAppApi nApi = new NetAppApi.Builder(system.getIpAddress(), system.getPortNumber(), system.getUsername(), system.getPassword()).https(true).build();
    try {
        systemInfo = nApi.systemInfo();
        systemVer = nApi.systemVer();
        if ((null == systemInfo) || (systemInfo.size() <= 0)) {
            _logger.error("Failed to retrieve NetApp Filer info!");
            system.setReachableStatus(false);
            return;
        }
        if ((null == systemVer) || (systemVer.size() <= 0)) {
            _logger.error("Failed to retrieve NetApp Filer info!");
            system.setReachableStatus(false);
            return;
        }
        system.setReachableStatus(true);
        system.setSerialNumber(systemInfo.get(SYSTEM_SERIAL_NUM));
        String sysNativeGuid = NativeGUIDGenerator.generateNativeGuid(system);
        system.setNativeGuid(sysNativeGuid);
        system.setFirmwareVersion(systemVer.get(SYSTEM_FIRMWARE_REL));
        _logger.info("NetApp Filer discovery for storage system {} complete", system.getId());
    } catch (Exception e) {
        _logger.error("Failed to retrieve NetApp Filer info!");
        system.setReachableStatus(false);
        String msg = "exception occurred while attempting to retrieve NetApp filer information. Storage system: " + system.getIpAddress() + " " + e.getMessage();
        _logger.error(msg);
        throw new NetAppFileCollectionException(msg);
    }
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) NetAppApi(com.emc.storageos.netapp.NetAppApi) NetAppFileCollectionException(com.emc.storageos.plugins.metering.netapp.NetAppFileCollectionException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) NetAppException(com.emc.storageos.netapp.NetAppException) NetAppFileCollectionException(com.emc.storageos.plugins.metering.netapp.NetAppFileCollectionException) IOException(java.io.IOException)

Example 3 with NetAppFileCollectionException

use of com.emc.storageos.plugins.metering.netapp.NetAppFileCollectionException in project coprhd-controller by CoprHD.

the class NetAppFileCommunicationInterface method discoverAll.

public void discoverAll(AccessProfile accessProfile) throws BaseCollectionException {
    URI storageSystemId = null;
    StorageSystem storageSystem = null;
    String detailedStatusMessage = "Unknown Status";
    try {
        _logger.info("Access Profile Details :  IpAddress : {}, PortNumber : {}", accessProfile.getIpAddress(), accessProfile.getPortNumber());
        storageSystemId = accessProfile.getSystemId();
        storageSystem = _dbClient.queryObject(StorageSystem.class, storageSystemId);
        // Retrieve NetApp Filer information.
        discoverFilerInfo(storageSystem);
        String minimumSupportedVersion = VersionChecker.getMinimumSupportedVersion(Type.valueOf(storageSystem.getSystemType()));
        String firmwareVersion = storageSystem.getFirmwareVersion();
        // Example version String for Netapp looks like 8.1.2
        _logger.info("Verifying version details : Minimum Supported Version {} - Discovered NetApp Version {}", minimumSupportedVersion, firmwareVersion);
        if (VersionChecker.verifyVersionDetails(minimumSupportedVersion, firmwareVersion) < 0) {
            storageSystem.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.INCOMPATIBLE.name());
            storageSystem.setReachableStatus(false);
            DiscoveryUtils.setSystemResourcesIncompatible(_dbClient, _coordinator, storageSystem.getId());
            NetAppFileCollectionException netAppEx = new NetAppFileCollectionException(String.format(" ** This version of NetApp is not supported ** Should be a minimum of %s", minimumSupportedVersion));
            throw netAppEx;
        }
        storageSystem.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
        storageSystem.setReachableStatus(true);
        _dbClient.persistObject(storageSystem);
        if (!storageSystem.getReachableStatus()) {
            throw new NetAppException("Failed to connect to " + storageSystem.getIpAddress());
        }
        _completer.statusPending(_dbClient, "Identified physical storage");
        List<VFilerInfo> vFilers = new ArrayList<VFilerInfo>();
        Map<String, List<StorageHADomain>> groups = discoverPortGroups(storageSystem, vFilers);
        _logger.info("No of newly discovered groups {}", groups.get(NEW).size());
        _logger.info("No of existing discovered groups {}", groups.get(EXISTING).size());
        if (!groups.get(NEW).isEmpty()) {
            _dbClient.createObject(groups.get(NEW));
        }
        if (!groups.get(EXISTING).isEmpty()) {
            _dbClient.persistObject(groups.get(EXISTING));
        }
        List<StoragePool> poolsToMatchWithVpool = new ArrayList<StoragePool>();
        List<StoragePool> allPools = new ArrayList<StoragePool>();
        Map<String, List<StoragePool>> pools = discoverStoragePools(storageSystem, poolsToMatchWithVpool);
        _logger.info("No of newly discovered pools {}", pools.get(NEW).size());
        _logger.info("No of existing discovered pools {}", pools.get(EXISTING).size());
        if (!pools.get(NEW).isEmpty()) {
            allPools.addAll(pools.get(NEW));
            _dbClient.createObject(pools.get(NEW));
        }
        if (!pools.get(EXISTING).isEmpty()) {
            allPools.addAll(pools.get(EXISTING));
            _dbClient.persistObject(pools.get(EXISTING));
        }
        List<StoragePool> notVisiblePools = DiscoveryUtils.checkStoragePoolsNotVisible(allPools, _dbClient, storageSystemId);
        if (notVisiblePools != null && !notVisiblePools.isEmpty()) {
            poolsToMatchWithVpool.addAll(notVisiblePools);
        }
        _completer.statusPending(_dbClient, "Completed pool discovery");
        // discover ports
        List<StoragePort> allPorts = new ArrayList<StoragePort>();
        Map<String, List<StoragePort>> ports = discoverPorts(storageSystem, vFilers, groups.get(NEW));
        _logger.info("No of newly discovered port {}", ports.get(NEW).size());
        _logger.info("No of existing discovered port {}", ports.get(EXISTING).size());
        if (!ports.get(NEW).isEmpty()) {
            allPorts.addAll(ports.get(NEW));
            _dbClient.createObject(ports.get(NEW));
        }
        if (!ports.get(EXISTING).isEmpty()) {
            allPorts.addAll(ports.get(EXISTING));
            _dbClient.persistObject(ports.get(EXISTING));
        }
        List<StoragePort> notVisiblePorts = DiscoveryUtils.checkStoragePortsNotVisible(allPorts, _dbClient, storageSystemId);
        _completer.statusPending(_dbClient, "Completed port discovery");
        List<StoragePort> allExistingPorts = new ArrayList<StoragePort>(ports.get(EXISTING));
        if (notVisiblePorts != null && !notVisiblePorts.isEmpty()) {
            allExistingPorts.addAll(notVisiblePorts);
        }
        StoragePortAssociationHelper.runUpdatePortAssociationsProcess(ports.get(NEW), allExistingPorts, _dbClient, _coordinator, poolsToMatchWithVpool);
        // discovery succeeds
        detailedStatusMessage = String.format("Discovery completed successfully for Storage System: %s", storageSystemId.toString());
    } catch (Exception e) {
        if (null != storageSystem) {
            cleanupDiscovery(storageSystem);
        }
        detailedStatusMessage = String.format("Discovery failed for Storage System: %s because %s", storageSystemId.toString(), e.getLocalizedMessage());
        _logger.error(detailedStatusMessage, e);
        throw new NetAppFileCollectionException(detailedStatusMessage);
    } finally {
        if (storageSystem != null) {
            try {
                // set detailed message
                storageSystem.setLastDiscoveryStatusMessage(detailedStatusMessage);
                _dbClient.persistObject(storageSystem);
            } catch (DatabaseException ex) {
                _logger.error("Error while persisting object to DB", ex);
            }
        }
    }
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) ArrayList(java.util.ArrayList) StoragePort(com.emc.storageos.db.client.model.StoragePort) URI(java.net.URI) NetAppException(com.emc.storageos.netapp.NetAppException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) NetAppException(com.emc.storageos.netapp.NetAppException) NetAppFileCollectionException(com.emc.storageos.plugins.metering.netapp.NetAppFileCollectionException) IOException(java.io.IOException) VFilerInfo(com.iwave.ext.netapp.VFilerInfo) NetAppFileCollectionException(com.emc.storageos.plugins.metering.netapp.NetAppFileCollectionException) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 4 with NetAppFileCollectionException

use of com.emc.storageos.plugins.metering.netapp.NetAppFileCollectionException in project coprhd-controller by CoprHD.

the class NetAppFileCommunicationInterface method discoverStoragePools.

private Map<String, List<StoragePool>> discoverStoragePools(StorageSystem system, List<StoragePool> poolsToMatchWithVpool) throws NetAppFileCollectionException, NetAppException {
    Map<String, List<StoragePool>> storagePools = new HashMap<String, List<StoragePool>>();
    List<StoragePool> newPools = new ArrayList<StoragePool>();
    List<StoragePool> existingPools = new ArrayList<StoragePool>();
    _logger.info("Start storage pool discovery for storage system {}", system.getId());
    try {
        NetAppApi netAppApi = new NetAppApi.Builder(system.getIpAddress(), system.getPortNumber(), system.getUsername(), system.getPassword()).https(true).build();
        List<AggregateInfo> pools = netAppApi.listAggregates(null);
        for (AggregateInfo netAppPool : pools) {
            StoragePool pool = null;
            URIQueryResultList results = new URIQueryResultList();
            String poolNativeGuid = NativeGUIDGenerator.generateNativeGuid(system, netAppPool.getName(), NativeGUIDGenerator.POOL);
            _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePoolByNativeGuidConstraint(poolNativeGuid), results);
            if (results.iterator().hasNext()) {
                StoragePool tmpPool = _dbClient.queryObject(StoragePool.class, results.iterator().next());
                if (tmpPool.getStorageDevice().equals(system.getId())) {
                    pool = tmpPool;
                }
            }
            if (pool == null) {
                pool = new StoragePool();
                pool.setId(URIUtil.createId(StoragePool.class));
                pool.setLabel(poolNativeGuid);
                pool.setNativeGuid(poolNativeGuid);
                pool.setPoolServiceType(PoolServiceType.file.toString());
                pool.setStorageDevice(system.getId());
                pool.setOperationalStatus(StoragePool.PoolOperationalStatus.READY.toString());
                StringSet protocols = new StringSet();
                protocols.add("NFS");
                protocols.add("CIFS");
                pool.setProtocols(protocols);
                pool.setPoolName(netAppPool.getName());
                pool.setNativeId(netAppPool.getName());
                pool.setSupportedResourceTypes(StoragePool.SupportedResourceTypes.THIN_AND_THICK.toString());
                Map<String, String> params = new HashMap<String, String>();
                params.put(StoragePool.ControllerParam.PoolType.name(), "File Pool");
                pool.addControllerParams(params);
                pool.setRegistrationStatus(RegistrationStatus.REGISTERED.toString());
                _logger.info("Creating new storage pool using NativeGuid : {}", poolNativeGuid);
                newPools.add(pool);
            } else {
                existingPools.add(pool);
            }
            // Update Pool details with new discovery run
            pool.setTotalCapacity(netAppPool.getSizeTotal() / BYTESCONVERTER);
            pool.setFreeCapacity(netAppPool.getSizeAvailable() / BYTESCONVERTER);
            pool.setSubscribedCapacity(netAppPool.getSizeUsed() / BYTESCONVERTER);
            if (ImplicitPoolMatcher.checkPoolPropertiesChanged(pool.getCompatibilityStatus(), DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name()) || ImplicitPoolMatcher.checkPoolPropertiesChanged(pool.getDiscoveryStatus(), DiscoveryStatus.VISIBLE.name())) {
                poolsToMatchWithVpool.add(pool);
            }
            pool.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
            pool.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
        }
    } catch (NumberFormatException e) {
        _logger.error("Data Format Exception:  Discovery of storage pools failed for storage system {} for {}", system.getId(), e);
        NetAppFileCollectionException ntpe = new NetAppFileCollectionException("Storage pool discovery data error for storage system " + system.getId());
        ntpe.initCause(e);
        throw ntpe;
    }
    _logger.info("Storage pool discovery for storage system {} complete", system.getId());
    storagePools.put(NEW, newPools);
    storagePools.put(EXISTING, existingPools);
    return storagePools;
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) StringSet(com.emc.storageos.db.client.model.StringSet) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) NetAppApi(com.emc.storageos.netapp.NetAppApi) NetAppFileCollectionException(com.emc.storageos.plugins.metering.netapp.NetAppFileCollectionException) AggregateInfo(com.iwave.ext.netapp.AggregateInfo)

Aggregations

NetAppFileCollectionException (com.emc.storageos.plugins.metering.netapp.NetAppFileCollectionException)4 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)3 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)3 NetAppException (com.emc.storageos.netapp.NetAppException)3 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 List (java.util.List)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 StoragePool (com.emc.storageos.db.client.model.StoragePool)2 StoragePort (com.emc.storageos.db.client.model.StoragePort)2 NetAppApi (com.emc.storageos.netapp.NetAppApi)2 VFilerInfo (com.iwave.ext.netapp.VFilerInfo)2 URI (java.net.URI)2 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)1 StringSet (com.emc.storageos.db.client.model.StringSet)1 AggregateInfo (com.iwave.ext.netapp.AggregateInfo)1 VFNetInfo (com.iwave.ext.netapp.VFNetInfo)1