Search in sources :

Example 16 with SnmpAgentConfig

use of org.opennms.netmgt.snmp.SnmpAgentConfig in project opennms by OpenNMS.

the class EnLinkdSnmpIT method testLldpDragonWaveRemTableWalk.

@Test
@JUnitSnmpAgent(host = DW_IP, port = 161, resource = DW_SNMP_RESOURCE)
public void testLldpDragonWaveRemTableWalk() throws Exception {
    final SnmpAgentConfig config = SnmpPeerFactory.getInstance().getAgentConfig(InetAddress.getByName(DW_IP));
    LldpRemTableTracker lldpRemTable = new LldpRemTableTracker() {

        public void processLldpRemRow(final LldpRemRow row) {
            System.err.println("----------lldp rem----------------");
            System.err.println("columns number in the row: " + row.getColumnCount());
            assertEquals(6, row.getColumnCount());
            LldpLink link = row.getLldpLink();
            assertEquals(1, row.getLldpRemLocalPortNum().intValue());
            System.err.println("local port number: " + row.getLldpRemLocalPortNum());
            assertEquals(LldpChassisIdSubType.LLDP_CHASSISID_SUBTYPE_CHASSISCOMPONENT, link.getLldpRemChassisIdSubType());
            System.err.println("remote chassis type: " + LldpChassisIdSubType.getTypeString(link.getLldpRemChassisIdSubType().getValue()));
            assertEquals("cf", link.getLldpRemChassisId());
            System.err.println("remote chassis: " + link.getLldpRemChassisId());
            assertEquals(LldpPortIdSubType.LLDP_PORTID_SUBTYPE_INTERFACEALIAS, link.getLldpRemPortIdSubType());
            System.err.println("remote port type: " + LldpPortIdSubType.getTypeString(link.getLldpRemPortIdSubType().getValue()));
            assertEquals("cf", link.getLldpRemPortId());
            System.err.println("remote port id: " + link.getLldpRemPortId());
            assertEquals("NuDesign", link.getLldpRemPortDescr());
            System.err.println("remote port descr: " + link.getLldpRemPortDescr());
            assertEquals("NuDesign", link.getLldpRemSysname());
            System.err.println("remote sysname: " + link.getLldpRemSysname());
        }
    };
    String trackerName = "lldpRemTable";
    try {
        m_client.walk(config, lldpRemTable).withDescription(trackerName).withLocation(null).execute().get();
    } catch (final InterruptedException e) {
        assertEquals(false, true);
    }
}
Also used : SnmpAgentConfig(org.opennms.netmgt.snmp.SnmpAgentConfig) LldpRemTableTracker(org.opennms.netmgt.enlinkd.snmp.LldpRemTableTracker) LldpLink(org.opennms.netmgt.model.LldpLink) Test(org.junit.Test) JUnitSnmpAgent(org.opennms.core.test.snmp.annotations.JUnitSnmpAgent)

Example 17 with SnmpAgentConfig

use of org.opennms.netmgt.snmp.SnmpAgentConfig in project opennms by OpenNMS.

the class EnLinkdSnmpIT method testLldpDragonWaveLocalGroupWalk.

/**
     * This test is designed to test the issues in bug NMS-6921.
     * 
     * @see http://issues.opennms.org/browse/NMS-6912

     * 
     * @throws Exception
     */
@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = DW_IP, port = 161, resource = DW_SNMP_RESOURCE) })
public void testLldpDragonWaveLocalGroupWalk() throws Exception {
    String trackerName = "lldpLocalGroup";
    SnmpAgentConfig config = SnmpPeerFactory.getInstance().getAgentConfig(InetAddress.getByName(DW_IP));
    LldpLocalGroupTracker lldpLocalGroup = new LldpLocalGroupTracker();
    try {
        m_client.walk(config, lldpLocalGroup).withDescription(trackerName).withLocation(null).execute().get();
    } catch (final InterruptedException e) {
        LOG.error("run: collection interrupted, exiting", e);
        return;
    }
    LldpElement eiA = lldpLocalGroup.getLldpElement();
    System.err.println("local chassis type: " + LldpChassisIdSubType.getTypeString(eiA.getLldpChassisIdSubType().getValue()));
    System.err.println("local chassis id: " + eiA.getLldpChassisId());
    System.err.println("local sysname: " + eiA.getLldpSysname());
    assertEquals("cf", eiA.getLldpChassisId());
    assertEquals(LldpChassisIdSubType.LLDP_CHASSISID_SUBTYPE_CHASSISCOMPONENT, eiA.getLldpChassisIdSubType());
    assertEquals("NuDesign", eiA.getLldpSysname());
}
Also used : SnmpAgentConfig(org.opennms.netmgt.snmp.SnmpAgentConfig) LldpLocalGroupTracker(org.opennms.netmgt.enlinkd.snmp.LldpLocalGroupTracker) LldpElement(org.opennms.netmgt.model.LldpElement) Test(org.junit.Test) JUnitSnmpAgents(org.opennms.core.test.snmp.annotations.JUnitSnmpAgents)

