Search in sources :

Example 11 with AbstractVertex

use of org.opennms.features.topology.api.topo.AbstractVertex in project opennms by OpenNMS.

the class SimpleGraphBuilder method vertex.

public SimpleGraphBuilder vertex(String id) {
    m_currentVertex = new AbstractVertex(ns(), id);
    m_graphProvider.addVertices(m_currentVertex);
    return this;
}
Also used : AbstractVertex(org.opennms.features.topology.api.topo.AbstractVertex)

Example 12 with AbstractVertex

use of org.opennms.features.topology.api.topo.AbstractVertex in project opennms by OpenNMS.

the class DefaultVertexInfoPanelItemProvider method createComponent.

private Component createComponent(VertexRef ref) {
    FormLayout formLayout = new FormLayout();
    formLayout.setSpacing(false);
    formLayout.setMargin(false);
    formLayout.addComponent(createLabel("Name", ref.getLabel()));
    formLayout.addComponent(createLabel("ID", String.format("%s:%s", ref.getNamespace(), ref.getId())));
    if (ref instanceof AbstractVertex) {
        AbstractVertex vertex = (AbstractVertex) ref;
        formLayout.addComponent(createLabel("Icon Key", vertex.getIconKey()));
        if (vertex.getIpAddress() != null) {
            formLayout.addComponent(createLabel("IP Address", vertex.getIpAddress()));
        }
    }
    return formLayout;
}
Also used : FormLayout(com.vaadin.ui.FormLayout) AbstractVertex(org.opennms.features.topology.api.topo.AbstractVertex)

Example 13 with AbstractVertex

use of org.opennms.features.topology.api.topo.AbstractVertex in project opennms by OpenNMS.

the class LinkdEdgeStatusProviderTest method setUp.

