Search in sources :

Example 41 with OnmsSnmpInterface

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

the class EnLinkdElementFactory method convertFromModel.

@Transactional
@SuppressWarnings("deprecation")
private CdpLinkNode convertFromModel(int nodeid, CdpLink link) {
    CdpLinkNode linknode = new CdpLinkNode();
    linknode.setCdpLocalPort(getPortString(link.getCdpCacheIfIndex(), link.getCdpInterfaceName(), null));
    if (link.getCdpCacheIfIndex() != null)
        linknode.setCdpLocalPortUrl(getSnmpInterfaceUrl(nodeid, link.getCdpCacheIfIndex()));
    linknode.setCdpCacheAddressType(CiscoNetworkProtocolType.getTypeString(link.getCdpCacheAddressType().getValue()));
    linknode.setCdpCacheAddress(link.getCdpCacheAddress());
    linknode.setCdpCacheDeviceId(link.getCdpCacheDeviceId());
    linknode.setCdpCacheDevicePlatform(link.getCdpCacheDevicePlatform());
    linknode.setCdpCacheVersion(link.getCdpCacheVersion());
    linknode.setCdpCacheDevicePort(link.getCdpCacheDevicePort());
    CdpElement cdpCacheElement = m_cdpElementDao.findByGlobalDeviceId(link.getCdpCacheDeviceId());
    if (cdpCacheElement != null) {
        linknode.setCdpCacheDeviceUrl(getNodeUrl(cdpCacheElement.getNode().getId()));
        OnmsSnmpInterface cdpcachesnmp = getFromCdpCacheDevicePort(cdpCacheElement.getNode().getId(), link.getCdpCacheDevicePort());
        if (cdpcachesnmp != null) {
            linknode.setCdpCacheDevicePort(getPortString(cdpcachesnmp.getIfIndex(), link.getCdpCacheDevicePort(), cdpcachesnmp.getIfAlias()));
            linknode.setCdpCacheDevicePortUrl(getSnmpInterfaceUrl(cdpCacheElement.getNode().getId(), cdpcachesnmp.getIfIndex()));
        }
    }
    linknode.setCdpCreateTime(Util.formatDateToUIString(link.getCdpLinkCreateTime()));
    linknode.setCdpLastPollTime(Util.formatDateToUIString(link.getCdpLinkLastPollTime()));
    return linknode;
}
Also used : OnmsSnmpInterface(org.opennms.netmgt.model.OnmsSnmpInterface) CdpElement(org.opennms.netmgt.model.CdpElement) Transactional(org.springframework.transaction.annotation.Transactional)

Example 42 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 43 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 44 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 45 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)

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