Search in sources :

Example 1 with PingWindow

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();
}
Also used : NodeDao(org.opennms.netmgt.dao.api.NodeDao) InetAddressUtils(org.opennms.core.utils.InetAddressUtils) Vertex(org.opennms.features.topology.api.topo.Vertex) Collectors(java.util.stream.Collectors) InetAddress(java.net.InetAddress) Objects(java.util.Objects) AbstractOperation(org.opennms.features.topology.api.AbstractOperation) Strings(com.google.common.base.Strings) List(java.util.List) LocationAwarePingClient(org.opennms.netmgt.icmp.proxy.LocationAwarePingClient) Lists(com.google.common.collect.Lists) OperationContext(org.opennms.features.topology.api.OperationContext) MonitoringLocationDao(org.opennms.netmgt.dao.api.MonitoringLocationDao) Optional(java.util.Optional) PingWindow(org.opennms.features.topology.netutils.internal.ping.PingWindow) VertexRef(org.opennms.features.topology.api.topo.VertexRef) OnmsNode(org.opennms.netmgt.model.OnmsNode) Vertex(org.opennms.features.topology.api.topo.Vertex) OnmsNode(org.opennms.netmgt.model.OnmsNode) PingWindow(org.opennms.features.topology.netutils.internal.ping.PingWindow) VertexRef(org.opennms.features.topology.api.topo.VertexRef) InetAddress(java.net.InetAddress)

Aggregations

Strings (com.google.common.base.Strings)1 Lists (com.google.common.collect.Lists)1 InetAddress (java.net.InetAddress)1 List (java.util.List)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 InetAddressUtils (org.opennms.core.utils.InetAddressUtils)1 AbstractOperation (org.opennms.features.topology.api.AbstractOperation)1 OperationContext (org.opennms.features.topology.api.OperationContext)1 Vertex (org.opennms.features.topology.api.topo.Vertex)1 VertexRef (org.opennms.features.topology.api.topo.VertexRef)1 PingWindow (org.opennms.features.topology.netutils.internal.ping.PingWindow)1 MonitoringLocationDao (org.opennms.netmgt.dao.api.MonitoringLocationDao)1 NodeDao (org.opennms.netmgt.dao.api.NodeDao)1 LocationAwarePingClient (org.opennms.netmgt.icmp.proxy.LocationAwarePingClient)1 OnmsNode (org.opennms.netmgt.model.OnmsNode)1