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();
}
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;
}
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();
}
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;
}
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());
}
Aggregations