/** * <p>getIsSnmpPrimary</p> * * @return a {@link org.opennms.netmgt.model.PrimaryType} object. */ @Override public PrimaryType getIsSnmpPrimary() { return getIpInterface().getIsSnmpPrimary(); }
public static IpInterfaceTopologyEntity create(OnmsIpInterface ipInterface) { return new IpInterfaceTopologyEntity( ipInterface.getId(), ipInterface.getIpAddress(), ipInterface.getIsManaged(), ipInterface.getIsSnmpPrimary(), Optional.ofNullable(ipInterface.getNode()).map(OnmsNode::getId).orElse(null), Optional.ofNullable(ipInterface.getSnmpInterface()).map(OnmsSnmpInterface::getId).orElse(null)); }
List<OnmsIpInterface> primaryInterfaces = new ArrayList<>(); for(OnmsIpInterface iface : getIpInterfaces()) { if (PrimaryType.PRIMARY.equals(iface.getIsSnmpPrimary())) { primaryInterfaces.add(iface);
/** * 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(); } }
private void update(OnmsIpInterface imported, OnmsIpInterface iface, List<Event> events) { if (!nullSafeEquals(iface.getIsManaged(), imported.getIsManaged())) iface.setIsManaged(imported.getIsManaged()); if (!nullSafeEquals(iface.getIsSnmpPrimary(), imported.getIsSnmpPrimary())) { iface.setIsSnmpPrimary(imported.getIsSnmpPrimary()); // TODO: send snmpPrimary event } if (isSnmpDataForInterfacesUpToDate()) { updateSnmpInterface(imported, iface); } if (!nullSafeEquals(iface.getIpHostName(), imported.getIpHostName())) iface.setIpHostName(imported.getIpHostName()); updateServices(iface, imported, events); }
private void dataSourceSyncWithinTransaction() { m_lock.writeLock().lock(); try { /* * Make a new list with which we'll replace the existing one, that way * if something goes wrong with the DB we won't lose whatever was already * in there */ final SortedSetMultimap<Key, Value> newAlreadyDiscovered = Multimaps.newSortedSetMultimap(Maps.newHashMap(), TreeSet::new); // Fetch all non-deleted nodes final CriteriaBuilder builder = new CriteriaBuilder(OnmsNode.class); builder.ne("type", String.valueOf(NodeType.DELETED.value())); for (OnmsNode node : m_nodeDao.findMatching(builder.toCriteria())) { for (final OnmsIpInterface iface : node.getIpInterfaces()) { // Skip deleted interfaces // TODO: Refactor the 'D' value with an enumeration if ("D".equals(iface.getIsManaged())) { continue; } LOG.debug("Adding entry: {}:{} -> {}", node.getLocation().getLocationName(), iface.getIpAddress(), node.getId()); newAlreadyDiscovered.put(new Key(node.getLocation().getLocationName(), iface.getIpAddress()), new Value(node.getId(), iface.getIsSnmpPrimary())); } } m_managedAddresses.clear(); m_managedAddresses.putAll(newAlreadyDiscovered); LOG.info("dataSourceSync: initialized list of managed IP addresses with {} members", m_managedAddresses.size()); } finally { m_lock.writeLock().unlock(); } }
if (hasNewCollectionTypeValue(scannedIface.getIsSnmpPrimary(), getIsSnmpPrimary())) { setIsSnmpPrimary(scannedIface.getIsSnmpPrimary());
public OpennmsModelProtos.IpInterface.Builder toIpInterface(OnmsIpInterface ipInterface) { if (ipInterface == null) { return null; } final OpennmsModelProtos.IpInterface.Builder builder = OpennmsModelProtos.IpInterface.newBuilder() .setId(ipInterface.getId()) .setIpAddress(InetAddressUtils.toIpAddrString(ipInterface.getIpAddress())); final OnmsSnmpInterface snmpInterface = ipInterface.getSnmpInterface(); if (snmpInterface != null && snmpInterface.getIfIndex() != null) { builder.setIfIndex(snmpInterface.getIfIndex()); } final PrimaryType primaryType = ipInterface.getIsSnmpPrimary(); if (PrimaryType.PRIMARY.equals(primaryType)) { builder.setPrimaryType(OpennmsModelProtos.IpInterface.PrimaryType.PRIMARY); } else if (PrimaryType.SECONDARY.equals(primaryType)) { builder.setPrimaryType(OpennmsModelProtos.IpInterface.PrimaryType.SECONDARY); } else if (PrimaryType.NOT_ELIGIBLE.equals(primaryType)) { builder.setPrimaryType(OpennmsModelProtos.IpInterface.PrimaryType.NOT_ELIGIBLE); } ipInterface.getMonitoredServices().forEach(svc -> builder.addService(svc.getServiceName())); return builder; }
public OpennmsModelProtos.IpInterface.Builder toIpInterface(OnmsIpInterface ipInterface) { if (ipInterface == null) { return null; } final OpennmsModelProtos.IpInterface.Builder builder = OpennmsModelProtos.IpInterface.newBuilder() .setId(ipInterface.getId()) .setIpAddress(InetAddressUtils.toIpAddrString(ipInterface.getIpAddress())); final OnmsSnmpInterface snmpInterface = ipInterface.getSnmpInterface(); if (snmpInterface != null && snmpInterface.getIfIndex() != null) { builder.setIfIndex(snmpInterface.getIfIndex()); } final PrimaryType primaryType = ipInterface.getIsSnmpPrimary(); if (PrimaryType.PRIMARY.equals(primaryType)) { builder.setPrimaryType(OpennmsModelProtos.IpInterface.PrimaryType.PRIMARY); } else if (PrimaryType.SECONDARY.equals(primaryType)) { builder.setPrimaryType(OpennmsModelProtos.IpInterface.PrimaryType.SECONDARY); } else if (PrimaryType.NOT_ELIGIBLE.equals(primaryType)) { builder.setPrimaryType(OpennmsModelProtos.IpInterface.PrimaryType.NOT_ELIGIBLE); } ipInterface.getMonitoredServices().forEach(svc -> builder.addService(svc.getServiceName())); return builder; }
assertEquals(PrimaryType.NOT_ELIGIBLE, node1.getIpInterfaceByIpAddress("172.16.0.1").getIsSnmpPrimary()); assertEquals(PrimaryType.NOT_ELIGIBLE, node1.getIpInterfaceByIpAddress("172.17.0.1").getIsSnmpPrimary()); assertEquals(PrimaryType.PRIMARY, node1.getIpInterfaceByIpAddress("192.168.0.10").getIsSnmpPrimary()); assertEquals("custom-location", node1.getLocation().getLocationName()); assertEquals(PrimaryType.PRIMARY, node2.getIpInterfaceByIpAddress("172.16.0.1").getIsSnmpPrimary()); assertEquals(PrimaryType.SECONDARY, node2.getIpInterfaceByIpAddress("172.17.0.1").getIsSnmpPrimary()); assertEquals(PrimaryType.NOT_ELIGIBLE, node2.getIpInterfaceByIpAddress("192.168.0.20").getIsSnmpPrimary()); assertEquals("Default", node2.getLocation().getLocationName());