@Before
public void setUp() {
    m_node1 = new OnmsNode();
    m_node1.setId(1);
    m_node2 = new OnmsNode();
    m_node2.setId(2);
    m_node3 = new OnmsNode();
    m_node3.setId(3);
    m_node4 = new OnmsNode();
    m_node4.setId(4);
    m_node5 = new OnmsNode();
    m_node5.setId(5);
    m_nodeDehli = new OnmsNode();
    m_nodeDehli.setId(10);
    m_nodeChennai = new OnmsNode();
    m_nodeChennai.setId(14);
    m_edges = new ArrayList<LinkdEdge>();
    Vertex sourceCloud = new AbstractVertex("nodes", "1", "source");
    // Cloud is identified by the designated bridge and designated port
    Vertex cloud = new AbstractVertex("nodes", "1:48", "cloud");
    Vertex targetCloud1 = new AbstractVertex("nodes", "2", "target1");
    Vertex targetCloud2 = new AbstractVertex("nodes", "3", "target2");
    Vertex source = new AbstractVertex("nodes", "4", "source");
    Vertex target = new AbstractVertex("nodes", "5", "target");
    Vertex dehli = new AbstractVertex("nodes", "10", "dehli");
    Vertex chennai = new AbstractVertex("nodes", "14", "chennai");
    // identification of link is done with targets id..that is port or mac        
    BridgePort bpnode1port48 = new BridgePort();
    bpnode1port48.setNode(m_node1);
    bpnode1port48.setBridgePort(48);
    bpnode1port48.setBridgePortIfIndex(48);
    m_edges.add(connectVertices(bpnode1port48, cloud, sourceCloud, BRIDGE_EDGE_NAMESPACE));
    BridgePort bpnode2port24 = new BridgePort();
    bpnode2port24.setNode(m_node2);
    bpnode2port24.setBridgePort(24);
    bpnode2port24.setBridgePortIfIndex(24);
    m_edges.add(connectVertices(bpnode2port24, cloud, targetCloud1, BRIDGE_EDGE_NAMESPACE));
    m_edges.add(connectCloudMacVertices("a8d0e5a0a467", cloud, targetCloud2, BRIDGE_EDGE_NAMESPACE));
    // isis link
    IsIsLink link1 = createIsIsLink(m_node4, 599, 599, 1, 1, "001f12accbf1", "000110255062");
    link1.setId(104);
    IsIsLink link2 = createIsIsLink(m_node5, 578, 578, 1, 1, "0021590e47c1", "000110088500");
    link2.setId(105);
    m_edges.add(connectVertices(new IsIsLinkDetail(Math.min(link1.getId(), link2.getId()) + "|" + Math.max(link1.getId(), link2.getId()), source, link1.getId(), link1.getIsisCircIfIndex(), target, link2.getId(), link2.getIsisCircIfIndex()), ISIS_EDGE_NAMESPACE));
    // lldp link
    LldpLink link3 = new LldpLink(m_node4, 12, 1, "node4PortId", "node4PortDescr", LldpPortIdSubType.LLDP_PORTID_SUBTYPE_LOCAL, "node4ChassisId", "node4SysName", LldpChassisIdSubType.LLDP_CHASSISID_SUBTYPE_LOCAL, "node4PortId", LldpPortIdSubType.LLDP_PORTID_SUBTYPE_LOCAL, "node2PortDescr");
    link3.setId(204);
    LldpLink link4 = new LldpLink(m_node5, 21, 2, "node5PortId", "node5PortDescr", LldpPortIdSubType.LLDP_PORTID_SUBTYPE_LOCAL, "node5ChassisId", "node5SysName", LldpChassisIdSubType.LLDP_CHASSISID_SUBTYPE_LOCAL, "node5PortId", LldpPortIdSubType.LLDP_PORTID_SUBTYPE_LOCAL, "node1PortDescr");
    link4.setId(205);
    m_edges.add(connectVertices(new LldpLinkDetail(Math.min(link3.getId(), link4.getId()) + "|" + Math.max(link3.getId(), link4.getId()), source, link3, target, link4), LLDP_EDGE_NAMESPACE));
    //ospf link
    OspfLink link5 = createOspfLink(m_node4, "192.168.100.246", "255.255.255.252", 0, 10101, "192.168.100.249", "192.168.100.245", 0);
    link5.setId(404);
    OspfLink link6 = createOspfLink(m_node5, "192.168.100.245", "255.255.255.252", 0, 10100, "192.168.100.250", "192.168.100.246", 0);
    link6.setId(405);
    m_edges.add(connectVertices(new OspfLinkDetail(Math.min(link5.getId(), link6.getId()) + "|" + Math.max(link5.getId(), link6.getId()), source, link5, target, link6), OSPF_EDGE_NAMESPACE));
    //cdp link
    LinkdEdge edgeG = new LinkdEdge(EnhancedLinkdTopologyProvider.CDP_EDGE_NAMESPACE, "504|505", source, target);
    edgeG.setSourceNodeid(m_node4.getId());
    edgeG.setTargetNodeid(m_node5.getId());
    edgeG.setSourceEndPoint("101");
    edgeG.setTargetEndPoint("100");
    m_edges.add(edgeG);
    // another ospf link
    LinkdEdge edgeChennaiTodehli = new LinkdEdge(EnhancedLinkdTopologyProvider.OSPF_EDGE_NAMESPACE, "310|314", dehli, chennai);
    edgeChennaiTodehli.setSourceNodeid(m_nodeDehli.getId());
    edgeChennaiTodehli.setTargetNodeid(m_nodeChennai.getId());
    edgeChennaiTodehli.setSourceEndPoint("13");
    edgeChennaiTodehli.setTargetEndPoint("13");
    m_edges.add(edgeChennaiTodehli);
    m_alarmDao = EasyMock.createMock(AlarmDao.class);
    m_edgeProvider = EasyMock.createMock(EdgeProvider.class);
    m_statusProvider = new LinkdEdgeStatusProvider();
    m_statusProvider.setAlarmDao(m_alarmDao);
}
Also used : Vertex(org.opennms.features.topology.api.topo.Vertex) AbstractVertex(org.opennms.features.topology.api.topo.AbstractVertex) BridgePort(org.opennms.netmgt.model.topology.BridgePort) IsIsLink(org.opennms.netmgt.model.IsIsLink) OnmsNode(org.opennms.netmgt.model.OnmsNode) LldpLink(org.opennms.netmgt.model.LldpLink) EdgeProvider(org.opennms.features.topology.api.topo.EdgeProvider) AlarmDao(org.opennms.netmgt.dao.api.AlarmDao) AbstractVertex(org.opennms.features.topology.api.topo.AbstractVertex) OspfLink(org.opennms.netmgt.model.OspfLink) Before(org.junit.Before)

Example 14 with AbstractVertex

use of org.opennms.features.topology.api.topo.AbstractVertex in project opennms by OpenNMS.

the class VmwareTopologyProvider method createHostSystemVertex.

private AbstractVertex createHostSystemVertex(String vertexId, String vertexName, String primaryInterface, int id, String powerState) {
    AbstractVertex vertex;
    if ("poweredOn".equals(powerState)) {
        vertex = createEntityVertex(vertexId, vertexName, Icons.HOSTSYSTEM_ON);
    } else if ("poweredOff".equals(powerState)) {
        vertex = createEntityVertex(vertexId, vertexName, Icons.HOSTSYSTEM_OFF);
    } else if ("standBy".equals(powerState)) {
        vertex = createEntityVertex(vertexId, vertexName, Icons.HOSTSYSTEM_STANDBY);
    } else {
        vertex = createEntityVertex(vertexId, vertexName, Icons.HOSTSYSTEM_UNKNOWN);
    }
    vertex.setIpAddress(primaryInterface);
    vertex.setNodeID(id);
    return vertex;
}
Also used : AbstractVertex(org.opennms.features.topology.api.topo.AbstractVertex)

Example 15 with AbstractVertex

use of org.opennms.features.topology.api.topo.AbstractVertex in project opennms by OpenNMS.

the class VmwareTopologyProvider method addHostSystem.

