private OnmsIpInterface lookupIpInterface(OnmsNode node, String ipAddress) { final OnmsIpInterface ipInterface = ipInterfaceDao.findByNodeIdAndIpAddress(node.getId(), ipAddress); if (ipInterface == null) { throw new IllegalArgumentException(String.format("No interface found with IP %s on node %s", ipAddress, node.getId())); } return ipInterface; } }
/** * This method is used to convert the event host into a hostname id by * performing a lookup in the database. If the conversion is successful then * the corresponding hostname will be returned to the caller. * * @param nodeId Node ID * @param hostip The event host * * @return The hostname */ @Override public String getHostName(final int nodeId, final String hostip) { OnmsIpInterface ints = ipInterfaceDao.findByNodeIdAndIpAddress(nodeId, hostip); if (ints == null) { return hostip; } else { final String hostname = ints.getIpHostName(); return (hostname == null) ? hostip : hostname; } }
private OnmsIpInterface lookupIpInterface(OnmsNode node, String ipAddress) { final OnmsIpInterface ipInterface = ipInterfaceDao.findByNodeIdAndIpAddress(node.getId(), ipAddress); if (ipInterface == null) { throw new IllegalArgumentException(String.format("No interface found with IP %s on node %s", ipAddress, node.getId())); } return ipInterface; } }
/** * This method is used to convert the event host into a hostname id by * performing a lookup in the database. If the conversion is successful then * the corresponding hostname will be returned to the caller. * * @param nodeId Node ID * @param hostip The event host * * @return The hostname */ @Override public String getHostName(final int nodeId, final String hostip) { OnmsIpInterface ints = ipInterfaceDao.findByNodeIdAndIpAddress(nodeId, hostip); if (ints == null) { return hostip; } else { final String hostname = ints.getIpHostName(); return (hostname == null) ? hostip : hostname; } }
/** {@inheritDoc} */ @Transactional @Override public OnmsMonitoredService addMonitoredService(final Integer nodeId, final String ipAddress, final String svcName) { final OnmsIpInterface iface = m_ipInterfaceDao.findByNodeIdAndIpAddress(nodeId, ipAddress); assertNotNull(iface, "could not find interface with nodeid %d and ipAddr %s", nodeId, ipAddress); return addMonitoredService(iface, svcName); }
/** {@inheritDoc} */ @Transactional @Override public OnmsMonitoredService addMonitoredService(final Integer nodeId, final String ipAddress, final String svcName) { final OnmsIpInterface iface = m_ipInterfaceDao.findByNodeIdAndIpAddress(nodeId, ipAddress); assertNotNull(iface, "could not find interface with nodeid %d and ipAddr %s", nodeId, ipAddress); return addMonitoredService(iface, svcName); }
@Override protected OnmsIpInterface query() { OnmsIpInterface dbIface = m_ipInterfaceDao.findByNodeIdAndIpAddress(nodeId, str(scannedIface.getIpAddress())); LOG.debug("Updating interface attributes for DB interface {} for node {} with ip {}", dbIface, nodeId, str(scannedIface.getIpAddress())); return dbIface; }
@Override protected OnmsIpInterface query() { OnmsIpInterface dbIface = m_ipInterfaceDao.findByNodeIdAndIpAddress(nodeId, str(scannedIface.getIpAddress())); LOG.debug("Updating interface attributes for DB interface {} for node {} with ip {}", dbIface, nodeId, str(scannedIface.getIpAddress())); return dbIface; }
@Override public String getIfAlias(long nodeId, String ipaddr) { OnmsIpInterface iface = ipInterfaceDao.findByNodeIdAndIpAddress((int)nodeId, ipaddr); if (iface != null && iface.getSnmpInterface() != null) { return iface.getSnmpInterface().getIfAlias(); } else { return null; } }
@Override public String getIfAlias(long nodeId, String ipaddr) { OnmsIpInterface iface = ipInterfaceDao.findByNodeIdAndIpAddress((int)nodeId, ipaddr); if (iface != null && iface.getSnmpInterface() != null) { return iface.getSnmpInterface().getIfAlias(); } else { return null; } }
@Override public void update(Integer nodeid, ReverseDnsRecord rdr) { OnmsIpInterface ipInterface = m_ipInterfaceDao.findByNodeIdAndIpAddress(nodeid, rdr.getIp().getHostAddress()); if (ipInterface != null) { ipInterface.setIpHostName(rdr.getHostname()); m_ipInterfaceDao.update(ipInterface); } }
/** * Sets the IP Address and Node ID in the Map. * * @param addr The IP Address to add. * @param nodeid The Node ID to add. * @return The nodeid if it existed in the map. */ @Override @Transactional public boolean setNodeId(final String location, final InetAddress addr, final int nodeid) { if (addr == null || nodeid == -1) { return false; } final OnmsIpInterface iface = m_ipInterfaceDao.findByNodeIdAndIpAddress(nodeid, str(addr)); if (iface == null) { return false; } LOG.debug("setNodeId: adding IP address to cache: {}:{} -> {}", location, str(addr), nodeid); m_lock.writeLock().lock(); try { return m_managedAddresses.put(new Key(location, addr), new Value(nodeid, iface.getIsSnmpPrimary())); } finally { m_lock.writeLock().unlock(); } }
@Override public T createCollectionAgentAndOverrideLocation(String nodeCriteria, InetAddress ipAddr, String location) { final OnmsNode node = nodeDao.get(nodeCriteria); if (node == null) { throw new IllegalArgumentException(String.format("No node found with lookup criteria: %s", nodeCriteria)); } final OnmsIpInterface ipInterface = ipInterfaceDao.findByNodeIdAndIpAddress( node.getId(), InetAddressUtils.str(ipAddr)); if (ipInterface == null) { throw new IllegalArgumentException(String.format("No interface found with IP %s on node %s", InetAddressUtils.str(ipAddr), nodeCriteria)); } final T agent = createAgent(ipInterface.getId(), ipInterfaceDao, transMgr, location); return agent; }
@Override public T createCollectionAgentAndOverrideLocation(String nodeCriteria, InetAddress ipAddr, String location) { final OnmsNode node = nodeDao.get(nodeCriteria); if (node == null) { throw new IllegalArgumentException(String.format("No node found with lookup criteria: %s", nodeCriteria)); } final OnmsIpInterface ipInterface = ipInterfaceDao.findByNodeIdAndIpAddress( node.getId(), InetAddressUtils.str(ipAddr)); if (ipInterface == null) { throw new IllegalArgumentException(String.format("No interface found with IP %s on node %s", InetAddressUtils.str(ipAddr), nodeCriteria)); } final T agent = createAgent(ipInterface.getId(), ipInterfaceDao, transMgr, location); return agent; }
@Transactional @Override public OnmsMonitoredService updateMonitoredServiceState(final Integer nodeId, final String ipAddress, final String svcName) { final OnmsIpInterface iface = m_ipInterfaceDao.findByNodeIdAndIpAddress(nodeId, ipAddress); assertNotNull(iface, "could not find interface with nodeid %d and ipAddr %s", nodeId, ipAddress);
@Transactional @Override public OnmsMonitoredService updateMonitoredServiceState(final Integer nodeId, final String ipAddress, final String svcName) { final OnmsIpInterface iface = m_ipInterfaceDao.findByNodeIdAndIpAddress(nodeId, ipAddress); assertNotNull(iface, "could not find interface with nodeid %d and ipAddr %s", nodeId, ipAddress);
/** {@inheritDoc} */ @Transactional @Override public void deleteInterface(final Integer nodeId, final String ipAddr) { LOG.debug("deleteInterface: nodeId={}, addr={}", nodeId, ipAddr); final OnmsIpInterface iface = m_ipInterfaceDao.findByNodeIdAndIpAddress(nodeId, ipAddr); if (iface != null) { final OnmsNode node = iface.getNode(); final boolean lastInterface = (node.getIpInterfaces().size() == 1); final DeleteEventVisitor visitor = new DeleteEventVisitor(m_eventForwarder); node.removeIpInterface(iface); m_nodeDao.saveOrUpdate(node); m_nodeDao.flush(); iface.visit(visitor); if (lastInterface) { LOG.debug("Deleting node {}", nodeId); m_nodeDao.delete(node); m_nodeDao.flush(); node.visit(visitor); } } }
/** {@inheritDoc} */ @Transactional @Override public void deleteInterface(final Integer nodeId, final String ipAddr) { LOG.debug("deleteInterface: nodeId={}, addr={}", nodeId, ipAddr); final OnmsIpInterface iface = m_ipInterfaceDao.findByNodeIdAndIpAddress(nodeId, ipAddr); if (iface != null) { final OnmsNode node = iface.getNode(); final boolean lastInterface = (node.getIpInterfaces().size() == 1); final DeleteEventVisitor visitor = new DeleteEventVisitor(m_eventForwarder); node.removeIpInterface(iface); m_nodeDao.saveOrUpdate(node); m_nodeDao.flush(); iface.visit(visitor); if (lastInterface) { LOG.debug("Deleting node {}", nodeId); m_nodeDao.delete(node); m_nodeDao.flush(); node.visit(visitor); } } }
return null; final OnmsIpInterface svcIface = m_ipInterfaceDao.findByNodeIdAndIpAddress(nodeId, ipAddress); if (svcIface == null) { LOG.info("unable to find IPInterface for nodeId={}, ipAddress={}", nodeId, ipAddress);
return null; final OnmsIpInterface svcIface = m_ipInterfaceDao.findByNodeIdAndIpAddress(nodeId, ipAddress); if (svcIface == null) { LOG.info("unable to find IPInterface for nodeId={}, ipAddress={}", nodeId, ipAddress);