private void updateParent(final OnmsSnmpInterface iface) { OnmsNode node = null; if (iface.getNodeId() != null) { node = getNodeDao().get(iface.getNodeId()); } else if (iface.getNode() != null) { node = getNodeDao().findByForeignId(iface.getNode().getForeignSource(), iface.getNode().getForeignId()); } if (node != null && node != iface.getNode()) { LOG.debug("merging node {} into node {}", iface.getNode(), node); node.mergeNode(iface.getNode(), new NullEventForwarder(), false); iface.setNode(node); } if (!iface.getNode().getSnmpInterfaces().contains(iface)) { LOG.debug("adding SNMP interface to node {}: {}", iface.getNode().getId(), iface); iface.getNode().addSnmpInterface(iface); } }
/** * <p>getPrimaryIpInterface</p> * * @return an {@link OnmsIpInterface} object. */ @Transient @XmlTransient @JsonIgnore public OnmsIpInterface getPrimaryIpInterface() { return getNode().getPrimaryInterface(); }
@Override public OnmsSnmpInterface findByNodeIdAndIfIndex(final Integer nodeId, final Integer ifIndex) { for (final OnmsSnmpInterface iface : findAll()) { if (nodeId.equals(iface.getNode().getId()) && ifIndex.equals(iface.getIfIndex())) { return iface; } } return null; }
private void updateParent(final OnmsSnmpInterface iface) { OnmsNode node = null; if (iface.getNodeId() != null) { node = getNodeDao().get(iface.getNodeId()); } else if (iface.getNode() != null) { node = getNodeDao().findByForeignId(iface.getNode().getForeignSource(), iface.getNode().getForeignId()); } if (node != null && node != iface.getNode()) { LOG.debug("merging node {} into node {}", iface.getNode(), node); node.mergeNode(iface.getNode(), new NullEventForwarder(), false); iface.setNode(node); } if (!iface.getNode().getSnmpInterfaces().contains(iface)) { LOG.debug("adding SNMP interface to node {}: {}", iface.getNode().getId(), iface); iface.getNode().addSnmpInterface(iface); } }
@Override public OnmsSnmpInterface findByNodeIdAndIfIndex(final Integer nodeId, final Integer ifIndex) { for (final OnmsSnmpInterface iface : findAll()) { if (nodeId.equals(iface.getNode().getId()) && ifIndex.equals(iface.getIfIndex())) { return iface; } } return null; }
@Override public OnmsSnmpInterface findByForeignKeyAndIfIndex(final String foreignSource, final String foreignId, final Integer ifIndex) { for (final OnmsSnmpInterface iface : findAll()) { final OnmsNode node = iface.getNode(); if (foreignSource.equals(node.getForeignSource()) && foreignId.equals(node.getForeignId()) && ifIndex.equals(iface.getIfIndex())) { return iface; } } return null; }
@Override public OnmsSnmpInterface findByForeignKeyAndIfIndex(final String foreignSource, final String foreignId, final Integer ifIndex) { for (final OnmsSnmpInterface iface : findAll()) { final OnmsNode node = iface.getNode(); if (foreignSource.equals(node.getForeignSource()) && foreignId.equals(node.getForeignId()) && ifIndex.equals(iface.getIfIndex())) { return iface; } } return null; }
public static SnmpInterfaceTopologyEntity create(OnmsSnmpInterface snmpInterface) { return new SnmpInterfaceTopologyEntity( snmpInterface.getId(), snmpInterface.getIfIndex(), snmpInterface.getIfName(), snmpInterface.getIfSpeed(), Optional.ofNullable(snmpInterface.getNode()).map(OnmsNode::getId).orElse(null) ); }
/** * <p>toString</p> * * @return a {@link java.lang.String} object. */ @Override public String toString() { return MoreObjects.toStringHelper(this) .add("snmpphysaddr", getPhysAddr()) .add("snmpifindex", getIfIndex()) .add("snmpifdescr", getIfDescr()) .add("snmpiftype", getIfType()) .add("snmpifname", getIfName()) .add("snmpifspeed", getIfSpeed()) .add("snmpifadminstatus", getIfAdminStatus()) .add("snmpifoperstatus", getIfOperStatus()) .add("snmpifalias", getIfAlias()) .add("snmpCollect", getCollect()) .add("snmpPoll", getPoll()) .add("nodeId", getNode() == null ? null : getNode().getId()) .add("lastCapsdPoll", getLastCapsdPoll()) .add("lastSnmpPoll", getLastSnmpPoll()) .add("hasFlows", getHasFlows()) .toString(); }
private OnmsIpInterface createIpInterface(OnmsSnmpInterface snmp, InetAddress inetAddress) { OnmsIpInterface ip = new OnmsIpInterface(); ip.setSnmpInterface(snmp); ip.setIpLastCapsdPoll(new Date()); ip.setNode(snmp.getNode()); ip.setIpAddress(inetAddress); return ip; }
public InterfaceBuilder addIpInterface(final String ipAddress) { final OnmsIpInterface iface = new OnmsIpInterface(InetAddressUtils.addr(ipAddress), m_snmpIf.getNode()); m_snmpIf.addIpInterface(iface); return new InterfaceBuilder(iface); } }
/** * <p>Constructor for SnmpIfData.</p> * * @param snmpIface a {@link org.opennms.netmgt.model.OnmsSnmpInterface} object. */ public SnmpIfData(OnmsSnmpInterface snmpIface) { m_nodeId = nullSafeUnbox(snmpIface.getNode().getId(), -1); m_collectionEnabled = snmpIface.isCollectionEnabled(); m_ifIndex = nullSafeUnbox(snmpIface.getIfIndex(), -1); m_ifType = nullSafeUnbox(snmpIface.getIfType(), -1); m_rrdLabel = snmpIface.computeLabelForRRD(); m_ifAlias = snmpIface.getIfAlias(); m_attributes.put("snmpphysaddr", snmpIface.getPhysAddr()); m_attributes.put("snmpifindex", Integer.toString(m_ifIndex)); m_attributes.put("snmpifdescr", snmpIface.getIfDescr()); m_attributes.put("snmpiftype", Integer.toString(m_ifType)); m_attributes.put("snmpifname", snmpIface.getIfName()); m_attributes.put("snmpifadminstatus", Integer.toString(nullSafeUnbox(snmpIface.getIfAdminStatus(), -1))); m_attributes.put("snmpifoperstatus", Integer.toString(nullSafeUnbox(snmpIface.getIfOperStatus(), -1))); m_attributes.put("snmpifspeed", Long.toString(nullSafeUnbox(snmpIface.getIfSpeed(), -1))); m_attributes.put("snmpifalias", m_ifAlias); }
/** {@inheritDoc} */ @Override public void update(OnmsSnmpInterface snmpinterface) { OnmsSnmpInterface dbSnmpInterface = getSnmpInterfaceDao().findByNodeIdAndIfIndex(snmpinterface.getNode().getId(), snmpinterface.getIfIndex()); if (dbSnmpInterface == null) { log().debug("updating SnmpInterface: no interface found on db for: " + snmpinterface.toString()); } else { dbSnmpInterface.setIfOperStatus(snmpinterface.getIfOperStatus()); dbSnmpInterface.setIfAdminStatus(snmpinterface.getIfAdminStatus()); dbSnmpInterface.setLastSnmpPoll(snmpinterface.getLastSnmpPoll()); log().debug("updating SnmpInterface: " + dbSnmpInterface.toString()); getSnmpInterfaceDao().update(dbSnmpInterface); } }