Search in sources :

Example 6 with CdpElement

use of org.opennms.netmgt.model.CdpElement in project opennms by OpenNMS.

the class NodeDiscoveryCdp method runCollection.

protected void runCollection() {
    final Date now = new Date();
    final CdpGlobalGroupTracker cdpGlobalGroup = new CdpGlobalGroupTracker();
    SnmpAgentConfig peer = m_linkd.getSnmpAgentConfig(getPrimaryIpAddress(), getLocation());
    try {
        m_linkd.getLocationAwareSnmpClient().walk(peer, cdpGlobalGroup).withDescription("cdpGlobalGroup").withLocation(getLocation()).execute().get();
    } catch (ExecutionException e) {
        LOG.info("run: node [{}]: ExecutionException: cdpGlobalGroup: {}", getNodeId(), e.getMessage());
        return;
    } catch (final InterruptedException e) {
        LOG.info("run: node [{}]: InterruptedException: cdpGlobalGroup: {}", getNodeId(), e.getMessage());
        return;
    }
    if (cdpGlobalGroup.getCdpDeviceId() == null) {
        LOG.info("run: node [{}]: CDP_MIB not supported", getNodeId());
        return;
    }
    CdpElement cdpElement = cdpGlobalGroup.getCdpElement();
    m_linkd.getQueryManager().store(getNodeId(), cdpElement);
    if (cdpElement.getCdpGlobalRun() == TruthValue.FALSE) {
        LOG.info("run: node [{}]. CDP disabled.", getNodeId());
        return;
    }
    List<CdpLink> links = new ArrayList<>();
    CdpCacheTableTracker cdpCacheTable = new CdpCacheTableTracker() {

        public void processCdpCacheRow(final CdpCacheRow row) {
            links.add(row.getLink());
        }
    };
    try {
        m_linkd.getLocationAwareSnmpClient().walk(peer, cdpCacheTable).withDescription("cdpCacheTable").withLocation(getLocation()).execute().get();
    } catch (ExecutionException e) {
        LOG.info("run: node [{}]: ExecutionException: cdpCacheTable: {}", getNodeId(), e.getMessage());
        return;
    } catch (final InterruptedException e) {
        LOG.info("run: node [{}]: InterruptedException: cdpCacheTable: {}", getNodeId(), e.getMessage());
        return;
    }
    final CdpInterfacePortNameGetter cdpInterfacePortNameGetter = new CdpInterfacePortNameGetter(peer, m_linkd.getLocationAwareSnmpClient(), getLocation(), getNodeId());
    for (CdpLink link : links) m_linkd.getQueryManager().store(getNodeId(), cdpInterfacePortNameGetter.get(link));
    m_linkd.getQueryManager().reconcileCdp(getNodeId(), now);
}
Also used : SnmpAgentConfig(org.opennms.netmgt.snmp.SnmpAgentConfig) CdpInterfacePortNameGetter(org.opennms.netmgt.enlinkd.snmp.CdpInterfacePortNameGetter) CdpCacheTableTracker(org.opennms.netmgt.enlinkd.snmp.CdpCacheTableTracker) ArrayList(java.util.ArrayList) CdpGlobalGroupTracker(org.opennms.netmgt.enlinkd.snmp.CdpGlobalGroupTracker) ExecutionException(java.util.concurrent.ExecutionException) CdpLink(org.opennms.netmgt.model.CdpLink) Date(java.util.Date) CdpElement(org.opennms.netmgt.model.CdpElement)

Aggregations

CdpElement (org.opennms.netmgt.model.CdpElement)6 CdpLink (org.opennms.netmgt.model.CdpLink)2 Transactional (org.springframework.transaction.annotation.Transactional)2 InetAddress (java.net.InetAddress)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 ExecutionException (java.util.concurrent.ExecutionException)1 AbstractVertex (org.opennms.features.topology.api.topo.AbstractVertex)1 Vertex (org.opennms.features.topology.api.topo.Vertex)1 CdpCacheTableTracker (org.opennms.netmgt.enlinkd.snmp.CdpCacheTableTracker)1 CdpGlobalGroupTracker (org.opennms.netmgt.enlinkd.snmp.CdpGlobalGroupTracker)1 CdpInterfacePortNameGetter (org.opennms.netmgt.enlinkd.snmp.CdpInterfacePortNameGetter)1 OnmsNode (org.opennms.netmgt.model.OnmsNode)1 OnmsSnmpInterface (org.opennms.netmgt.model.OnmsSnmpInterface)1 SnmpAgentConfig (org.opennms.netmgt.snmp.SnmpAgentConfig)1