Search in sources :

Example 1 with OspfElement

use of org.opennms.netmgt.model.OspfElement in project opennms by OpenNMS.

the class EnhancedLinkdServiceImpl method store.

@Override
@Transactional
public void store(int nodeId, OspfElement element) {
    if (element == null)
        return;
    final OnmsNode node = m_nodeDao.get(nodeId);
    if (node == null)
        return;
    OspfElement dbelement = node.getOspfElement();
    if (dbelement != null) {
        dbelement.merge(element);
        node.setOspfElement(dbelement);
    } else {
        element.setNode(node);
        element.setOspfNodeLastPollTime(element.getOspfNodeCreateTime());
        node.setOspfElement(element);
    }
    m_nodeDao.saveOrUpdate(node);
    m_nodeDao.flush();
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) OspfElement(org.opennms.netmgt.model.OspfElement) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with OspfElement

use of org.opennms.netmgt.model.OspfElement in project opennms by OpenNMS.

the class OspfGeneralGroupTracker method getOspfElement.

public OspfElement getOspfElement() {
    OspfElement ospfElement = new OspfElement();
    ospfElement.setOspfRouterId(getOspfRouterId());
    ospfElement.setOspfAdminStat(Status.get(getOspfAdminStat()));
    ospfElement.setOspfVersionNumber(getOspfVersionNumber());
    ospfElement.setOspfBdrRtrStatus(TruthValue.get(getOspfBdrRtrStatus()));
    ospfElement.setOspfASBdrRtrStatus(TruthValue.get(getOspfASBdrRtrStatus()));
    return ospfElement;
}
Also used : OspfElement(org.opennms.netmgt.model.OspfElement)

Example 3 with OspfElement

use of org.opennms.netmgt.model.OspfElement in project opennms by OpenNMS.

the class EnhancedLinkdServiceImpl method reconcileOspf.

@Override
public void reconcileOspf(int nodeId, Date now) {
    OspfElement element = m_ospfElementDao.findByNodeId(nodeId);
    if (element != null && element.getOspfNodeLastPollTime().getTime() < now.getTime()) {
        m_ospfElementDao.delete(element);
        m_ospfElementDao.flush();
    }
    m_ospfLinkDao.deleteByNodeIdOlderThen(nodeId, now);
    m_ospfLinkDao.flush();
}
Also used : OspfElement(org.opennms.netmgt.model.OspfElement)

Example 4 with OspfElement

use of org.opennms.netmgt.model.OspfElement in project opennms by OpenNMS.

the class EnLinkdElementFactory method convertFromModel.

@Transactional
@SuppressWarnings("deprecation")
private List<OspfLinkNode> convertFromModel(int nodeid, OspfLink link) {
    List<OspfLinkNode> linkNodes = new ArrayList<OspfLinkNode>();
    List<OspfElement> ospfElements = m_ospfElementDao.findAllByRouterId(link.getOspfRemRouterId());
    if (ospfElements.size() > 0) {
        for (OspfElement ospfElement : ospfElements) {
            OspfLinkNode linknode = new OspfLinkNode();
            linknode.setOspfIpAddr(str(link.getOspfIpAddr()));
            linknode.setOspfAddressLessIndex(link.getOspfAddressLessIndex());
            linknode.setOspfIfIndex(link.getOspfIfIndex());
            linknode.setOspfRemRouterId(getRemRouterIdString(str(link.getOspfRemRouterId()), ospfElement.getNode().getLabel()));
            linknode.setOspfRemRouterUrl(getNodeUrl(ospfElement.getNode().getId()));
            linknode.setOspfRemIpAddr(str(link.getOspfRemIpAddr()));
            linknode.setOspfRemAddressLessIndex(link.getOspfRemAddressLessIndex());
            if (ospfElement != null && linknode.getOspfRemIpAddr() != null)
                linknode.setOspfRemPortUrl(getIpInterfaceUrl(ospfElement.getNode().getId(), linknode.getOspfRemIpAddr()));
            linknode.setOspfLinkCreateTime(Util.formatDateToUIString(link.getOspfLinkCreateTime()));
            linknode.setOspfLinkLastPollTime(Util.formatDateToUIString(link.getOspfLinkLastPollTime()));
            linkNodes.add(linknode);
        }
    } else {
        OspfLinkNode linknode = new OspfLinkNode();
        linknode.setOspfIpAddr(str(link.getOspfIpAddr()));
        linknode.setOspfAddressLessIndex(link.getOspfAddressLessIndex());
        linknode.setOspfIfIndex(link.getOspfIfIndex());
        linknode.setOspfRemRouterId(str(link.getOspfRemRouterId()));
        linknode.setOspfRemIpAddr(str(link.getOspfRemIpAddr()));
        linknode.setOspfRemAddressLessIndex(link.getOspfRemAddressLessIndex());
        linknode.setOspfLinkCreateTime(Util.formatDateToUIString(link.getOspfLinkCreateTime()));
        linknode.setOspfLinkLastPollTime(Util.formatDateToUIString(link.getOspfLinkLastPollTime()));
        linkNodes.add(linknode);
    }
    Collections.sort(linkNodes);
    return linkNodes;
}
Also used : OspfElement(org.opennms.netmgt.model.OspfElement) ArrayList(java.util.ArrayList) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with OspfElement