Example 18 with SnmpAgentConfig

use of org.opennms.netmgt.snmp.SnmpAgentConfig in project opennms by OpenNMS.

the class EnLinkdSnmpIT method testCdpGlobalGroupCollection.

@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = RPict001_IP, port = 161, resource = RPict001_SNMP_RESOURCE) })
public void testCdpGlobalGroupCollection() throws Exception {
    SnmpAgentConfig config = SnmpPeerFactory.getInstance().getAgentConfig(InetAddress.getByName(RPict001_IP));
    String trackerName = "cdpGlobalGroup";
    final CdpGlobalGroupTracker cdpGlobalGroup = new CdpGlobalGroupTracker();
    try {
        m_client.walk(config, cdpGlobalGroup).withDescription(trackerName).withLocation(null).execute().get();
    } catch (final InterruptedException e) {
        LOG.error("run: Cdp Linkd collection interrupted, exiting", e);
        return;
    }
    assertEquals("r-ro-suce-pict-001.infra.u-ssi.net", cdpGlobalGroup.getCdpDeviceId());
    assertEquals(1, cdpGlobalGroup.getCdpGlobalRun().intValue());
    assertNull(cdpGlobalGroup.getCdpGlobalDeviceFormat());
}
Also used : SnmpAgentConfig(org.opennms.netmgt.snmp.SnmpAgentConfig) CdpGlobalGroupTracker(org.opennms.netmgt.enlinkd.snmp.CdpGlobalGroupTracker) Test(org.junit.Test) JUnitSnmpAgents(org.opennms.core.test.snmp.annotations.JUnitSnmpAgents)

Example 19 with SnmpAgentConfig

use of org.opennms.netmgt.snmp.SnmpAgentConfig in project opennms by OpenNMS.

the class EnLinkdSnmpIT method testDot1dStpPortTableWalk.

@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = DLINK1_IP, port = 161, resource = DLINK1_SNMP_RESOURCE) })
public void testDot1dStpPortTableWalk() throws Exception {
    String trackerName = "dot1dbaseStpTable";
    final List<BridgeStpLink> links = new ArrayList<BridgeStpLink>();
    SnmpAgentConfig config = SnmpPeerFactory.getInstance().getAgentConfig(InetAddress.getByName(DLINK1_IP));
    Dot1dStpPortTableTracker tracker = new Dot1dStpPortTableTracker() {

        @Override
        public void processDot1dStpPortRow(final Dot1dStpPortRow row) {
            links.add(row.getLink());
        }
    };
    try {
        m_client.walk(config, tracker).withDescription(trackerName).withLocation(null).execute().get();
    } catch (final InterruptedException e) {
        LOG.error("run: collection interrupted, exiting", e);
        return;
    }
    assertEquals(26, links.size());
    int i = 0;
    for (BridgeStpLink link : links) {
        assertEquals(++i, link.getStpPort().intValue());
        assertEquals(128, link.getStpPortPriority().intValue());
        if (link.getStpPort() <= 6 || link.getStpPort() == 24)
            assertEquals(BridgeDot1dStpPortState.DOT1D_STP_PORT_STATUS_FORWARDING, link.getStpPortState());
        else
            assertEquals(BridgeDot1dStpPortState.DOT1D_STP_PORT_STATUS_DISABLED, link.getStpPortState());
        assertEquals(BridgeDot1dStpPortEnable.DOT1D_STP_PORT_ENABLED, link.getStpPortEnable());
        assertEquals(2000000, link.getStpPortPathCost().intValue());
        assertEquals("0000000000000000", link.getDesignatedRoot());
        assertEquals(0, link.getDesignatedCost().intValue());
        assertEquals("0000000000000000", link.getDesignatedBridge());
        assertEquals("0000", link.getDesignatedPort());
    }
}
Also used : SnmpAgentConfig(org.opennms.netmgt.snmp.SnmpAgentConfig) BridgeStpLink(org.opennms.netmgt.model.BridgeStpLink) ArrayList(java.util.ArrayList) Dot1dStpPortTableTracker(org.opennms.netmgt.enlinkd.snmp.Dot1dStpPortTableTracker) Test(org.junit.Test) JUnitSnmpAgents(org.opennms.core.test.snmp.annotations.JUnitSnmpAgents)

