/** * 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; }
@Override protected OnmsNode query() { // Find all of the nodes in the target requisition with the given IP address return m_nodeDao.findByForeignSourceAndIpAddress(effectiveForeignSource, ipAddress).stream().filter(n -> { // Now filter the nodes by location final String existingLocationName = MonitoringLocationUtils.getLocationNameOrNullIfDefault(n); return Objects.equals(existingLocationName, effectiveLocationName); }).findFirst().orElse(null); }
@Override public ResourcePath getPath() { if (MonitoringLocationUtils.isDefaultLocationName(m_location)) { return ResourcePath.get(m_ipAddress); } else { return ResourcePath.get(ResourcePath.sanitize(m_location), m_ipAddress); } }
@Override protected OnmsNode query() { // Find all of the nodes in the target requisition with the given IP address return m_nodeDao.findByForeignSourceAndIpAddress(effectiveForeignSource, ipAddress).stream().filter(n -> { // Now filter the nodes by location final String existingLocationName = MonitoringLocationUtils.getLocationNameOrNullIfDefault(n); return Objects.equals(existingLocationName, effectiveLocationName); }).findFirst().orElse(null); }
/** * 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 List<OnmsResource> getResourcesForParent(OnmsResource parent, boolean stopAfterFirst) { if (!NodeResourceType.isNode(parent)) { return Collections.emptyList(); } // Grab the node entity final OnmsNode node = ResourceTypeUtils.getNodeFromResource(parent); // Determine the location name final String locationName = MonitoringLocationUtils.getLocationNameOrNullIfDefault(node); // Verify the existence of the individual interfaces final LinkedList<OnmsResource> resources = new LinkedList<>(); for (final OnmsIpInterface i : node.getIpInterfaces()) { String ipAddr = InetAddressUtils.str(i.getIpAddress()); final ResourcePath path = getInterfacePath(locationName, ipAddr); if (m_resourceStorageDao.exists(path, 0)) { resources.add(createResource(locationName, i, ipAddr, path)); if (stopAfterFirst) { break; } } } return resources; }
if (MonitoringLocationUtils.isDefaultLocationName(request.getLocation())) { request.setProviderRequest(providerRequest); } else {
@Override public CriticalPath getCriticalPath(int nodeId) { //"SELECT criticalpathip, criticalpathservicename FROM pathoutage WHERE nodeid=?"; String location = null; InetAddress pathIp = pathOutageConfig.getDefaultCriticalPathIp(); String serviceName = "ICMP"; final OnmsNode node = nodeDao.get(nodeId); if (node != null) { location = MonitoringLocationUtils.getLocationNameOrNullIfDefault(node); } final OnmsPathOutage out = pathOutageDao.get(nodeId); if (out != null) { if (out.getCriticalPathIp() != null) { pathIp = out.getCriticalPathIp(); } if (out.getCriticalPathServiceName() != null && !"".equals(out.getCriticalPathServiceName().trim())) { serviceName = out.getCriticalPathServiceName(); } } return new CriticalPath(location, pathIp, serviceName); }
public OnmsNode createUndiscoveredNode(final String ipAddress, final String foreignSource, final String locationString) { final String effectiveForeignSource = foreignSource == null ? FOREIGN_SOURCE_FOR_DISCOVERED_NODES : foreignSource; final String effectiveLocationName = MonitoringLocationUtils.isDefaultLocationName(locationString) ? null : locationString;
final SnmpAgentConfig agentConfig = SnmpPeerFactory.getInstance().getAgentConfig(m_address, MonitoringLocationUtils.getLocationNameOrNullIfDefault(node)); try { m_locationAwareSnmpClient.walk(agentConfig, tracker)
public OnmsNode createUndiscoveredNode(final String ipAddress, final String foreignSource, final String locationString) { final String effectiveForeignSource = foreignSource == null ? FOREIGN_SOURCE_FOR_DISCOVERED_NODES : foreignSource; final String effectiveLocationName = MonitoringLocationUtils.isDefaultLocationName(locationString) ? null : locationString;
final SnmpAgentConfig agentConfig = SnmpPeerFactory.getInstance().getAgentConfig(m_address, MonitoringLocationUtils.getLocationNameOrNullIfDefault(node)); try { m_locationAwareSnmpClient.walk(agentConfig, tracker)
if (MonitoringLocationUtils.isDefaultLocationName(request.getLocation())) {
@Override public OnmsResource getChildByName(OnmsResource parent, String ipAddress) { // Grab the node entity final OnmsNode node = ResourceTypeUtils.getNodeFromResource(parent); // Determine the location name final String locationName = MonitoringLocationUtils.getLocationNameOrNullIfDefault(node); // Grab the interface final OnmsIpInterface matchingIf = m_ipInterfaceDao.get(node, ipAddress); if (matchingIf == null) { throw new ObjectRetrievalFailureException(OnmsIpInterface.class, "No interface with ipAddr " + ipAddress + " could be found on node with id " + node.getId()); } // Verify the path final ResourcePath path = getInterfacePath(locationName, ipAddress); if (!m_resourceStorageDao.exists(path, 0)) { throw new ObjectRetrievalFailureException(OnmsResource.class, "No metrics found in parent path '" + parent.getPath() + "'"); } // Create the resource final OnmsResource resource = createResource(locationName, matchingIf, ipAddress, path); resource.setParent(parent); return resource; }
if (MonitoringLocationUtils.isDefaultLocationName(request.getLocation())) {