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