Search in sources :

Example 1 with SVMNetInfo

use of com.iwave.ext.netappc.SVMNetInfo in project coprhd-controller by CoprHD.

the class NetAppClusterModeCommIntf method discoverPorts.

/**
 * Discover the IP Interfaces/Storage Ports for NetApp Cluster mode array
 *
 * @param system
 *            Storage system information
 * @return Map of new and existing storage ports
 * @throws NetAppCException
 */
private Map<String, List<StoragePort>> discoverPorts(StorageSystem storageSystem, List<StorageVirtualMachineInfo> svms, List<StorageHADomain> haDomains) throws NetAppCException {
    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 (svms != null && !svms.isEmpty()) {
            for (StorageVirtualMachineInfo svm : svms) {
                for (SVMNetInfo intf : svm.getInterfaces()) {
                    if (intf.getRole().contains(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(svm.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(svm.getName());
                        storagePort.setStorageHADomain(findMatchingHADomain(svm.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 NetAppC 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 NetAppCException("discoverPorts failed. Storage system: " + storageSystemId, e);
    }
}
Also used : HashMap(java.util.HashMap) StoragePort(com.emc.storageos.db.client.model.StoragePort) ArrayList(java.util.ArrayList) URI(java.net.URI) SVMNetInfo(com.iwave.ext.netappc.SVMNetInfo) 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) NetAppCException(com.emc.storageos.netappc.NetAppCException) IOException(java.io.IOException) NetAppCException(com.emc.storageos.netappc.NetAppCException) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) StorageVirtualMachineInfo(com.iwave.ext.netappc.StorageVirtualMachineInfo)

Aggregations

URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 StoragePort (com.emc.storageos.db.client.model.StoragePort)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 NetAppException (com.emc.storageos.netapp.NetAppException)1 NetAppCException (com.emc.storageos.netappc.NetAppCException)1 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)1 SVMNetInfo (com.iwave.ext.netappc.SVMNetInfo)1 StorageVirtualMachineInfo (com.iwave.ext.netappc.StorageVirtualMachineInfo)1 IOException (java.io.IOException)1 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1