use of org.opennms.netmgt.enlinkd.snmp.LldpLocalGroupTracker 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());
}
use of org.opennms.netmgt.enlinkd.snmp.LldpLocalGroupTracker in project opennms by OpenNMS.
the class EnLinkdSnmpIT method testLldpLocalGroupWalk.
@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = SWITCH1_IP, port = 161, resource = "classpath:/linkd/nms17216/switch1-walk.txt") })
public void testLldpLocalGroupWalk() throws Exception {
String trackerName = "lldpLocalGroup";
SnmpAgentConfig config = SnmpPeerFactory.getInstance().getAgentConfig(InetAddress.getByName(SWITCH1_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("0016c8bd4d80", eiA.getLldpChassisId());
assertEquals(LldpChassisIdSubType.LLDP_CHASSISID_SUBTYPE_MACADDRESS, eiA.getLldpChassisIdSubType());
assertEquals("Switch1", eiA.getLldpSysname());
}
use of org.opennms.netmgt.enlinkd.snmp.LldpLocalGroupTracker in project opennms by OpenNMS.
the class NodeDiscoveryLldp method runCollection.
protected void runCollection() {
final Date now = new Date();
final LldpLocalGroupTracker lldpLocalGroup = new LldpLocalGroupTracker();
SnmpAgentConfig peer = m_linkd.getSnmpAgentConfig(getPrimaryIpAddress(), getLocation());
try {
m_linkd.getLocationAwareSnmpClient().walk(peer, lldpLocalGroup).withDescription("lldpLocalGroup").withLocation(getLocation()).execute().get();
} catch (ExecutionException e) {
LOG.info("run: node [{}]: ExecutionException: lldpLocalGroup: {}", getNodeId(), e.getMessage());
return;
} catch (final InterruptedException e) {
LOG.info("run: node [{}]: InterruptedException: lldpLocalGroup: {}", getNodeId(), e.getMessage());
return;
}
if (lldpLocalGroup.getLldpLocChassisid() == null) {
LOG.info("run: node[{}]: LLDP_MIB not supported", getNodeId());
return;
} else {
LOG.info("run: node[{}]: lldp identifier : {}", getNodeId(), lldpLocalGroup.getLldpElement());
}
m_linkd.getQueryManager().store(getNodeId(), lldpLocalGroup.getLldpElement());
if (getSysoid() == null || getSysoid().equals(DW_SYSOID)) {
if (lldpLocalGroup.getLldpLocChassisid().toHexString().equals(DW_NULL_CHASSIS_ID) && lldpLocalGroup.getLldpLocChassisidSubType() == LldpChassisIdSubType.LLDP_CHASSISID_SUBTYPE_CHASSISCOMPONENT.getValue()) {
LOG.info("run: node[{}]: address {}. lldp identifier : {}. lldp not active for Dragon Wave Device.", getNodeId(), getPrimaryIpAddressString(), lldpLocalGroup.getLldpElement());
return;
}
if (lldpLocalGroup.getLldpLocSysname().equals(DW_NULL_SYSOID_ID)) {
LOG.info("run: node[{}]: lldp identifier : {}. lldp not active for Dragon Wave Device.", getNodeId(), lldpLocalGroup.getLldpElement());
return;
}
}
List<LldpLink> links = new ArrayList<>();
LldpRemTableTracker lldpRemTable = new LldpRemTableTracker() {
public void processLldpRemRow(final LldpRemRow row) {
links.add(row.getLldpLink());
}
};
try {
m_linkd.getLocationAwareSnmpClient().walk(peer, lldpRemTable).withDescription("lldpRemTable").withLocation(getLocation()).execute().get();
} catch (ExecutionException e) {
LOG.info("run: node [{}]: ExecutionException: lldpRemTable: {}", getNodeId(), e.getMessage());
return;
} catch (final InterruptedException e) {
LOG.info("run: node [{}]: InterruptedException: lldpRemTable: {}", getNodeId(), e.getMessage());
return;
}
final LldpLocPortGetter lldpLocPort = new LldpLocPortGetter(peer, m_linkd.getLocationAwareSnmpClient(), getLocation(), getNodeId());
for (LldpLink link : links) m_linkd.getQueryManager().store(getNodeId(), lldpLocPort.getLldpLink(link));
m_linkd.getQueryManager().reconcileLldp(getNodeId(), now);
}
Aggregations