Search in sources :

Example 1 with DDNetworkDetails

use of com.emc.storageos.datadomain.restapi.model.DDNetworkDetails in project coprhd-controller by CoprHD.

the class DataDomainCommunicationInterface method discoverPort.

private void discoverPort(DataDomainClient ddClient, StorageSystem storageSystem) {
    boolean newPort = false;
    _log.info("discoverPorts for storage system {} - start", storageSystem.getId());
    try {
        DDNetworkList networks = ddClient.getNetworks(storageSystem.getNativeGuid());
        if (networks.network.isEmpty()) {
            return;
        }
        List<StoragePort> ports = new ArrayList<StoragePort>();
        for (DDNetworkInfo network : networks.network) {
            DDNetworkDetails detailedNetworkInfo = ddClient.getNetwork(storageSystem.getNativeGuid(), network.getId());
            if ((!detailedNetworkInfo.getEnabled()) || (detailedNetworkInfo.getIp() == null)) {
                continue;
            }
            StoragePort storagePort = null;
            // Check if storage port was already discovered
            String portNativeGuid = NativeGUIDGenerator.generateNativeGuid(storageSystem, detailedNetworkInfo.getIp(), NativeGUIDGenerator.PORT);
            URIQueryResultList results = new URIQueryResultList();
            _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePortByNativeGuidConstraint(portNativeGuid), results);
            while (results.iterator().hasNext()) {
                StoragePort port = _dbClient.queryObject(StoragePort.class, results.iterator().next());
                if (!port.getInactive() && port.getStorageDevice().equals(storageSystem.getId())) {
                    storagePort = port;
                    break;
                }
            }
            if (storagePort == null) {
                // Create DataDomain 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(storageSystem.getId());
                storagePort.setPortName(detailedNetworkInfo.getName());
                storagePort.setPortGroup(detailedNetworkInfo.getName());
                storagePort.setPortNetworkId(detailedNetworkInfo.getIp());
                storagePort.setIpAddress(detailedNetworkInfo.getIp());
                storagePort.setPortSpeed((long) detailedNetworkInfo.getLinkSpeed());
                storagePort.setRegistrationStatus(DiscoveredDataObject.RegistrationStatus.REGISTERED.toString());
                newPort = true;
                _log.info("Creating new storage port using NativeGuid : {}", portNativeGuid);
            }
            storagePort.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
            storagePort.setOperationalStatus(StoragePort.OperationalStatus.OK.toString());
            storagePort.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.COMPATIBLE.name());
            storagePort.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
            _log.info("discoverPorts for storage system {} - complete", storageSystem.getId());
            StoragePortAssociationHelper.updatePortAssociations(Arrays.asList(storagePort), _dbClient);
            if (newPort) {
                _dbClient.createObject(storagePort);
            } else {
                _dbClient.persistObject(storagePort);
            }
            ports.add(storagePort);
        }
        DiscoveryUtils.checkStoragePortsNotVisible(ports, _dbClient, storageSystem.getId());
    } catch (InternalException e) {
        throw e;
    } catch (Exception e) {
        _log.error("discoverPorts failed. Storage system: " + storageSystem.getId(), e);
        throw DataDomainApiException.exceptions.failedDataDomainDiscover(storageSystem.getNativeGuid(), e);
    }
}
Also used : DDNetworkList(com.emc.storageos.datadomain.restapi.model.DDNetworkList) StoragePort(com.emc.storageos.db.client.model.StoragePort) ArrayList(java.util.ArrayList) DDNetworkInfo(com.emc.storageos.datadomain.restapi.model.DDNetworkInfo) DDNetworkDetails(com.emc.storageos.datadomain.restapi.model.DDNetworkDetails) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DataDomainApiException(com.emc.storageos.datadomain.restapi.errorhandling.DataDomainApiException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) DataDomainResourceNotFoundException(com.emc.storageos.datadomain.restapi.errorhandling.DataDomainResourceNotFoundException) IOException(java.io.IOException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException)

Aggregations

DataDomainApiException (com.emc.storageos.datadomain.restapi.errorhandling.DataDomainApiException)1 DataDomainResourceNotFoundException (com.emc.storageos.datadomain.restapi.errorhandling.DataDomainResourceNotFoundException)1 DDNetworkDetails (com.emc.storageos.datadomain.restapi.model.DDNetworkDetails)1 DDNetworkInfo (com.emc.storageos.datadomain.restapi.model.DDNetworkInfo)1 DDNetworkList (com.emc.storageos.datadomain.restapi.model.DDNetworkList)1 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 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)1 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1