use of org.opennms.netmgt.model.BridgeMacLink in project opennms by OpenNMS.
the class Nms7918EnIT method testNms7918STCASW01BftCollection.
@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = STCASW01_IP, port = 161, resource = STCASW01_SNMP_RESOURCE) })
public void testNms7918STCASW01BftCollection() throws Exception {
final OnmsNode stcasw01 = m_nodeDao.findByForeignId("linkd", STCASW01_NAME);
m_linkdConfig.getConfiguration().setUseBridgeDiscovery(true);
m_linkdConfig.getConfiguration().setUseCdpDiscovery(false);
m_linkdConfig.getConfiguration().setUseOspfDiscovery(false);
m_linkdConfig.getConfiguration().setUseLldpDiscovery(false);
m_linkdConfig.getConfiguration().setUseIsisDiscovery(false);
assertTrue(!m_linkdConfig.useLldpDiscovery());
assertTrue(!m_linkdConfig.useCdpDiscovery());
assertTrue(!m_linkdConfig.useOspfDiscovery());
assertTrue(m_linkdConfig.useBridgeDiscovery());
assertTrue(!m_linkdConfig.useIsisDiscovery());
assertTrue(m_linkd.scheduleNodeCollection(stcasw01.getId()));
assertEquals(0, m_bridgeBridgeLinkDao.countAll());
assertEquals(0, m_bridgeMacLinkDao.countAll());
assertTrue(m_linkd.runSingleSnmpCollection(stcasw01.getId()));
assertEquals(0, m_bridgeBridgeLinkDao.countAll());
assertEquals(0, m_bridgeMacLinkDao.countAll());
List<BridgeMacLink> links = m_linkd.getQueryManager().useBridgeTopologyUpdateBFT(stcasw01.getId());
assertEquals(34, links.size());
for (BridgeMacLink link : links) {
System.err.println(link.printTopology());
}
assertTrue(m_linkd.runTopologyDiscovery(stcasw01.getId()));
assertEquals(0, m_bridgeBridgeLinkDao.countAll());
assertEquals(0, m_bridgeMacLinkDao.countAll());
}
use of org.opennms.netmgt.model.BridgeMacLink in project opennms by OpenNMS.
the class Nms7918EnIT method testNms7918ASW01BftCollection.
@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = ASW01_IP, port = 161, resource = ASW01_SNMP_RESOURCE) })
public void testNms7918ASW01BftCollection() throws Exception {
final OnmsNode asw01 = m_nodeDao.findByForeignId("linkd", ASW01_NAME);
m_linkdConfig.getConfiguration().setUseBridgeDiscovery(true);
m_linkdConfig.getConfiguration().setUseCdpDiscovery(false);
m_linkdConfig.getConfiguration().setUseOspfDiscovery(false);
m_linkdConfig.getConfiguration().setUseLldpDiscovery(false);
m_linkdConfig.getConfiguration().setUseIsisDiscovery(false);
assertTrue(!m_linkdConfig.useLldpDiscovery());
assertTrue(!m_linkdConfig.useCdpDiscovery());
assertTrue(!m_linkdConfig.useOspfDiscovery());
assertTrue(m_linkdConfig.useBridgeDiscovery());
assertTrue(!m_linkdConfig.useIsisDiscovery());
assertTrue(m_linkd.scheduleNodeCollection(asw01.getId()));
assertEquals(0, m_bridgeBridgeLinkDao.countAll());
assertEquals(0, m_bridgeMacLinkDao.countAll());
assertTrue(m_linkd.runSingleSnmpCollection(asw01.getId()));
assertEquals(0, m_bridgeBridgeLinkDao.countAll());
assertEquals(0, m_bridgeMacLinkDao.countAll());
List<BridgeMacLink> links = m_linkd.getQueryManager().useBridgeTopologyUpdateBFT(asw01.getId());
assertEquals(40, links.size());
;
for (BridgeMacLink link : links) {
System.err.println(link.printTopology());
}
assertTrue(m_linkd.runTopologyDiscovery(asw01.getId()));
assertEquals(0, m_bridgeBridgeLinkDao.countAll());
assertEquals(0, m_bridgeMacLinkDao.countAll());
}
use of org.opennms.netmgt.model.BridgeMacLink in project opennms by OpenNMS.
the class EnhancedLinkdServiceImpl method store.
@Override
public void store(BroadcastDomain domain, Date now) {
for (SharedSegment segment : domain.getTopology()) {
for (BridgeBridgeLink link : segment.getBridgeBridgeLinks()) {
link.setBridgeBridgeLinkLastPollTime(new Date());
saveBridgeBridgeLink(link);
}
for (BridgeMacLink link : segment.getBridgeMacLinks()) {
link.setBridgeMacLinkLastPollTime(new Date());
saveBridgeMacLink(link);
}
}
for (Integer nodeid : domain.getBridgeNodesOnDomain()) {
m_bridgeMacLinkDao.deleteByNodeIdOlderThen(nodeid, now);
m_bridgeMacLinkDao.flush();
m_bridgeBridgeLinkDao.deleteByNodeIdOlderThen(nodeid, now);
m_bridgeBridgeLinkDao.deleteByDesignatedNodeIdOlderThen(nodeid, now);
m_bridgeBridgeLinkDao.flush();
}
}
use of org.opennms.netmgt.model.BridgeMacLink in project opennms by OpenNMS.
the class BridgeTopologyDaoInMemory method getHostNodeSharedSegment.
@Override
public SharedSegment getHostNodeSharedSegment(BridgeBridgeLinkDao bridgeBridgeLinkDao, BridgeMacLinkDao bridgeMacLinkDao, String mac) {
List<BridgeMacLink> links = bridgeMacLinkDao.findByMacAddress(mac);
if (links.size() == 0)
return new SharedSegment();
BridgeMacLink link = links.get(0);
for (SharedSegment segment : getBridgeNodeSharedSegments(bridgeBridgeLinkDao, bridgeMacLinkDao, link.getNode().getId())) {
if (segment.containsPort(link.getNode().getId(), link.getBridgePort())) {
return segment;
}
}
return new SharedSegment();
}
use of org.opennms.netmgt.model.BridgeMacLink in project opennms by OpenNMS.
the class BridgeTopologyDaoInMemory method getAllPersisted.
@Override
public Set<BroadcastDomain> getAllPersisted(BridgeBridgeLinkDao bridgeBridgeLinkDao, BridgeMacLinkDao bridgeMacLinkDao) {
List<SharedSegment> segments = new ArrayList<SharedSegment>();
BRIDGELINK: for (BridgeBridgeLink link : bridgeBridgeLinkDao.findAll()) {
for (SharedSegment segment : segments) {
if (segment.containsPort(link.getNode().getId(), link.getBridgePort()) || segment.containsPort(link.getDesignatedNode().getId(), link.getDesignatedPort())) {
segment.add(link);
continue BRIDGELINK;
}
}
SharedSegment segment = new SharedSegment();
segment.add(link);
segment.setDesignatedBridge(link.getDesignatedNode().getId());
segments.add(segment);
}
MACLINK: for (BridgeMacLink link : bridgeMacLinkDao.findAll()) {
link.setBridgeDot1qTpFdbStatus(BridgeDot1qTpFdbStatus.DOT1D_TP_FDB_STATUS_LEARNED);
for (SharedSegment segment : segments) {
if (segment.containsMac(link.getMacAddress()) || segment.containsPort(link.getNode().getId(), link.getBridgePort())) {
segment.add(link);
continue MACLINK;
}
}
SharedSegment segment = new SharedSegment();
segment.add(link);
segment.setDesignatedBridge(link.getNode().getId());
segments.add(segment);
}
Set<Set<Integer>> nodelinked = new HashSet<Set<Integer>>();
SHARED: for (SharedSegment segment : segments) {
Set<Integer> nodesOnSegment = new HashSet<Integer>(segment.getBridgeIdsOnSegment());
for (Set<Integer> nodes : nodelinked) {
for (Integer nodeid : nodesOnSegment) {
if (nodes.contains(nodeid))
continue SHARED;
}
}
nodelinked.add(getNodesOnDomainSet(segments, segment, new HashSet<SharedSegment>(), nodesOnSegment));
}
Set<BroadcastDomain> domains = new HashSet<BroadcastDomain>();
for (Set<Integer> nodes : nodelinked) {
BroadcastDomain domain = new BroadcastDomain();
for (Integer nodeid : nodes) domain.addBridge(new Bridge(nodeid));
domains.add(domain);
}
// Assign the segment to domain and add to single nodes
for (SharedSegment segment : segments) {
BroadcastDomain domain = null;
for (BroadcastDomain cdomain : domains) {
if (cdomain.containsAtleastOne(segment.getBridgeIdsOnSegment())) {
domain = cdomain;
break;
}
}
if (domain == null) {
domain = new BroadcastDomain();
domains.add(domain);
}
domain.loadTopologyEntry(segment);
}
return domains;
}
Aggregations