use of org.opennms.features.topology.netutils.internal.ping.PingWindow in project opennms by OpenNMS.
the class PingOperation method execute.
@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(eachLocation -> eachLocation.getLocationName()).collect(Collectors.toList());
final String defaultLocation = node.isPresent() ? node.get().getLocation().getLocationName() : MonitoringLocationDao.DEFAULT_MONITORING_LOCATION_ID;
final List<InetAddress> ipAddresses = node.isPresent() ? Lists.newArrayList(node.get().getIpInterfaces()).stream().map(eachInterface -> eachInterface.getIpAddress()).collect(Collectors.toList()) : Lists.newArrayList(InetAddressUtils.addr(vertex.getIpAddress()));
final InetAddress 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();
}
Aggregations