use of org.opennms.netmgt.model.topology.SharedSegment in project opennms by OpenNMS.
the class BridgeTopologyDaoInMemory method getBridgeNodeSharedSegments.
@Override
public List<SharedSegment> getBridgeNodeSharedSegments(BridgeBridgeLinkDao bridgeBridgeLinkDao, BridgeMacLinkDao bridgeMacLinkDao, int nodeid) {
List<SharedSegment> segments = new ArrayList<SharedSegment>();
/*
for (BroadcastDomain domain: getAllPersisted(bridgeBridgeLinkDao, bridgeMacLinkDao)) {
System.out.println("parsing domain:" + domain);
System.out.println("parsing domain with nodes:" + domain.getBridgeNodesOnDomain());
System.out.println("parsing domain with macs:" + domain.getMacsOnDomain());
if (domain.getBridgeNodesOnDomain().contains(nodeid)) {
System.out.println("got domain with nodeid:" + nodeid);
for (SharedSegment segment: domain.getTopology()) {
System.out.println("parsing segment:" + segment);
System.out.println("parsing segment with nodes:" + segment.getBridgeIdsOnSegment());
System.out.println("parsing segment with macs:" + segment.getMacsOnSegment());
if (segment.getBridgeIdsOnSegment().contains(nodeid)) {
segments.add(segment);
System.out.println("added segment:" + segment);
}
}
}
}*/
Set<Integer> designated = new HashSet<Integer>();
BRIDGELINK: for (BridgeBridgeLink link : bridgeBridgeLinkDao.findByNodeId(nodeid)) {
for (SharedSegment segment : segments) {
if (segment.containsPort(link.getNode().getId(), link.getBridgePort()) || segment.containsPort(link.getDesignatedNode().getId(), link.getDesignatedPort())) {
segment.add(link);
designated.add(link.getDesignatedNode().getId());
continue BRIDGELINK;
}
}
SharedSegment segment = new SharedSegment();
segment.add(link);
segment.setDesignatedBridge(link.getDesignatedNode().getId());
segments.add(segment);
}
designated.add(nodeid);
for (Integer curNodeId : designated) {
DBRIDGELINK: for (BridgeBridgeLink link : bridgeBridgeLinkDao.findByDesignatedNodeId(curNodeId)) {
for (SharedSegment segment : segments) {
if (segment.containsPort(link.getNode().getId(), link.getBridgePort()) || segment.containsPort(link.getDesignatedNode().getId(), link.getDesignatedPort())) {
segment.add(link);
continue DBRIDGELINK;
}
}
SharedSegment segment = new SharedSegment();
segment.add(link);
segment.setDesignatedBridge(link.getDesignatedNode().getId());
segments.add(segment);
}
}
MACLINK: for (BridgeMacLink link : bridgeMacLinkDao.findByNodeId(nodeid)) {
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);
}
return segments;
}
use of org.opennms.netmgt.model.topology.SharedSegment in project opennms by OpenNMS.
the class NodeDiscoveryBridgeTopology method loadFirstLevelSharedSegment.
private void loadFirstLevelSharedSegment(List<BridgeMacLink> electedRootBFT) {
Map<Integer, SharedSegment> rootleafs = new HashMap<Integer, SharedSegment>();
for (BridgeMacLink link : electedRootBFT) {
if (link.getBridgeDot1qTpFdbStatus() != BridgeDot1qTpFdbStatus.DOT1D_TP_FDB_STATUS_LEARNED)
continue;
if (rootleafs.containsKey(link.getBridgePort()))
rootleafs.get(link.getBridgePort()).add(link);
else
rootleafs.put(link.getBridgePort(), new SharedSegment(m_domain, link));
}
for (SharedSegment rootleaf : rootleafs.values()) {
LOG.debug("calculate: node [{}]: add shared segment[designated bridge:[{}]," + "designated port:{}, macs: {}]", getNodeId(), rootleaf.getDesignatedBridge(), rootleaf.getDesignatedPort(), rootleaf.getMacsOnSegment());
m_domain.add(rootleaf);
}
}
use of org.opennms.netmgt.model.topology.SharedSegment in project opennms by OpenNMS.
the class NodeDiscoveryBridgeTopology method calculate.
private void calculate(Bridge root, List<BridgeMacLink> rootbft, Bridge xBridge, List<BridgeMacLink> xbft) {
//FIXME checkStp(root, xBridge);
BridgeTopologyHelper rx = new BridgeTopologyHelper(root, rootbft, xBridge, xbft);
Integer rxDesignatedPort = rx.getFirstBridgeConnectionPort();
if (rxDesignatedPort == null) {
LOG.warn("calculate: node [{}]: cannot found simple connection for bridges: [{},{}]", getNodeId(), root.getId(), xBridge.getId());
m_domain.clearTopology();
return;
}
Integer xrDesignatedPort = rx.getSecondBridgeConnectionPort();
if (xrDesignatedPort == null) {
LOG.warn("calculate: node [{}]: cannot found simple connectionfor bridges: [{},{}]", getNodeId(), xBridge.getId(), root.getId());
m_domain.clearTopology();
return;
}
LOG.debug("calculate: node [{}]: level 1: bridge: [{}]. setting root port {} ", getNodeId(), xBridge.getId(), xrDesignatedPort);
xBridge.setRootPort(xrDesignatedPort);
xBridge.setRootBridge(false);
//get the starting point shared segment of the top bridge
// where the bridge is learned should not be null
SharedSegment topSegment = m_domain.getSharedSegment(root.getId(), rxDesignatedPort);
if (topSegment == null) {
LOG.warn("calculate: node [{}]: nodeid [{}], port {}. top segment not found.", getNodeId(), m_domain.getRootBridgeId(), rxDesignatedPort);
m_domain.clearTopology();
return;
}
if (!findBridgesTopo(rx, topSegment, xBridge, xbft, 0))
m_domain.clearTopology();
}
use of org.opennms.netmgt.model.topology.SharedSegment in project opennms by OpenNMS.
the class EnhancedLinkdTopologyProvider method getBridgeLinks.
private void getBridgeLinks(Map<Integer, OnmsNode> nodemap, Map<Integer, List<OnmsSnmpInterface>> nodesnmpmap, Map<String, List<OnmsIpInterface>> macToIpMap, Map<Integer, List<OnmsIpInterface>> ipmap, Map<Integer, OnmsIpInterface> ipprimarymap) {
for (BroadcastDomain domain : m_bridgeTopologyDao.getAllPersisted(m_bridgeBridgeLinkDao, m_bridgeMacLinkDao)) {
LOG.info("loadtopology: parsing broadcast Domain: '{}', {}", domain);
for (SharedSegment segment : domain.getTopology()) {
if (segment.noMacsOnSegment() && segment.getBridgeBridgeLinks().size() == 1) {
for (BridgeBridgeLink link : segment.getBridgeBridgeLinks()) {
Vertex source = getOrCreateVertex(nodemap.get(link.getNode().getId()), ipprimarymap.get(link.getNode().getId()));
Vertex target = getOrCreateVertex(nodemap.get(link.getDesignatedNode().getId()), ipprimarymap.get(link.getDesignatedNode().getId()));
BridgeLinkDetail detail = new BridgeLinkDetail(EnhancedLinkdTopologyProvider.TOPOLOGY_NAMESPACE_LINKD, source, link.getBridgePortIfIndex(), target, link.getDesignatedPortIfIndex(), link.getBridgePort(), link.getDesignatedPort(), link.getId(), link.getId());
LinkdEdge edge = connectVertices(detail, BRIDGE_EDGE_NAMESPACE);
edge.setTooltipText(getEdgeTooltipText(detail, nodesnmpmap));
}
continue;
}
if (segment.getBridgeMacLinks().size() == 1 && segment.getBridgeBridgeLinks().size() == 0) {
for (BridgeMacLink sourcelink : segment.getBridgeMacLinks()) {
if (macToIpMap.containsKey(sourcelink.getMacAddress()) && macToIpMap.get(sourcelink.getMacAddress()).size() > 0) {
List<OnmsIpInterface> targetInterfaces = macToIpMap.get(sourcelink.getMacAddress());
OnmsIpInterface targetIp = targetInterfaces.get(0);
if (segment.getBridgeIdsOnSegment().contains(targetIp.getNode().getId()))
continue;
Vertex source = getOrCreateVertex(nodemap.get(sourcelink.getNode().getId()), ipprimarymap.get(sourcelink.getNode().getId()));
Vertex target = getOrCreateVertex(nodemap.get(targetIp.getNode().getId()), ipprimarymap.get(targetIp.getNode().getId()));
LinkdEdge edge = connectVertices(sourcelink, source, target, BRIDGE_EDGE_NAMESPACE);
edge.setTooltipText(getEdgeTooltipText(sourcelink, source, target, targetInterfaces, nodesnmpmap));
}
}
continue;
}
String cloudId = segment.getDesignatedBridge() + ":" + segment.getDesignatedPort();
AbstractVertex cloudVertex = addVertex(cloudId, 0, 0);
cloudVertex.setLabel("");
cloudVertex.setIconKey("cloud");
cloudVertex.setTooltipText("Shared Segment: " + nodemap.get(segment.getDesignatedBridge()).getLabel() + " port: " + segment.getDesignatedPort());
addVertices(cloudVertex);
LOG.info("loadtopology: adding cloud: id: '{}', {}", cloudId, cloudVertex.getTooltipText());
for (BridgePort targetport : segment.getBridgePortsOnSegment()) {
Vertex target = getOrCreateVertex(nodemap.get(targetport.getNode().getId()), ipprimarymap.get(targetport.getNode().getId()));
LinkdEdge edge = connectVertices(targetport, cloudVertex, target, BRIDGE_EDGE_NAMESPACE);
edge.setTooltipText(getEdgeTooltipText(targetport, target, nodesnmpmap));
}
for (String targetmac : segment.getMacsOnSegment()) {
if (macToIpMap.containsKey(targetmac) && macToIpMap.get(targetmac).size() > 0) {
List<OnmsIpInterface> targetInterfaces = macToIpMap.get(targetmac);
OnmsIpInterface targetIp = targetInterfaces.get(0);
if (segment.getBridgeIdsOnSegment().contains(targetIp.getNode().getId()))
continue;
Vertex target = getOrCreateVertex(nodemap.get(targetIp.getNode().getId()), ipprimarymap.get(targetIp.getNode().getId()));
LinkdEdge edge = connectCloudMacVertices(targetmac, cloudVertex, target, BRIDGE_EDGE_NAMESPACE);
edge.setTooltipText(getEdgeTooltipText(targetmac, target, targetInterfaces));
}
}
}
}
}
use of org.opennms.netmgt.model.topology.SharedSegment 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();
}
Aggregations