use of org.opennms.netmgt.model.OspfElement in project opennms by OpenNMS.

the class EnLinkdSnmpIT method testOspfGeneralGroupWalk.

@Test
@JUnitSnmpAgents(value = { @JUnitSnmpAgent(host = SWITCH1_IP, port = 161, resource = "classpath:/linkd/nms17216/switch1-walk.txt") })
public void testOspfGeneralGroupWalk() throws Exception {
    SnmpAgentConfig config = SnmpPeerFactory.getInstance().getAgentConfig(InetAddress.getByName(SWITCH1_IP));
    String trackerName = "ospfGeneralGroup";
    final OspfGeneralGroupTracker ospfGeneralGroup = new OspfGeneralGroupTracker();
    try {
        m_client.walk(config, ospfGeneralGroup).withDescription(trackerName).withLocation(null).execute().get();
    } catch (final InterruptedException e) {
        LOG.error("run: collection interrupted, exiting", e);
        return;
    }
    OspfElement ospfElement = ospfGeneralGroup.getOspfElement();
    assertEquals(InetAddress.getByName("192.168.100.246"), ospfElement.getOspfRouterId());
    assertEquals(null, ospfElement.getOspfRouterIdNetmask());
    assertEquals(null, ospfElement.getOspfRouterIdIfindex());
    assertEquals(Status.enabled, ospfElement.getOspfAdminStat());
    assertEquals(2, ospfElement.getOspfVersionNumber().intValue());
    assertEquals(TruthValue.FALSE, ospfElement.getOspfBdrRtrStatus());
    assertEquals(TruthValue.FALSE, ospfElement.getOspfASBdrRtrStatus());
    final OspfIpAddrTableGetter ipAddrTableGetter = new OspfIpAddrTableGetter(config, m_client, null, 0);
    OspfElement ospfElementN = ipAddrTableGetter.get(ospfElement);
    assertEquals(InetAddress.getByName("192.168.100.246"), ospfElementN.getOspfRouterId());
    assertEquals(InetAddress.getByName("255.255.255.252"), ospfElementN.getOspfRouterIdNetmask());
    assertEquals(10101, ospfElementN.getOspfRouterIdIfindex().intValue());
    assertEquals(Status.enabled, ospfElementN.getOspfAdminStat());
    assertEquals(2, ospfElementN.getOspfVersionNumber().intValue());
    assertEquals(TruthValue.FALSE, ospfElementN.getOspfBdrRtrStatus());
    assertEquals(TruthValue.FALSE, ospfElementN.getOspfASBdrRtrStatus());
}
Also used : SnmpAgentConfig(org.opennms.netmgt.snmp.SnmpAgentConfig) OspfElement(org.opennms.netmgt.model.OspfElement) OspfGeneralGroupTracker(org.opennms.netmgt.enlinkd.snmp.OspfGeneralGroupTracker) OspfIpAddrTableGetter(org.opennms.netmgt.enlinkd.snmp.OspfIpAddrTableGetter) Test(org.junit.Test) JUnitSnmpAgents(org.opennms.core.test.snmp.annotations.JUnitSnmpAgents)

Aggregations

OspfElement (org.opennms.netmgt.model.OspfElement)5 Transactional (org.springframework.transaction.annotation.Transactional)2 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 JUnitSnmpAgents (org.opennms.core.test.snmp.annotations.JUnitSnmpAgents)1 OspfGeneralGroupTracker (org.opennms.netmgt.enlinkd.snmp.OspfGeneralGroupTracker)1 OspfIpAddrTableGetter (org.opennms.netmgt.enlinkd.snmp.OspfIpAddrTableGetter)1 OnmsNode (org.opennms.netmgt.model.OnmsNode)1 SnmpAgentConfig (org.opennms.netmgt.snmp.SnmpAgentConfig)1