/** * <p>getMonitoringLocations</p> * * @return a {@link java.util.Collection} object. */ @Transactional(readOnly=true) @Override public Collection<OnmsMonitoringLocation> getMonitoringLocations() { return m_monitoringLocationDao.findAll(); }
private List<String> getPackageNameForLocation(final String location) { final OnmsMonitoringLocation def = m_monitoringLocationDao.get(location); if (def == null) { throw new IllegalStateException("Location definition '" + location + "' could not be found"); } return def.getPollingPackageNames(); }
private void updateLocation(final OnmsNode node) { if (node.getLocation() == null) { node.setLocation(m_monitoringLocationDao.getDefaultLocation()); } else { node.setLocation(createLocationIfNecessary(node.getLocation().getLocationName())); } }
def.setPriority(1L); def.setTags(Collections.singletonList("blah")); m_monitoringLocationDao.save(def);
private void updateLocation(final OnmsNode node) { if (node.getLocation() == null) { node.setLocation(m_monitoringLocationDao.getDefaultLocation()); } else { node.setLocation(createLocationIfNecessary(node.getLocation().getLocationName())); } }
m_monitoringLocationDao.save(location);
@Override protected OnmsMonitoringLocation query() { return m_dao.get(location.getLocationName()); }
/** * <p>getMonitoringLocations</p> * * @return a {@link java.util.Collection} object. */ @Transactional(readOnly=true) @Override public Collection<OnmsMonitoringLocation> getMonitoringLocations() { return m_monitoringLocationDao.findAll(); }
/** {@inheritDoc} */ @Transactional @Override public OnmsNode getRequisitionedNode(final String foreignSource, final String foreignId) throws ForeignSourceRepositoryException { OnmsNodeRequisition nodeReq = null; try { nodeReq = m_foreignSourceRepository.getNodeRequisition(foreignSource, foreignId); } catch (ForeignSourceRepositoryException e) { // just fall through, nodeReq will be null } if (nodeReq == null) { LOG.warn("nodeReq for node {}:{} cannot be null!", foreignSource, foreignId); return null; } final OnmsNode node = nodeReq.constructOnmsNodeFromRequisition(); // fill in real database categories final HashSet<OnmsCategory> dbCategories = new HashSet<>(); for(final OnmsCategory category : node.getCategories()) { dbCategories.add(createCategoryIfNecessary(category.getName())); } node.setCategories(dbCategories); if (node.getLocation() == null || Strings.isNullOrEmpty(node.getLocation().getLocationName())) { node.setLocation(m_monitoringLocationDao.getDefaultLocation()); } // fill in real service types node.visit(new ServiceTypeFulfiller()); return node; }
private List<String> getPackageNameForLocation(final String location) { final OnmsMonitoringLocation def = m_monitoringLocationDao.get(location); if (def == null) { throw new IllegalStateException("Location definition '" + location + "' could not be found"); } return def.getPollingPackageNames(); }
@Override public void execute(final List<VertexRef> targets, final OperationContext operationContext) { final VertexRef target = targets.get(0); final Vertex vertex = getVertexItem(operationContext, target); final Optional<OnmsNode> node = getNodeIfAvailable(vertex); final List<String> locations = monitoringLocationDao.findAll().stream().map(OnmsMonitoringLocation::getLocationName).collect(Collectors.toList()); final String defaultLocation = node.isPresent() ? node.get().getLocation().getLocationName() : MonitoringLocationDao.DEFAULT_MONITORING_LOCATION_ID; final List<String> ipAddresses = node.isPresent() ? Lists.newArrayList(node.get().getIpInterfaces()).stream().map(eachInterface -> InetAddressUtils.str(eachInterface.getIpAddress())).collect(Collectors.toList()) : Lists.newArrayList(vertex.getIpAddress()); final String defaultIp = getDefaultIp(vertex, node); final String caption = String.format("Ping - %s (%s)", vertex.getLabel(), vertex.getIpAddress()); new PingWindow(pingClient, locations, ipAddresses, defaultLocation, defaultIp, caption) .open(); }
/** {@inheritDoc} */ @Transactional @Override public OnmsNode getRequisitionedNode(final String foreignSource, final String foreignId) throws ForeignSourceRepositoryException { OnmsNodeRequisition nodeReq = null; try { nodeReq = m_foreignSourceRepository.getNodeRequisition(foreignSource, foreignId); } catch (ForeignSourceRepositoryException e) { // just fall through, nodeReq will be null } if (nodeReq == null) { LOG.warn("nodeReq for node {}:{} cannot be null!", foreignSource, foreignId); return null; } final OnmsNode node = nodeReq.constructOnmsNodeFromRequisition(); // fill in real database categories final HashSet<OnmsCategory> dbCategories = new HashSet<>(); for(final OnmsCategory category : node.getCategories()) { dbCategories.add(createCategoryIfNecessary(category.getName())); } node.setCategories(dbCategories); if (node.getLocation() == null || Strings.isNullOrEmpty(node.getLocation().getLocationName())) { node.setLocation(m_monitoringLocationDao.getDefaultLocation()); } // fill in real service types node.visit(new ServiceTypeFulfiller()); return node; }
@Override protected OnmsMonitoringLocation query() { return m_dao.get(location.getLocationName()); }
@Override public void execute(final List<VertexRef> targets, final OperationContext operationContext) { final VertexRef target = targets.get(0); final Vertex vertex = getVertexItem(operationContext, target); final Optional<OnmsNode> node = getNodeIfAvailable(vertex); final List<String> locations = monitoringLocationDao.findAll().stream().map(OnmsMonitoringLocation::getLocationName).collect(Collectors.toList()); final String defaultLocation = node.isPresent() ? node.get().getLocation().getLocationName() : MonitoringLocationDao.DEFAULT_MONITORING_LOCATION_ID; final List<String> ipAddresses = node.isPresent() ? Lists.newArrayList(node.get().getIpInterfaces()).stream().map(eachInterface -> InetAddressUtils.str(eachInterface.getIpAddress())).collect(Collectors.toList()) : Lists.newArrayList(vertex.getIpAddress()); final String defaultIp = getDefaultIp(vertex, node); final String caption = String.format("Ping - %s (%s)", vertex.getLabel(), vertex.getIpAddress()); new PingWindow(pingClient, locations, ipAddresses, defaultLocation, defaultIp, caption) .open(); }
@Before public void setUp() { // Async. m_eventMgr.setSynchronous(false); // Events need database IDs to make alarmd happy m_eventMgr.setEventWriter(m_database); // Events need to real nodes too OnmsNode node = new OnmsNode(m_locationDao.getDefaultLocation(), "node1"); node.setId(1); m_nodeDao.save(node); node = new OnmsNode(m_locationDao.getDefaultLocation(), "node2"); node.setId(2); m_nodeDao.save(node); node = new OnmsNode(m_locationDao.getDefaultLocation(), "node3"); node.setId(3); m_nodeDao.save(node); // Use a pseudo-clock m_droolsAlarmContext.setUsePseudoClock(true); // Drive the ticks ourselves m_droolsAlarmContext.setUseManualTick(true); // Set the behavior if (scenario.getLegacyAlarmBehavior()) { m_alarmPersister.setLegacyAlarmState(true); } // Start alarmd m_alarmd.start(); }