use of org.opennms.netmgt.enlinkd.snmp.Dot1dStpPortTableTracker in project opennms by OpenNMS.
the class NodeDiscoveryBridge method walkSpanningTree.
private List<BridgeStpLink> walkSpanningTree(SnmpAgentConfig peer, final String baseBridgeAddress) {
final List<BridgeStpLink> stplinks = new ArrayList<>();
Dot1dStpPortTableTracker stpPortTableTracker = new Dot1dStpPortTableTracker() {
@Override
public void processDot1dStpPortRow(final Dot1dStpPortRow row) {
BridgeStpLink link = row.getLink();
LOG.debug("processDot1dStpPortRow: node [{}]: stp: port:{}/{}, vlan:{}, designated root/bridge/port:{}/{}/{}.", getNodeId(), link.getStpPort(), link.getStpPortState(), link.getVlan(), link.getDesignatedRoot(), link.getDesignatedBridge(), link.getDesignatedPort());
if (isValidStpBridgeId(link.getDesignatedRoot()) && isValidStpBridgeId(link.getDesignatedBridge()) && !baseBridgeAddress.equals(link.getDesignatedBridgeAddress())) {
LOG.debug("processDot1dStpPortRow: node [{}]: stp: port:{}/{}, vlan:{}, designated root/bridge/port:{}/{}/{}. row added", getNodeId(), link.getStpPort(), link.getStpPortState(), link.getVlan(), link.getDesignatedRoot(), link.getDesignatedBridge(), link.getDesignatedPort());
stplinks.add(link);
}
}
};
try {
m_linkd.getLocationAwareSnmpClient().walk(peer, stpPortTableTracker).withDescription("dot1dStpPortTable").withLocation(getLocation()).execute().get();
} catch (ExecutionException e) {
LOG.info("run: node [{}]: ExecutionException: dot1dStpPortTable: {}", getNodeId(), e.getMessage());
} catch (final InterruptedException e) {
LOG.info("run: node [{}]: InterruptedException: dot1dStpPortTable: {}", getNodeId(), e.getMessage());
}
return stplinks;
}
use of org.opennms.netmgt.enlinkd.snmp.Dot1dStpPortTableTracker 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<>();
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());
}
}
Aggregations