private OnmsIpInterface getIpInterface(int nodeId, String ipAddress) { OnmsNode node = m_nodeDao.load(nodeId); return node.getIpInterfaceByIpAddress(ipAddress); }
@Override public OnmsSnmpInterface doInsert() { // add the interface to the node, if it wasn't found final OnmsNode dbNode = m_nodeDao.load(nodeId); assertNotNull(dbNode, "no node found with nodeId %d", nodeId); // for performance reasons we don't add the snmp interface to the node so we avoid loading all the interfaces // setNode only sets the node in the interface snmpInterface.setNode(dbNode); LOG.info("Saving SnmpInterface {}", snmpInterface); m_snmpInterfaceDao.save(snmpInterface); m_snmpInterfaceDao.flush(); return snmpInterface; }
@Override public OnmsSnmpInterface doInsert() { // add the interface to the node, if it wasn't found final OnmsNode dbNode = m_nodeDao.load(nodeId); assertNotNull(dbNode, "no node found with nodeId %d", nodeId); // for performance reasons we don't add the snmp interface to the node so we avoid loading all the interfaces // setNode only sets the node in the interface snmpInterface.setNode(dbNode); LOG.info("Saving SnmpInterface {}", snmpInterface); m_snmpInterfaceDao.save(snmpInterface); m_snmpInterfaceDao.flush(); return snmpInterface; }
/** * <p>walk</p> */ public void walk() { SortedMap<Integer, String> map = getFilterDao().getNodeMap(m_filter); if (map != null) { for (final Integer nodeId : map.keySet()) { final OnmsNode node = getNodeDao().load(nodeId); m_visitor.visitNode(node); } } }
/** * <p>walk</p> */ public void walk() { EntityVisitor visitor = new AbstractEntityVisitor() { @Override public void visitNode(OnmsNode node) { walk(node); } }; SortedMap<Integer, String> map = getFilterDao().getNodeMap(m_filter); for (final Integer nodeId : map.keySet()) { final OnmsNode node = getNodeDao().load(nodeId); visitor.visitNode(node); } }
/** * {@inheritDoc} * * Use the node id to find the value associated with column defined in the view. The view defines a column * and column value to be used by default. This method determines the column value using the value associated * with the asset record for the given nodeid. * @see org.opennms.web.svclayer.SiteStatusViewService#createAggregateStatusesUsingNodeId(int, java.lang.String) */ @Override public Collection<AggregateStatus> createAggregateStatusesUsingNodeId(int nodeId, String viewName) { OnmsNode node = m_nodeDao.load(nodeId); //TODO this is a hack. need to use reflection to get the right column instead of building. return createAggregateStatuses(createAggregateStatusView(viewName), node.getAssetRecord().getBuilding()); }
@Override protected OnmsIpInterface doInsert() { final OnmsNode dbNode = m_nodeDao.load(nodeId); assertNotNull(dbNode, "no node found with nodeId %d", nodeId); // for performance reasons we don't add the IP interface to the node so we avoid loading all the interfaces // setNode only sets the node in the interface scannedIface.setNode(dbNode); saveOrUpdate(scannedIface); m_ipInterfaceDao.flush(); final AddEventVisitor visitor = new AddEventVisitor(m_eventForwarder); scannedIface.visit(visitor); return scannedIface; } }.execute();
/** * {@inheritDoc} * * Use the node id to find the value associated with column defined in the view. The view defines a column * and column value to be used by default. This method determines the column value using the value associated * with the asset record for the given nodeid. * @see org.opennms.web.svclayer.SiteStatusViewService#createAggregateStatusesUsingNodeId(int, java.lang.String) */ @Override public Collection<AggregateStatus> createAggregateStatusesUsingNodeId(int nodeId, String viewName) { OnmsNode node = m_nodeDao.load(nodeId); //TODO this is a hack. need to use reflection to get the right column instead of building. return createAggregateStatuses(createAggregateStatusView(viewName), node.getAssetRecord().getBuilding()); }
@Override protected OnmsIpInterface doInsert() { final OnmsNode dbNode = m_nodeDao.load(nodeId); assertNotNull(dbNode, "no node found with nodeId %d", nodeId); // for performance reasons we don't add the IP interface to the node so we avoid loading all the interfaces // setNode only sets the node in the interface scannedIface.setNode(dbNode); saveOrUpdate(scannedIface); m_ipInterfaceDao.flush(); final AddEventVisitor visitor = new AddEventVisitor(m_eventForwarder); scannedIface.visit(visitor); return scannedIface; } }.execute();
public void testFilteredResourceAttributeFilteringWithNoMatch() throws Exception { final OnmsNode node = new OnmsNode(); node.setId(1); node.setLabel("Node One"); EasyMock.expect(m_nodeDao.load(1)).andReturn(node); MockResourceType resourceType = new MockResourceType(); resourceType.setName("interfaceSnmp"); OnmsAttribute attribute = new RrdGraphAttribute("IfInOctets", "something", "something else"); OnmsResource resource = new OnmsResource(node.getId().toString(), node.getLabel(), resourceType, Collections.singleton(attribute), ResourcePath.get("foo")); ReportDefinition def = createReportDefinition(); def.getReport().getPackage().setFilter(""); def.setResourceAttributeKey("ifSpeed"); def.setResourceAttributeValueMatch("100000000"); ReportInstance report = def.createReport(m_nodeDao, m_resourceDao, m_fetchStrategy, m_filterDao); SortedMap<Integer,String> sortedNodeMap = new TreeMap<Integer, String>(); sortedNodeMap.put(node.getId(), node.getLabel()); EasyMock.expect(m_filterDao.getNodeMap("")).andReturn(sortedNodeMap); EasyMock.expect(m_resourceDao.getResourceForNode(node)).andReturn(resource); m_mocks.replayAll(); report.walk(); assertEquals("results size", 0, report.getResults().size()); }
node.setId(1); node.setLabel("Node One"); EasyMock.expect(m_nodeDao.load(1)).andReturn(node);
EasyMock.expect(m_nodeDao.load(1)).andReturn(nodeBuilder.getNode()).anyTimes();