use of org.opennms.features.topology.api.topo.AbstractVertex in project opennms by OpenNMS.
the class BusinessServiceSearchProviderIT method verifyQuery.
@Test
public void verifyQuery() {
BusinessServiceEntity bs1 = new BusinessServiceEntityBuilder().name("Test Service").reduceFunction(new HighestSeverityEntity()).addReductionKey("bs1.key1", new IdentityEntity(), 1).addReductionKey("bs1.key2", new IdentityEntity(), 1).toEntity();
BusinessServiceEntity bs2 = new BusinessServiceEntityBuilder().name("Real Service 2").reduceFunction(new HighestSeverityEntity()).addReductionKey("bs2.key1", new IdentityEntity(), 1).addReductionKey("bs2.key2", new IdentityEntity(), 1).toEntity();
businessServiceDao.save(bs1);
businessServiceDao.save(bs2);
businessServiceDao.flush();
// prepare mocks
TopologyServiceClient topologyServiceClientMock = EasyMock.createNiceMock(TopologyServiceClient.class);
EasyMock.expect(topologyServiceClientMock.getVertex(EasyMock.anyObject(BusinessServiceVertex.class))).andReturn(// always return a vertex, it just needs to be not null
new AbstractVertex("bsm", "0", "Dummy Vertex"));
GraphContainer graphContainerMock = EasyMock.createNiceMock(GraphContainer.class);
EasyMock.expect(graphContainerMock.getTopologyServiceClient()).andReturn(topologyServiceClientMock).anyTimes();
EasyMock.replay(graphContainerMock, topologyServiceClientMock);
// try searching
final BusinessServiceSearchProvider provider = new BusinessServiceSearchProvider();
provider.setBusinessServiceManager(businessServiceManager);
final SearchQuery query = new AbstractSearchQuery("Test") {
@Override
public boolean matches(String label) {
// always match, it does not matter
return true;
}
};
final List<SearchResult> result = provider.query(query, graphContainerMock);
Assert.assertEquals(1, result.size());
EasyMock.verify(graphContainerMock, topologyServiceClientMock);
}
use of org.opennms.features.topology.api.topo.AbstractVertex in project opennms by OpenNMS.
the class AbstractLinkdTopologyProvider method getVertex.
protected AbstractVertex getVertex(Integer nodeId, String ip, String sysobjectId, String nodeLabel, String tooltipText) {
AbstractVertex vertex = new SimpleLeafVertex(TOPOLOGY_NAMESPACE_LINKD, nodeId.toString(), 0, 0);
vertex.setIconKey(getIconName(sysobjectId));
vertex.setLabel(nodeLabel);
vertex.setIpAddress(ip);
vertex.setNodeID(nodeId);
vertex.setTooltipText(tooltipText);
return vertex;
}
use of org.opennms.features.topology.api.topo.AbstractVertex in project opennms by OpenNMS.
the class AlarmStatusProviderTest method createVertex.
private static Vertex createVertex(int nodeId) {
AbstractVertex v = new AbstractVertex("nodes", Integer.toString(nodeId), Integer.toString(nodeId));
v.setNodeID(nodeId);
return v;
}
use of org.opennms.features.topology.api.topo.AbstractVertex in project opennms by OpenNMS.
the class IconSelectionOperation method execute.
@Override
public void execute(List<VertexRef> targets, OperationContext operationContext) {
final AbstractVertex vertex = (AbstractVertex) targets.get(0);
final String preSelectedIconId = operationContext.getGraphContainer().getIconManager().getSVGIconId(vertex);
new IconSelectionDialog(preSelectedIconId).withOkAction(iconWindow -> {
final IconManager iconManager = operationContext.getGraphContainer().getIconManager();
final String newIconId = iconWindow.getSelectedIcon();
String newIconKey = iconManager.setIconMapping(vertex, newIconId);
if (newIconKey != null) {
vertex.setIconKey(newIconKey);
operationContext.getGraphContainer().setDirty(true);
operationContext.getGraphContainer().redoLayout();
}
}).open();
}
use of org.opennms.features.topology.api.topo.AbstractVertex 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));
}
}
}
}
}
Aggregations