Example 20 with SnmpAgentConfig

use of org.opennms.netmgt.snmp.SnmpAgentConfig in project opennms by OpenNMS.

the class EnLinkdSnmpIT method test3LldpRemoteTableWalk.

@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = SWITCH2_IP, port = 161, resource = "classpath:/linkd/nms17216/switch2-walk.txt") })
public void test3LldpRemoteTableWalk() throws Exception {
    SnmpAgentConfig config = SnmpPeerFactory.getInstance().getAgentConfig(InetAddress.getByName(SWITCH2_IP));
    final List<LldpLink> links = new ArrayList<LldpLink>();
    LldpRemTableTracker lldpRemTable = new LldpRemTableTracker() {

        public void processLldpRemRow(final LldpRemRow row) {
            links.add(row.getLldpLink());
        }
    };
    try {
        m_client.walk(config, lldpRemTable).withDescription("lldpRemTable").withLocation(null).execute().get();
    } catch (ExecutionException e) {
        // pass
        LOG.error("run: collection failed, exiting", e);
        return;
    } catch (final InterruptedException e) {
        LOG.error("run: collection interrupted, exiting", e);
        return;
    }
    final LldpLocPortGetter lldpLocPort = new LldpLocPortGetter(config, m_client, null);
    for (LldpLink link : links) {
        assertNotNull(link);
        assertNotNull(link.getLldpLocalPortNum());
        assertNull(link.getLldpPortId());
        assertNull(link.getLldpPortIdSubType());
        assertNull(link.getLldpPortDescr());
        LldpLink updated = lldpLocPort.getLldpLink(link);
        assertNotNull(updated.getLldpPortId());
        assertEquals(5, updated.getLldpPortIdSubType().getValue().intValue());
        assertNotNull(updated.getLldpPortDescr());
    }
}
Also used : SnmpAgentConfig(org.opennms.netmgt.snmp.SnmpAgentConfig) LldpRemTableTracker(org.opennms.netmgt.enlinkd.snmp.LldpRemTableTracker) ArrayList(java.util.ArrayList) LldpLocPortGetter(org.opennms.netmgt.enlinkd.snmp.LldpLocPortGetter) LldpLink(org.opennms.netmgt.model.LldpLink) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.Test) JUnitSnmpAgents(org.opennms.core.test.snmp.annotations.JUnitSnmpAgents)

Aggregations

SnmpAgentConfig (org.opennms.netmgt.snmp.SnmpAgentConfig)117 Test (org.junit.Test)31 InetAddress (java.net.InetAddress)30 JUnitSnmpAgents (org.opennms.core.test.snmp.annotations.JUnitSnmpAgents)23 ArrayList (java.util.ArrayList)22 SnmpValue (org.opennms.netmgt.snmp.SnmpValue)21 SnmpObjId (org.opennms.netmgt.snmp.SnmpObjId)20 SnmpInstId (org.opennms.netmgt.snmp.SnmpInstId)16 PollStatus (org.opennms.netmgt.poller.PollStatus)14 Map (java.util.Map)11 ExecutionException (java.util.concurrent.ExecutionException)9 ParameterMap (org.opennms.core.utils.ParameterMap)9 SnmpWalker (org.opennms.netmgt.snmp.SnmpWalker)8 Date (java.util.Date)7 LldpLink (org.opennms.netmgt.model.LldpLink)7 OnmsNode (org.opennms.netmgt.model.OnmsNode)7 HashMap (java.util.HashMap)6 List (java.util.List)4 LldpLocPortGetter (org.opennms.netmgt.enlinkd.snmp.LldpLocPortGetter)4 LldpRemTableTracker (org.opennms.netmgt.enlinkd.snmp.LldpRemTableTracker)4