private void addHostSystem(OnmsNode hostSystem) {
    String vmwareManagementServer = hostSystem.getAssetRecord().getVmwareManagementServer().trim();
    String vmwareManagedObjectId = hostSystem.getAssetRecord().getVmwareManagedObjectId().trim();
    String vmwareState = hostSystem.getAssetRecord().getVmwareState().trim();
    String primaryInterface = "unknown";
    OnmsIpInterface ipInterface = m_ipInterfaceDao.findPrimaryInterfaceByNodeId(hostSystem.getId());
    if (ipInterface != null) {
        primaryInterface = ipInterface.getIpHostName();
    }
    AbstractVertex hostSystemVertex = createHostSystemVertex(vmwareManagementServer + "/" + vmwareManagedObjectId, hostSystem.getLabel(), primaryInterface, hostSystem.getId(), vmwareState);
    addVertices(hostSystemVertex);
    Map<String, ParsedEntity> parsedEntities = parseNodeAssets(hostSystem);
    String datacenterName = parsedEntities.values().stream().filter(e -> "datacenter".equals(e.getEntityType())).findFirst().map(e -> parsedEntities.get(e.getEntityId()).getEntityName() + " (" + vmwareManagementServer + ")").orElse("Datacenter (" + vmwareManagementServer + ")");
    AbstractVertex datacenterVertex = createDatacenterVertex(vmwareManagementServer, datacenterName);
    addVertices(datacenterVertex);
    if (!hostSystemVertex.equals(datacenterVertex)) {
        connectVertices(hostSystemVertex, datacenterVertex);
    }
    parsedEntities.values().stream().filter(e -> "network".equals(e.getEntityType())).forEach(e -> {
        AbstractVertex networkVertex = createNetworkVertex(vmwareManagementServer + "/" + e.getEntityId(), parsedEntities.get(e.getEntityId()).getEntityName());
        addVertices(networkVertex);
        connectVertices(vmwareManagementServer + "/" + vmwareManagedObjectId + "->" + e.getEntityId(), hostSystemVertex, networkVertex, getNamespace());
    });
    parsedEntities.values().stream().filter(e -> "datastore".equals(e.getEntityType())).forEach(e -> {
        AbstractVertex datastoreVertex = createDatastoreVertex(vmwareManagementServer + "/" + e.getEntityId(), parsedEntities.get(e.getEntityId()).getEntityName());
        addVertices(datastoreVertex);
        connectVertices(vmwareManagementServer + "/" + vmwareManagedObjectId + "->" + e.getEntityId(), hostSystemVertex, datastoreVertex, getNamespace());
    });
}
Also used : AbstractVertex(org.opennms.features.topology.api.topo.AbstractVertex) IpInterfaceDao(org.opennms.netmgt.dao.api.IpInterfaceDao) Arrays(java.util.Arrays) NodeDao(org.opennms.netmgt.dao.api.NodeDao) OnmsIpInterface(org.opennms.netmgt.model.OnmsIpInterface) Logger(org.slf4j.Logger) URLDecoder(java.net.URLDecoder) DefaultVertexHopCriteria(org.opennms.features.topology.api.support.VertexHopGraphProvider.DefaultVertexHopCriteria) AbstractTopologyProvider(org.opennms.features.topology.api.topo.AbstractTopologyProvider) LoggerFactory(org.slf4j.LoggerFactory) AbstractVertex(org.opennms.features.topology.api.topo.AbstractVertex) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) StandardCharsets(java.nio.charset.StandardCharsets) Sets(com.google.common.collect.Sets) Objects(java.util.Objects) List(java.util.List) Lists(com.google.common.collect.Lists) Map(java.util.Map) Defaults(org.opennms.features.topology.api.topo.Defaults) SelectionChangedListener(org.opennms.features.topology.api.browsers.SelectionChangedListener) VertexRef(org.opennms.features.topology.api.topo.VertexRef) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ContentType(org.opennms.features.topology.api.browsers.ContentType) OnmsNode(org.opennms.netmgt.model.OnmsNode) OnmsIpInterface(org.opennms.netmgt.model.OnmsIpInterface)

Aggregations

AbstractVertex (org.opennms.features.topology.api.topo.AbstractVertex)18 VertexRef (org.opennms.features.topology.api.topo.VertexRef)7 List (java.util.List)5 Map (java.util.Map)4 Objects (java.util.Objects)4 Function (java.util.function.Function)4 Collectors (java.util.stream.Collectors)4 OnmsNode (org.opennms.netmgt.model.OnmsNode)4 Test (org.junit.Test)3 Vertex (org.opennms.features.topology.api.topo.Vertex)3 Lists (com.google.common.collect.Lists)2 Maps (com.google.common.collect.Maps)2 Sets (com.google.common.collect.Sets)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 URLDecoder (java.net.URLDecoder)2 StandardCharsets (java.nio.charset.StandardCharsets)2 ArrayList (java.util.ArrayList)2 Arrays (java.util.Arrays)2 Collection (java.util.Collection)2 Set (java.util.Set)2