@Override public Integer getId() { return entity.getId(); } }
@Transient @XmlTransient public Integer getNodeId() { if (m_node != null) { return m_node.getId(); } return null; }
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; } }
@Override public Map<Integer, String> getAllLabelsById() { Map<Integer, String> allLabelsById = new HashMap<Integer, String>(); for (final OnmsNode node : findAll()) { allLabelsById.put(node.getId(), node.getLabel()); } return allLabelsById; }
@Override public Map<String, Integer> getForeignIdToNodeIdMap(final String foreignSource) { final Map<String, Integer> nodes = new HashMap<String, Integer>(); for (final OnmsNode node : findAll()) { if (foreignSource.equals(node.getForeignSource())) { nodes.put(node.getForeignId(), node.getId()); } } return nodes; }
@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 Map<String, Integer> findImportedAssetNumbersToNodeIds(final String foreignSource) { final Map<String,Integer> ret = new HashMap<String,Integer>(); for (final OnmsAssetRecord asset : findAll()) { ret.put(asset.getAssetNumber(), asset.getNode().getId()); } return ret; }
@Override public OnmsHwEntity findRootByNodeId(Integer nodeId) { for (final OnmsHwEntity entity : findAll()) { if (entity.getNode().getId().equals(nodeId) && entity.getParent() == null) { return entity; } } return null; }
/** * <p>createNodeGainedInterfaceEvent</p> * * @param iface a {@link org.opennms.netmgt.model.OnmsIpInterface} object. * @return a {@link org.opennms.netmgt.xml.event.Event} object. */ protected Event createNodeGainedInterfaceEvent(OnmsIpInterface iface) { return EventUtils.createNodeGainedInterfaceEvent(m_eventSource, iface.getNode().getId(), iface.getIpAddress()); }
@Override public void visitNodeComplete(final OnmsNode node) { m_eventForwarder.sendNow(EventUtils.createNodeDeletedEvent(m_eventSource, node.getId(), node.getLabel(), node.getLabel())); } }
@Override protected BridgeMacLink query() { return m_dao.getByNodeIdBridgePortMac(saveMe.getNode().getId(), saveMe.getBridgePort(), saveMe.getMacAddress()); }
protected static ResourcePath getResourcePathForNode(OnmsNode node) { // Use the storeByFs path when enabled, falling back to the node id path when // the node in question has no foreign source or foreign id if (ResourceTypeUtils.isStoreByForeignSource() && node.getForeignSource() != null && node.getForeignId() != null) { return ResourcePath.get(ResourceTypeUtils.SNMP_DIRECTORY, ResourceTypeUtils.FOREIGN_SOURCE_DIRECTORY, node.getForeignSource(), node.getForeignId()); } else { return ResourcePath.get(ResourceTypeUtils.SNMP_DIRECTORY, Integer.toString(node.getId())); } }
protected OnmsResource createResourceForNode(OnmsNode node) { final ResourcePath path = getResourcePathForNode(node); final LazyChildResourceLoader loader = new LazyChildResourceLoader(m_resourceDao); final String resourceName = node.getForeignSource() != null && node.getForeignId() != null ? String.format("%s:%s", node.getForeignSource(), node.getForeignId()) : Integer.toString(node.getId()); final OnmsResource resource = new OnmsResource(resourceName, node.getLabel(), this, s_emptyAttributeSet, new LazyList<OnmsResource>(loader), path); resource.setEntity(node); loader.setParent(resource); return resource; }
public OpennmsModelProtos.NodeCriteria.Builder toNodeCriteria(OnmsNode node) { final OpennmsModelProtos.NodeCriteria.Builder builder = OpennmsModelProtos.NodeCriteria.newBuilder() .setId(node.getId()); if (node.getForeignSource() != null) { builder.setForeignSource(node.getForeignSource()); } if (node.getForeignId() != null) { builder.setForeignId(node.getForeignId()); } return builder; }
public static BridgePort getFromDesignatedBridgeBridgeLink(BridgeBridgeLink link) { BridgePort bp = new BridgePort(); bp.setNodeId(link.getDesignatedNode().getId()); bp.setBridgePort(link.getDesignatedPort()); bp.setBridgePortIfIndex(link.getDesignatedPortIfIndex()); bp.setVlan(link.getDesignatedVlan()); return bp; }
@Test public void testPersistStringAttributeWithParentDirectory() throws Exception { initPersister(); File nodeDir = m_fileAnticipator.tempDir(getSnmpRrdDirectory(), m_node.getId().toString()); m_fileAnticipator.expecting(nodeDir, RrdResourceAttributeUtils.STRINGS_PROPERTIES_FILE_NAME); CollectionAttribute attribute = buildStringAttribute(); m_persister.persistStringAttribute(attribute); }
private CollectionAgent createAgent(OnmsIpInterface ipIf, OnmsNode node, String location) { final CollectionAgentDTO agent = new CollectionAgentDTO(); agent.setAddress(ipIf.getIpAddress()); agent.setForeignId(node.getForeignId()); agent.setForeignSource(node.getForeignSource()); agent.setNodeId(node.getId()); agent.setNodeLabel(node.getLabel()); agent.setLocationName(location); agent.setStorageResourcePath(DefaultCollectionAgentService.createStorageResourcePath(agent)); agent.setStoreByForeignSource(storeByForeignSource); return agent; }
private QueryResource getResourceInfo(final OnmsResource resource, final Source source) { if (resource == null) return null; final OnmsNode node = getNode(resource, source); return new QueryResource( resource.getId().toString(), resource.getParent() == null? null : resource.getParent().getId().toString(), resource.getLabel(), resource.getName(), node == null? null : new QueryNode(node.getId(), node.getForeignSource(), node.getForeignId(), node.getLabel()) ); } }