use of org.opennms.netmgt.model.OnmsSnmpInterface in project opennms by OpenNMS.
the class EnLinkdElementFactory method getFromPhysAddress.
private OnmsSnmpInterface getFromPhysAddress(String physAddress) {
final CriteriaBuilder builder = new CriteriaBuilder(OnmsSnmpInterface.class);
builder.eq("physAddr", physAddress);
final List<OnmsSnmpInterface> nodes = m_snmpInterfaceDao.findMatching(builder.toCriteria());
if (nodes.size() == 1)
return nodes.get(0);
return null;
}
use of org.opennms.netmgt.model.OnmsSnmpInterface in project opennms by OpenNMS.
the class DefaultLocationDataService method transformMonitoredService.
private static GWTMonitoredService transformMonitoredService(final OnmsMonitoredService monitoredService) {
final GWTMonitoredService service = new GWTMonitoredService();
service.setId(monitoredService.getId());
final OnmsIpInterface ipi = monitoredService.getIpInterface();
if (ipi != null) {
service.setIpInterfaceId(ipi.getId());
if (ipi.getNode() != null) {
service.setNodeId(ipi.getNode().getId());
}
service.setIpAddress(str(ipi.getIpAddress()));
service.setHostname(ipi.getIpHostName());
final OnmsSnmpInterface snmpi = ipi.getSnmpInterface();
if (snmpi != null) {
service.setIfIndex(snmpi.getIfIndex());
}
}
service.setServiceName(monitoredService.getServiceName());
return service;
}
use of org.opennms.netmgt.model.OnmsSnmpInterface in project opennms by OpenNMS.
the class MockNodeDao method deleteObsoleteInterfaces.
@Override
public void deleteObsoleteInterfaces(final Integer nodeId, final Date scanStamp) {
final OnmsNode node = get(nodeId);
if (node == null)
return;
for (final OnmsIpInterface iface : findObsoleteIpInterfaces(nodeId, scanStamp)) {
LOG.debug("Deleting obsolete IP interface: {}", iface);
node.getIpInterfaces().remove(iface);
getIpInterfaceDao().delete(iface.getId());
}
for (final OnmsSnmpInterface iface : findObsoleteSnmpInterfaces(nodeId, scanStamp)) {
LOG.debug("Deleting obsolete SNMP interface: {}", iface);
node.getSnmpInterfaces().remove(iface);
getSnmpInterfaceDao().delete(iface.getId());
}
}
use of org.opennms.netmgt.model.OnmsSnmpInterface in project opennms by OpenNMS.
the class SnmpInterfaceDaoIT method testGet.
@Test
@Transactional
public void testGet() throws Exception {
Collection<OnmsSnmpInterface> snmpIfs = m_snmpInterfaceDao.findAll();
assertEquals(4, snmpIfs.size());
for (OnmsSnmpInterface snmpIf : snmpIfs) {
assertEquals(10000000, snmpIf.getIfSpeed().intValue());
assertNotNull(snmpIf.getNode());
assertEquals(1, snmpIf.getNode().getId().intValue());
assertEquals("node1", snmpIf.getNode().getLabel());
}
}
use of org.opennms.netmgt.model.OnmsSnmpInterface in project opennms by OpenNMS.
the class UpsertIT method testInsert.
@Test
@JUnitTemporaryDatabase
public void testInsert() {
String newIfName = "newIf0";
assertEquals(0, countIfs(m_populator.getNode1().getId(), 1001, newIfName));
// add non existent snmpiface
OnmsSnmpInterface snmpIface = new OnmsSnmpInterface();
snmpIface.setNode(m_populator.getNode1());
snmpIface.setIfIndex(1001);
snmpIface.setIfName(newIfName);
m_upsertService.upsert(m_populator.getNode1().getId(), /* nodeid */
snmpIface, 0);
assertEquals(1, countIfs(m_populator.getNode1().getId(), 1001, newIfName));
}
Aggregations