Search in sources :

Example 1 with IsilonSmartConnectInfo

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

the class IsilonCommunicationInterface method discoverPorts.

private HashMap<String, List<StoragePort>> discoverPorts(StorageSystem storageSystem) throws IsilonCollectionException {
    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 {
        _log.info("discoverPorts for storage system {} - start", storageSystemId);
        IsilonApi isilonApi = getIsilonDevice(storageSystem);
        List<IsilonStoragePort> isilonStoragePorts = new ArrayList<IsilonStoragePort>();
        try {
            _log.info("Trying to get latest smart connect version");
            IsilonSmartConnectInfoV2 connInfo = isilonApi.getSmartConnectInfoV2();
            if (connInfo == null || (connInfo != null && connInfo.getSmartZones() == null)) {
                throw new Exception("Failed new Interface, try old Interface");
            }
            if (connInfo != null) {
                isilonStoragePorts = connInfo.getPorts();
            }
        } catch (Exception e) {
            _log.info("Latest version failed so Trying to get old smart connect version");
            IsilonSmartConnectInfo connInfo = isilonApi.getSmartConnectInfo();
            if (connInfo != null) {
                isilonStoragePorts = connInfo.getPorts();
            }
        }
        if (isilonStoragePorts == null || isilonStoragePorts.isEmpty()) {
            // No ports defined throw an exception and fail the discovery
            IsilonCollectionException ice = new IsilonCollectionException("discoverPorts failed. No Smartzones defined");
            throw ice;
        }
        for (IsilonStoragePort isilonPort : isilonStoragePorts) {
            StoragePort storagePort = null;
            String portNativeGuid = NativeGUIDGenerator.generateNativeGuid(storageSystem, isilonPort.getIpAddress(), NativeGUIDGenerator.PORT);
            // Check if storage port was already discovered
            @SuppressWarnings("deprecation") List<URI> portURIs = _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePortByNativeGuidConstraint(portNativeGuid));
            for (URI portUri : portURIs) {
                StoragePort port = _dbClient.queryObject(StoragePort.class, portUri);
                if (port.getStorageDevice().equals(storageSystemId) && !port.getInactive()) {
                    storagePort = port;
                    break;
                }
            }
            if (storagePort == null) {
                // Create Isilon storage port for Isilon cluster IP address (smart connect ip)
                storagePort = new StoragePort();
                storagePort.setId(URIUtil.createId(StoragePort.class));
                storagePort.setTransportType("IP");
                storagePort.setNativeGuid(portNativeGuid);
                storagePort.setLabel(portNativeGuid);
                storagePort.setStorageDevice(storageSystemId);
                storagePort.setPortNetworkId(isilonPort.getIpAddress().toLowerCase());
                storagePort.setPortName(isilonPort.getPortName());
                storagePort.setLabel(isilonPort.getPortName());
                storagePort.setPortSpeed(isilonPort.getPortSpeed());
                storagePort.setPortGroup(isilonPort.getPortName());
                storagePort.setRegistrationStatus(RegistrationStatus.REGISTERED.toString());
                _log.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());
        }
        _log.info("discoverPorts for storage system {} - complete", storageSystemId);
        storagePorts.put(NEW, newStoragePorts);
        storagePorts.put(EXISTING, existingStoragePorts);
        return storagePorts;
    } catch (Exception e) {
        _log.error("discoverPorts failed. Storage system: {}", storageSystemId, e);
        IsilonCollectionException ice = new IsilonCollectionException("discoverPorts failed. Storage system: " + storageSystemId);
        throw ice;
    }
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) IsilonSmartConnectInfoV2(com.emc.storageos.isilon.restapi.IsilonSmartConnectInfoV2) IsilonStoragePort(com.emc.storageos.isilon.restapi.IsilonStoragePort) StoragePort(com.emc.storageos.db.client.model.StoragePort) ArrayList(java.util.ArrayList) IsilonCollectionException(com.emc.storageos.plugins.metering.isilon.IsilonCollectionException) IsilonSmartConnectInfo(com.emc.storageos.isilon.restapi.IsilonSmartConnectInfo) 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) IsilonStoragePort(com.emc.storageos.isilon.restapi.IsilonStoragePort) 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)

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 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 IsilonSmartConnectInfo (com.emc.storageos.isilon.restapi.IsilonSmartConnectInfo)1 IsilonSmartConnectInfoV2 (com.emc.storageos.isilon.restapi.IsilonSmartConnectInfoV2)1 IsilonStoragePort (com.emc.storageos.isilon.restapi.IsilonStoragePort)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