@Override public void findMatchingCallback(OnmsNode node) { node.getPrimaryInterface(); } }
@Override public void findMatchingCallback(OnmsNode node) { node.getPrimaryInterface(); } }
private OnmsIpInterface getCriticalInterface(OnmsNode parent) { OnmsIpInterface critIface = parent.getPrimaryInterface(); if (critIface != null) { return critIface; } return parent.getInterfaceWithService("ICMP"); }
/** * <p>getPrimaryIpInterface</p> * * @return an {@link OnmsIpInterface} object. */ @Transient @XmlTransient @JsonIgnore public OnmsIpInterface getPrimaryIpInterface() { return getNode().getPrimaryInterface(); }
private String getDefaultIp(Vertex vertex, Optional<OnmsNode> node) { if (hasValidIpAddress(vertex)) { return vertex.getIpAddress(); } if (node.isPresent() && node.get().getPrimaryInterface() != null) { return InetAddressUtils.str(node.get().getPrimaryInterface().getIpAddress()); } if (node.isPresent()) { return InetAddressUtils.str(node.get().getIpInterfaces().iterator().next().getIpAddress()); } throw new IllegalStateException("The vertex does not have a ip address or a node assigned."); }
/** * <p>getCriticalInterface</p> * * @return a {@link org.opennms.netmgt.model.OnmsIpInterface} object. */ @Transient @JsonIgnore public OnmsIpInterface getCriticalInterface() { OnmsIpInterface critIface = getPrimaryInterface(); if (critIface != null) { return critIface; } return getInterfaceWithService("ICMP"); }
private String getDefaultIp(Vertex vertex, Optional<OnmsNode> node) { if (hasValidIpAddress(vertex)) { return vertex.getIpAddress(); } if (node.isPresent() && node.get().getPrimaryInterface() != null) { return InetAddressUtils.str(node.get().getPrimaryInterface().getIpAddress()); } if (node.isPresent()) { return InetAddressUtils.str(node.get().getIpInterfaces().iterator().next().getIpAddress()); } throw new IllegalStateException("The vertex does not have a ip address or a node assigned."); }
@Override public CollectionAgent doInTransaction(TransactionStatus status) { final OnmsNode node = Iterables.getFirst(nodeDao.findByLabel(jtiMsg.getSystemId()), null); if (node != null) { final OnmsIpInterface primaryInterface = node.getPrimaryInterface(); return collectionAgentFactory.createCollectionAgent(primaryInterface); } return null; } });
/** {@inheritDoc} */ @Transactional @Override public OnmsIpInterface getPrimaryInterfaceForNode(final OnmsNode node) { final OnmsNode dbNode = getDbNode(node); if (dbNode == null) { return null; } else { final OnmsIpInterface primaryIface = dbNode.getPrimaryInterface(); if (primaryIface != null) { m_ipInterfaceDao.initialize(primaryIface); m_ipInterfaceDao.initialize(primaryIface.getMonitoredServices()); } return primaryIface; } }
/** {@inheritDoc} */ @Transactional @Override public OnmsIpInterface getPrimaryInterfaceForNode(final OnmsNode node) { final OnmsNode dbNode = getDbNode(node); if (dbNode == null) { return null; } else { final OnmsIpInterface primaryIface = dbNode.getPrimaryInterface(); if (primaryIface != null) { m_ipInterfaceDao.initialize(primaryIface); m_ipInterfaceDao.initialize(primaryIface.getMonitoredServices()); } return primaryIface; } }
@Override public CollectionAgent doInTransaction(TransactionStatus status) { OnmsNode node = Iterables.getFirst(nodeDao.findByLabelForLocation(msg.getNodeIdStr(), messageLog.getLocation()), null); if (node == null) { // If there is no matching label , Try matching with foreignId node = Iterables.getFirst(nodeDao.findByForeignIdForLocation(msg.getNodeIdStr(), messageLog.getLocation()), null); } if (node != null) { final OnmsIpInterface primaryInterface = node.getPrimaryInterface(); return collectionAgentFactory.createCollectionAgent(primaryInterface); } return null; } });
private String getSuitableIpForRancid(OnmsNode node){ LOG.debug("getSuitableIpForRancid: node: {} Foreign Source: {}", node.getForeignSource(), node.getNodeId()); OnmsIpInterface primaryInterface = node.getPrimaryInterface(); String ipaddr = "127.0.0.1"; if (primaryInterface == null) { LOG.debug("getSuitableIpForRancid: found null SNMP Primary Interface, getting interfaces"); Set<OnmsIpInterface> ipInterfaces = node.getIpInterfaces(); for (OnmsIpInterface onmsIpInterface : ipInterfaces) { LOG.debug("getSuitableIpForRancid: trying Interface with id: {}", onmsIpInterface.getId()); if (onmsIpInterface.getIpAddress() != null) { ipaddr = str(onmsIpInterface.getIpAddress()); } else { LOG.debug("getSuitableIpForRancid: found null ip address on Interface with id: {}", onmsIpInterface.getId()); } } } else { LOG.debug("getSuitableIpForRancid: found SNMP Primary Interface"); if (primaryInterface.getIpAddress() != null ) { ipaddr = str(primaryInterface.getIpAddress()); } else { LOG.debug("getSuitableIpForRancid: found null ip address on Primary Interface"); } } return ipaddr; }
private InetAddress getIpForNode(final OnmsNode node) { LOG.debug("getIpForNode: node: {} Foreign Source: {}", node.getNodeId(), node.getForeignSource()); final OnmsIpInterface primaryInterface = node.getPrimaryInterface(); InetAddress ipaddr = InetAddressUtils.getLocalHostAddress(); if (primaryInterface == null) { LOG.debug("getIpForNode: found null SNMP Primary Interface, getting interfaces"); final Set<OnmsIpInterface> ipInterfaces = node.getIpInterfaces(); for (final OnmsIpInterface onmsIpInterface : ipInterfaces) { LOG.debug("getIpForNode: trying Interface with id: {}", onmsIpInterface.getId()); if (InetAddressUtils.str(onmsIpInterface.getIpAddress()) != null) ipaddr = onmsIpInterface.getIpAddress(); else LOG.debug("getIpForNode: found null ip address on Interface with id: {}", onmsIpInterface.getId()); } } else { LOG.debug("getIpForNode: found SNMP Primary Interface"); if (InetAddressUtils.str(primaryInterface.getIpAddress()) != null ) ipaddr = primaryInterface.getIpAddress(); else LOG.debug("getIpForNode: found null ip address on Primary Interface"); } return ipaddr; }
private InetAddress getIpForNode(final OnmsNode node) { LOG.debug("getIpForNode: node: {} Foreign Source: {}", node.getNodeId(), node.getForeignSource()); final OnmsIpInterface primaryInterface = node.getPrimaryInterface(); InetAddress ipaddr = InetAddressUtils.getLocalHostAddress(); if (primaryInterface == null) { LOG.debug("getIpForNode: found null SNMP Primary Interface, getting interfaces"); final Set<OnmsIpInterface> ipInterfaces = node.getIpInterfaces(); for (final OnmsIpInterface onmsIpInterface : ipInterfaces) { LOG.debug("getIpForNode: trying Interface with id: {}", onmsIpInterface.getId()); if (InetAddressUtils.str(onmsIpInterface.getIpAddress()) != null) ipaddr = onmsIpInterface.getIpAddress(); else LOG.debug("getIpForNode: found null ip address on Interface with id: {}", onmsIpInterface.getId()); } } else { LOG.debug("getIpForNode: found SNMP Primary Interface"); if (InetAddressUtils.str(primaryInterface.getIpAddress()) != null ) ipaddr = primaryInterface.getIpAddress(); else LOG.debug("getIpForNode: found null ip address on Primary Interface"); } return ipaddr; }
private String getSuitableIpForRancid(OnmsNode node){ LOG.debug("getSuitableIpForRancid: node: {} Foreign Source: {}", node.getForeignSource(), node.getNodeId()); OnmsIpInterface primaryInterface = node.getPrimaryInterface(); String ipaddr = "127.0.0.1"; if (primaryInterface == null) { LOG.debug("getSuitableIpForRancid: found null SNMP Primary Interface, getting interfaces"); Set<OnmsIpInterface> ipInterfaces = node.getIpInterfaces(); for (OnmsIpInterface onmsIpInterface : ipInterfaces) { LOG.debug("getSuitableIpForRancid: trying Interface with id: {}", onmsIpInterface.getId()); if (onmsIpInterface.getIpAddress() != null) { ipaddr = str(onmsIpInterface.getIpAddress()); } else { LOG.debug("getSuitableIpForRancid: found null ip address on Interface with id: {}", onmsIpInterface.getId()); } } } else { LOG.debug("getSuitableIpForRancid: found SNMP Primary Interface"); if (primaryInterface.getIpAddress() != null ) { ipaddr = str(primaryInterface.getIpAddress()); } else { LOG.debug("getSuitableIpForRancid: found null ip address on Primary Interface"); } } return ipaddr; }
private InetAddress getIpForNode(final OnmsNode node) { LOG.debug("getIpForNode: node: {} Foreign Source: {}", node.getNodeId(), node.getForeignSource()); final OnmsIpInterface primaryInterface = node.getPrimaryInterface(); InetAddress ipaddr = InetAddressUtils.getLocalHostAddress(); if (primaryInterface == null) { LOG.debug("getIpForNode: found null SNMP Primary Interface, getting interfaces"); final Set<OnmsIpInterface> ipInterfaces = node.getIpInterfaces(); for (final OnmsIpInterface onmsIpInterface : ipInterfaces) { LOG.debug("getIpForNode: trying Interface with id: {}", onmsIpInterface.getId()); if (InetAddressUtils.str(onmsIpInterface.getIpAddress()) != null) ipaddr = onmsIpInterface.getIpAddress(); else LOG.debug("getIpForNode: found null ip address on Interface with id: {}", onmsIpInterface.getId()); } } else { LOG.debug("getIpForNode: found SNMP Primary Interface"); if (InetAddressUtils.str(primaryInterface.getIpAddress()) != null ) ipaddr = primaryInterface.getIpAddress(); else LOG.debug("getIpForNode: found null ip address on Primary Interface"); } return ipaddr; }
/** * <p>getSuitableIp</p> * * @param node a {@link org.opennms.netmgt.model.OnmsNode} object. * @return a {@link java.lang.String} object. */ public String getSuitableIp(final OnmsNode node){ final OnmsIpInterface primaryInterface = node.getPrimaryInterface(); if (primaryInterface == null) { final Set<OnmsIpInterface> ipInterfaces = node.getIpInterfaces(); for (final OnmsIpInterface onmsIpInterface : ipInterfaces) { return str(onmsIpInterface.getIpAddress()); } return "0.0.0.0"; } return str(primaryInterface.getIpAddress()); }
@Override public List<Node> findAllSnmpNode() { final List<Node> nodes = new ArrayList<Node>(); final Criteria criteria = new Criteria(OnmsNode.class); criteria.setAliases(Arrays.asList(new Alias[] { new Alias( "ipInterfaces", "iface", JoinType.LEFT_JOIN) })); criteria.addRestriction(new EqRestriction("type", NodeType.ACTIVE)); criteria.addRestriction(new EqRestriction("iface.isSnmpPrimary", PrimaryType.PRIMARY)); for (final OnmsNode node : m_nodeDao.findMatching(criteria)) { nodes.add(new Node(node.getId(), node.getLabel(), node.getPrimaryInterface().getIpAddress(), node.getSysObjectId(), node.getSysName(),node.getLocation() == null ? null : node.getLocation().getLocationName())); } return nodes; }
@Override public Node getSnmpNode(final int nodeid) { final Criteria criteria = new Criteria(OnmsNode.class); criteria.setAliases(Arrays.asList(new Alias[] { new Alias( "ipInterfaces", "iface", JoinType.LEFT_JOIN) })); criteria.addRestriction(new EqRestriction("type", NodeType.ACTIVE)); criteria.addRestriction(new EqRestriction("iface.isSnmpPrimary", PrimaryType.PRIMARY)); criteria.addRestriction(new EqRestriction("id", nodeid)); final List<OnmsNode> nodes = m_nodeDao.findMatching(criteria); if (nodes.size() > 0) { final OnmsNode node = nodes.get(0); return new Node(node.getId(), node.getLabel(), node.getPrimaryInterface().getIpAddress(), node.getSysObjectId(), node.getSysName(),node.getLocation() == null ? null : node.getLocation().getLocationName()); } else { return null; } }
nodeInfo.setMaintcontract(node.getAssetRecord().getMaintcontract()); if (node.getPrimaryInterface() != null) { nodeInfo.setIpAddress(InetAddressUtils.str(node.getPrimaryInterface().getIpAddress()));