Search in sources :

Example 66 with OnmsSnmpInterface

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;
}
Also used : CriteriaBuilder(org.opennms.core.criteria.CriteriaBuilder) OnmsSnmpInterface(org.opennms.netmgt.model.OnmsSnmpInterface)

Example 67 with OnmsSnmpInterface

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;
}
Also used : OnmsIpInterface(org.opennms.netmgt.model.OnmsIpInterface) OnmsSnmpInterface(org.opennms.netmgt.model.OnmsSnmpInterface) GWTMonitoredService(org.opennms.features.poller.remote.gwt.client.GWTMonitoredService)

Example 68 with OnmsSnmpInterface

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());
    }
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) OnmsIpInterface(org.opennms.netmgt.model.OnmsIpInterface) OnmsSnmpInterface(org.opennms.netmgt.model.OnmsSnmpInterface)

Example 69 with OnmsSnmpInterface

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());
    }
}
Also used : OnmsSnmpInterface(org.opennms.netmgt.model.OnmsSnmpInterface) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 70 with OnmsSnmpInterface

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));
}
Also used : OnmsSnmpInterface(org.opennms.netmgt.model.OnmsSnmpInterface) Test(org.junit.Test) JUnitTemporaryDatabase(org.opennms.core.test.db.annotations.JUnitTemporaryDatabase)

Aggregations

OnmsSnmpInterface (org.opennms.netmgt.model.OnmsSnmpInterface)73 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)39 OnmsNode (org.opennms.netmgt.model.OnmsNode)38 Test (org.junit.Test)17 InetAddress (java.net.InetAddress)16 OnmsAlarm (org.opennms.netmgt.model.OnmsAlarm)10 NorthboundAlarm (org.opennms.netmgt.alarmd.api.NorthboundAlarm)9 OnmsEvent (org.opennms.netmgt.model.OnmsEvent)9 Transactional (org.springframework.transaction.annotation.Transactional)9 ArrayList (java.util.ArrayList)8 HashMap (java.util.HashMap)8 OnmsEventParameter (org.opennms.netmgt.model.OnmsEventParameter)8 LinkedHashSet (java.util.LinkedHashSet)5 LinkedList (java.util.LinkedList)5 HashSet (java.util.HashSet)4 List (java.util.List)4 Before (org.junit.Before)4 CriteriaBuilder (org.opennms.core.criteria.CriteriaBuilder)4 IpNetToMedia (org.opennms.netmgt.model.IpNetToMedia)4 OnmsMonitoredService (org.opennms.netmgt.model.OnmsMonitoredService)4