@Override public List<FlowNodeSummary> getFlowExporters() { return transactionOperations.execute(status -> this.nodeDao.findAllHavingFlows().stream()) .map(n -> new FlowNodeSummary(n.getId(), n.getForeignId(), n.getForeignSource(), n.getLabel(), n.getCategories().stream().map(OnmsCategory::getName).collect(Collectors.toList()))) .sorted(Comparator.comparingInt(FlowNodeSummary::getId)) .collect(Collectors.toList()); }
@Override public List<OnmsNode> findByForeignIdForLocation(String foreignId, String location) { List<OnmsNode> nodes = new ArrayList<OnmsNode>(); for (final OnmsNode node : findAll()) { if (node.getLabel().equals(foreignId) && (node.getLocation().getLocationName().equals(location))) { nodes.add(node); } } return nodes; }
private static OnmsGeolocation getGeoLocation(OnmsNode node) { if (node != null && node.getAssetRecord() != null && node.getAssetRecord().getGeolocation() != null) { return node.getAssetRecord().getGeolocation(); } return null; } }
@Override public ItemProvider<String> getItemProvider() { return node -> node.getParent().getForeignSource(); } }),
@Override public ItemProvider<String> getItemProvider() { return node -> node.getParent().getForeignId(); } }),
@Transactional(readOnly=true) private OnmsNode getDbNode(final OnmsNode node) { OnmsNode dbNode; if (node.getId() != null) { dbNode = m_nodeDao.get(node.getId()); } else { dbNode = m_nodeDao.findByForeignId(node.getForeignSource(), node.getForeignId()); } return dbNode; }
@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; }
@Transient @XmlElement(name="nodeLabel", required=false) public String getNodeLabel() { return m_node == null ? null : m_node.getLabel(); }
public AvailabilityNode(final OnmsNode node, final double availability) { m_nodeId = node.getId().longValue(); m_availability = availability; m_serviceCount = 0l; m_serviceDownCount = 0l; for (final OnmsIpInterface iface : node.getIpInterfaces()) { for (final OnmsMonitoredService svc : iface.getMonitoredServices()) { m_serviceCount++; if (svc.isDown()) { m_serviceDownCount++; } } } }
@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; }
/** {@inheritDoc} */ @Transactional @Override public OnmsNode getNode(final Integer nodeId) { final OnmsNode node = m_nodeDao.get(nodeId); // TODO: Does calling initialize() on an entity do anything? m_nodeDao.initialize(node); m_nodeDao.initialize(node.getCategories()); m_nodeDao.initialize(node.getIpInterfaces()); m_nodeDao.initialize(node.getLocation()); return node; }
/** * Returns the name to which the given node is associated, or null if the if node * is associated to either the default location, or no location. * * @param node * @return */ public static String getLocationNameOrNullIfDefault(OnmsNode node) { final String locationName = node.getLocation() != null ? node.getLocation().getLocationName() : null; return isDefaultLocationName(locationName) ? null : locationName; }
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 Set<String> getForeignIdsPerForeignSource(String foreignSource) { Set<String> set = new TreeSet<String>(); for (final OnmsNode node : findAll()) { if (node.getForeignId() != null) { set.add(node.getForeignId()); } } return set; }
/** * minimal constructor * * @param ipAddr a {@link java.lang.String} object. * @param node a {@link org.opennms.netmgt.model.OnmsNode} object. */ public OnmsIpInterface(InetAddress ipAddr, OnmsNode node) { m_ipAddress = ipAddr; m_node = node; if (node != null) { node.getIpInterfaces().add(this); } }
@Override public void findMatchingCallback(OnmsNode node) { node.getPrimaryInterface(); } }
/** {@inheritDoc} */ @Override public void visit(EntityVisitor visitor) { visitor.visitNode(this); for (OnmsIpInterface iface : getIpInterfaces()) { iface.visit(visitor); } for (OnmsSnmpInterface snmpIface : getSnmpInterfaces()) { snmpIface.visit(visitor); } visitor.visitNodeComplete(this); }