private boolean hasValidIpAddress(Vertex vertexItem) { // Only enable if we actually have something to ping // Be aware that originally the ip address was also resolved via InetAddressUtils.getInetAddress(ipAddress) // but in cases were the ipAddress is not reachable, the response thread would block and causing // the ui to build the menubar very slowly. Therefore this was changed. See NMS-10452 return !Strings.isNullOrEmpty(vertexItem.getIpAddress()); }
private boolean hasValidIpAddress(Vertex vertexItem) { // Only enable if we actually have something to ping // Be aware that originally the ip address was also resolved via InetAddressUtils.getInetAddress(ipAddress) // but in cases were the ipAddress is not reachable, the response thread would block and causing // the ui to build the menubar very slowly. Therefore this was changed. See NMS-10452 return !Strings.isNullOrEmpty(vertexItem.getIpAddress()); }
protected static String getIpAddrValue(final OperationContext operationContext, final VertexRef target) { Vertex vertex = getVertexItem(operationContext, target); return vertex == null ? null : vertex.getIpAddress(); }
protected static String getIpAddrValue(final OperationContext operationContext, final VertexRef target) { Vertex vertex = getVertexItem(operationContext, target); return vertex == null ? null : vertex.getIpAddress(); }
protected static String getIpAddrValue(final OperationContext operationContext, final VertexRef target) { Vertex vertex = getVertexItem(operationContext, target); return vertex == null ? null : vertex.getIpAddress(); }
@Override public boolean enabled(List<VertexRef> targets, OperationContext operationContext) { if (targets.size() == 1) { // Only enable if we actually have something to ping String ipAddress = getVertexItem(operationContext, targets.get(0)).getIpAddress(); if (!Strings.isNullOrEmpty(ipAddress)) { try { InetAddressUtils.getInetAddress(ipAddress); return true; } catch (IllegalArgumentException ex) { return false; } } } return false; }
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."); }
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 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(); }
@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(); }
protected WrappedVertex(Vertex vertex) { this((VertexRef)vertex); iconKey = vertex.getIconKey(); ipAddr = vertex.getIpAddress(); nodeID = vertex.getNodeID(); if (vertex.getParent() != null) parent = new WrappedVertex(vertex.getParent()); styleName = vertex.getStyleName(); tooltipText = vertex.getTooltipText(); x = vertex.getX(); y = vertex.getY(); group = vertex.isGroup(); locked = vertex.isLocked(); selected = vertex.isSelected(); }
pingForm = new PingForm(InetAddressUtils.getInetAddress(vertex.getIpAddress())); setCaption(String.format("Ping - %s (%s)", vertex.getLabel(), vertex.getIpAddress())); setResizable(false); setModal(true);