use of org.opennms.netmgt.model.BridgeStpLink 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.model.BridgeStpLink 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());
}
}
use of org.opennms.netmgt.model.BridgeStpLink in project opennms by OpenNMS.
the class NodeDiscoveryBridge method runCollection.
protected void runCollection() {
final Date now = new Date();
SnmpAgentConfig peer = m_linkd.getSnmpAgentConfig(getPrimaryIpAddress(), getLocation());
String community = peer.getReadCommunity();
Map<Integer, String> vlanmap = getVtpVlanMap(peer);
Map<Integer, SnmpAgentConfig> vlanSnmpAgentConfigMap = new HashMap<Integer, SnmpAgentConfig>();
for (Integer vlanId : vlanmap.keySet()) {
LOG.debug("run: node [{}], support cisco vtp: setting peer community for vlan: {}, vlanname: {}", getNodeId(), vlanId, vlanmap.get(vlanId));
SnmpAgentConfig vlanpeer = m_linkd.getSnmpAgentConfig(getPrimaryIpAddress(), getLocation());
if (vlanpeer.isVersion3()) {
vlanpeer.setContextName("vlan-" + vlanId);
} else {
vlanpeer.setReadCommunity(community + "@" + vlanId);
}
vlanSnmpAgentConfigMap.put(vlanId, vlanpeer);
}
if (vlanmap.isEmpty()) {
vlanSnmpAgentConfigMap.put(null, peer);
vlanmap.put(null, null);
}
List<BridgeMacLink> bft = new ArrayList<>();
Map<Integer, Integer> bridgeifindex = new HashMap<Integer, Integer>();
for (Entry<Integer, SnmpAgentConfig> entry : vlanSnmpAgentConfigMap.entrySet()) {
Map<Integer, Integer> vlanbridgetoifindex = walkDot1dBasePortTable(entry.getValue());
LOG.debug("run: node: [{}], vlan: {}, bridge ifindex map {}", getNodeId(), vlanmap.get(entry.getKey()), vlanbridgetoifindex);
bridgeifindex.putAll(vlanbridgetoifindex);
}
for (Entry<Integer, String> entry : vlanmap.entrySet()) {
BridgeElement bridge = getDot1dBridgeBase(vlanSnmpAgentConfigMap.get(entry.getKey()));
if (bridge != null) {
bridge.setVlan(entry.getKey());
bridge.setVlanname(vlanmap.get(entry.getKey()));
m_linkd.getQueryManager().store(getNodeId(), bridge);
} else {
LOG.info("run: node: [{}], vlan {}. no dot1d bridge data found. skipping other operations", getNodeId(), entry.getValue());
continue;
}
if (!isValidStpBridgeId(bridge.getStpDesignatedRoot())) {
LOG.info("run: node: [{}], vlan {}. invalid designated root: spanning tree not supported.", getNodeId(), entry.getValue());
} else if (bridge.getBaseBridgeAddress().equals(getBridgeAddressFromStpBridgeId(bridge.getStpDesignatedRoot()))) {
LOG.info("run: node [{}]: vlan {}. designated root {} is itself. Skipping store.", getNodeId(), entry.getValue(), bridge.getStpDesignatedRoot());
} else {
for (BridgeStpLink stplink : walkSpanningTree(vlanSnmpAgentConfigMap.get(entry.getKey()), bridge.getBaseBridgeAddress())) {
stplink.setVlan(entry.getKey());
stplink.setStpPortIfIndex(bridgeifindex.get(stplink.getStpPort()));
m_linkd.getQueryManager().store(getNodeId(), stplink);
}
}
bft = walkDot1dTpFdp(entry.getValue(), entry.getKey(), bridgeifindex, bft, vlanSnmpAgentConfigMap.get(entry.getKey()));
}
LOG.debug("run: node [{}]: bridge ifindex map {}", getNodeId(), bridgeifindex);
bft = walkDot1qTpFdb(peer, bridgeifindex, bft);
LOG.debug("run: node [{}]: bft size:{}", getNodeId(), bft.size());
if (bft.size() > 0) {
LOG.debug("run: node [{}]: updating topology", getNodeId());
m_linkd.getQueryManager().updateBft(getNodeId(), bft);
m_linkd.scheduleBridgeTopologyDiscovery(getNodeId());
}
LOG.debug("run: node [{}]: deleting older the time {}", getNodeId(), now);
m_linkd.collectedBft(getNodeId());
m_linkd.getQueryManager().reconcileBridge(getNodeId(), now);
}
Aggregations