Adding a very simple output for pingall

Change-Id: I7575d4f6d1c45cdfaeb6a10d1bdc8371bcb25a29
(cherry picked from commit 134c3c051f1d8bdbaee66c4ffee7579e53ffc1f0)
diff --git a/src/main/java/org/onosproject/t3/api/StaticPacketTrace.java b/src/main/java/org/onosproject/t3/api/StaticPacketTrace.java
index 542dcfd..149cba7 100644
--- a/src/main/java/org/onosproject/t3/api/StaticPacketTrace.java
+++ b/src/main/java/org/onosproject/t3/api/StaticPacketTrace.java
@@ -43,6 +43,7 @@
     private Map<DeviceId, List<FlowEntry>> flowsForDevice;
     private StringBuilder resultMessage;
     private Pair<Host, Host> hosts;
+    private boolean success = false;
 
     /**
      * Builds the trace with a given packet and a connect point.
@@ -195,6 +196,23 @@
         hosts = endpointHosts;
     }
 
+    /**
+     * Return if this trace is successful.
+     * @return true if successful
+     */
+    public boolean isSuccess() {
+        return success;
+    }
+
+    /**
+     * Sets if this trace is successful.
+     * @param success true if trace is successful.
+     */
+    public void setSuccess(boolean success) {
+        this.success = success;
+    }
+
+
     @Override
     public String toString() {
         return "StaticPacketTrace{" +
diff --git a/src/main/java/org/onosproject/t3/api/TroubleshootService.java b/src/main/java/org/onosproject/t3/api/TroubleshootService.java
index 28ff728..ab7ff29 100644
--- a/src/main/java/org/onosproject/t3/api/TroubleshootService.java
+++ b/src/main/java/org/onosproject/t3/api/TroubleshootService.java
@@ -20,6 +20,7 @@
 import org.onosproject.net.ConnectPoint;
 import org.onosproject.net.HostId;
 import org.onosproject.net.flow.TrafficSelector;
+import org.onosproject.t3.impl.Generator;
 
 import java.util.List;
 import java.util.Set;
@@ -39,6 +40,14 @@
     List<StaticPacketTrace> pingAll(EthType.EtherType type);
 
     /**
+     * Requests a static trace be performed between all hosts in the network, given a type of traffic.
+     *
+     * @param type the etherType of the traffic we want to trace.
+     * @return a trace result
+     */
+    Generator<Set<StaticPacketTrace>> pingAllGenerator(EthType.EtherType type);
+
+    /**
      * Requests a static trace be performed between the two hosts in the network, given a type of traffic.
      *
      * @param sourceHost      source host
diff --git a/src/main/java/org/onosproject/t3/cli/TroubleshootPingAllCommand.java b/src/main/java/org/onosproject/t3/cli/TroubleshootPingAllCommand.java
new file mode 100644
index 0000000..f8648d0
--- /dev/null
+++ b/src/main/java/org/onosproject/t3/cli/TroubleshootPingAllCommand.java
@@ -0,0 +1,199 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.t3.cli;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.commands.Option;
+import org.onlab.packet.IpAddress;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.net.Host;
+import org.onosproject.net.flow.criteria.Criterion;
+import org.onosproject.net.flow.criteria.IPCriterion;
+import org.onosproject.t3.api.StaticPacketTrace;
+import org.onosproject.t3.api.TroubleshootService;
+import org.onosproject.t3.impl.Generator;
+
+import java.util.Set;
+
+import static java.lang.Thread.sleep;
+import static org.onlab.packet.EthType.EtherType;
+
+/**
+ * Starts a Static Packet Trace for a given input and prints the result.
+ */
+@Command(scope = "onos", name = "t3-troubleshoot-pingall",
+        description = "Traces a ping between all hosts in the system of a given ETH type")
+public class TroubleshootPingAllCommand extends AbstractShellCommand {
+
+    private static final String FMT_SHORT =
+            "id=%s, mac=%s, locations=%s, vlan=%s, ip(s)=%s";
+
+    @Option(name = "-et", aliases = "--ethType", description = "ETH Type", valueToShowInHelp = "ipv4")
+    String ethType = "ipv4";
+
+    @Option(name = "-v", aliases = "--verbose", description = "Outputs trace for each host to host combination")
+    private boolean verbosity1 = false;
+
+    @Option(name = "-vv", aliases = "--veryverbose", description = "Outputs details of every trace")
+    private boolean verbosity2 = false;
+
+    @Option(name = "-d", aliases = "--delay", description = "delay between host to host trace display")
+    private long delay = 0;
+
+    @Override
+    protected void execute() {
+        TroubleshootService service = get(TroubleshootService.class);
+
+        EtherType type = EtherType.valueOf(ethType.toUpperCase());
+
+        print("Tracing between all %s hosts", ethType);
+
+        if (!type.equals(EtherType.IPV4) && !type.equals(EtherType.IPV6)) {
+            print("Command only support IPv4 or IPv6");
+        } else {
+            //Create the generator for the list of traces.
+            Generator<Set<StaticPacketTrace>> generator = service.pingAllGenerator(type);
+            Host previousHost = null;
+            while (generator.iterator().hasNext()) {
+                Set<StaticPacketTrace> traces = generator.iterator().next();
+                for (StaticPacketTrace trace : traces) {
+                    boolean ipv4 = type.equals(EtherType.IPV4);
+                    //no verbosity is mininet style output
+                    if (!verbosity1 && !verbosity2) {
+                        if (trace.getEndpointHosts().isPresent()) {
+                            Host src = trace.getEndpointHosts().get().getLeft();
+                            if (previousHost == null || !previousHost.equals(src)) {
+                                print("%s", StringUtils.rightPad("", 125, '-'));
+                                IpAddress ipAddress = getIpAddress(trace, ipv4, src, true);
+                                if (ipAddress == null) {
+                                    print("%s", src.id() + " -->");
+                                } else {
+                                    print("%s (%s) -->", src.id(), ipAddress);
+                                }
+                                previousHost = src;
+                            } else {
+                                String host;
+                                IpAddress ipAddress = getIpAddress(trace, ipv4, src, false);
+                                if (ipAddress == null) {
+                                    host = String.format("       %s %s", trace.getEndpointHosts().get().getRight().id(),
+                                            trace.isSuccess());
+                                } else {
+                                    host = String.format("       %s (%s) %s",
+                                            trace.getEndpointHosts().get().getRight().id(), ipAddress,
+                                            trace.isSuccess());
+                                }
+                                if (!trace.isSuccess()) {
+                                    host = host + " " + trace.resultMessage();
+                                }
+                                print("%s", host);
+                            }
+                        }
+                    } else {
+                        print("%s", StringUtils.leftPad("", 125, '-'));
+
+                        if (trace.getInitialPacket() != null) {
+                            if (verbosity1) {
+                                printResultOnly(trace, ipv4);
+                            } else if (verbosity2) {
+                                printVerbose(trace);
+                            }
+                        } else {
+                            if (trace.getEndpointHosts().isPresent()) {
+                                Host source = trace.getEndpointHosts().get().getLeft();
+                                Host destination = trace.getEndpointHosts().get().getRight();
+                                print("Source %s --> Destination %s", source.id(), destination.id());
+                            }
+                            print("Error in obtaining trace: %s", trace.resultMessage());
+                        }
+                    }
+                }
+                try {
+                    sleep(delay);
+                } catch (InterruptedException e) {
+                    log.debug("interrupted while sleep");
+                }
+            }
+            print("%s", StringUtils.rightPad("", 125, '-'));
+        }
+    }
+
+    private IpAddress getIpAddress(StaticPacketTrace trace, boolean ipv4, Host host, boolean src) {
+        IpAddress ipAddress;
+        if (ipv4) {
+            Criterion.Type type = src ? Criterion.Type.IPV4_SRC : Criterion.Type.IPV4_DST;
+            if (trace.getInitialPacket().getCriterion(type) != null) {
+                ipAddress = ((IPCriterion) trace.getInitialPacket()
+                        .getCriterion(type)).ip().address();
+            } else {
+                ipAddress = host.ipAddresses().stream().filter(IpAddress::isIp4)
+                        .findAny().orElseGet(null);
+            }
+        } else {
+            Criterion.Type type = src ? Criterion.Type.IPV6_SRC : Criterion.Type.IPV6_DST;
+            if (trace.getInitialPacket().getCriterion(type) != null) {
+                ipAddress = ((IPCriterion) trace.getInitialPacket()
+                        .getCriterion(type)).ip().address();
+            } else {
+                ipAddress = host.ipAddresses().stream().filter(IpAddress::isIp6)
+                        .findAny().orElseGet(null);
+            }
+        }
+        return ipAddress;
+    }
+
+    private void printResultOnly(StaticPacketTrace trace, boolean ipv4) {
+        if (trace.getEndpointHosts().isPresent()) {
+            Host source = trace.getEndpointHosts().get().getLeft();
+            Host destination = trace.getEndpointHosts().get().getRight();
+            IpAddress srcIP;
+            IpAddress dstIP;
+            if (ipv4 && trace.getInitialPacket().getCriterion(Criterion.Type.IPV4_SRC) != null) {
+                srcIP = ((IPCriterion) trace.getInitialPacket().getCriterion(Criterion.Type.IPV4_SRC)).ip().address();
+                dstIP = ((IPCriterion) trace.getInitialPacket().getCriterion(Criterion.Type.IPV4_DST)).ip().address();
+                print("Source %s (%s) --> Destination %s (%s)", source.id(), srcIP, destination.id(), dstIP);
+            } else if (trace.getInitialPacket().getCriterion(Criterion.Type.IPV6_SRC) != null) {
+                srcIP = ((IPCriterion) trace.getInitialPacket().getCriterion(Criterion.Type.IPV6_SRC)).ip().address();
+                dstIP = ((IPCriterion) trace.getInitialPacket().getCriterion(Criterion.Type.IPV6_DST)).ip().address();
+                print("Source %s (%s) --> Destination %s (%s)", source.id(), srcIP, destination.id(), dstIP);
+            } else {
+                print("Source %s --> Destination %s", source.id(), destination.id());
+            }
+            print("%s", trace.resultMessage());
+        } else {
+            print("Can't gather host information from trace");
+            print("%s", trace.resultMessage());
+        }
+    }
+
+    private void printVerbose(StaticPacketTrace trace) {
+        if (trace.getEndpointHosts().isPresent()) {
+            Host source = trace.getEndpointHosts().get().getLeft();
+            print("Source host %s", printHost(source));
+            Host destination = trace.getEndpointHosts().get().getRight();
+            print("Destination host %s", printHost(destination));
+        }
+        print("%s", trace.getInitialPacket());
+        print("%s", T3CliUtils.printTrace(trace, false, false));
+    }
+
+    private String printHost(Host host) {
+        return String.format(FMT_SHORT, host.id(), host.mac(),
+                host.locations(),
+                host.vlan(), host.ipAddresses());
+    }
+}
diff --git a/src/main/java/org/onosproject/t3/cli/TroubleshootPingAllTraceCommand.java b/src/main/java/org/onosproject/t3/cli/TroubleshootPingAllTraceCommand.java
deleted file mode 100644
index d2dba49..0000000
--- a/src/main/java/org/onosproject/t3/cli/TroubleshootPingAllTraceCommand.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright 2018-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.t3.cli;
-
-import org.apache.commons.lang.StringUtils;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.onlab.packet.IpAddress;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.Host;
-import org.onosproject.net.flow.criteria.Criterion;
-import org.onosproject.net.flow.criteria.IPCriterion;
-import org.onosproject.t3.api.StaticPacketTrace;
-import org.onosproject.t3.api.TroubleshootService;
-
-import java.util.List;
-
-import static org.onlab.packet.EthType.EtherType;
-
-/**
- * Starts a Static Packet Trace for a given input and prints the result.
- */
-@Command(scope = "onos", name = "t3-troubleshoot-pingall",
-        description = "Traces a ping between all hosts in the system of a given ETH type")
-public class TroubleshootPingAllTraceCommand extends AbstractShellCommand {
-
-    private static final String FMT_SHORT =
-            "id=%s, mac=%s, locations=%s, vlan=%s, ip(s)=%s";
-
-    @Option(name = "-et", aliases = "--ethType", description = "ETH Type", valueToShowInHelp = "ipv4")
-    String ethType = "ipv4";
-
-    @Option(name = "-v", aliases = "--verbose", description = "Outputs trace for each host to host combination")
-    private boolean verbosity1 = false;
-
-    @Override
-    protected void execute() {
-        TroubleshootService service = get(TroubleshootService.class);
-
-        EtherType type = EtherType.valueOf(ethType.toUpperCase());
-
-        print("Tracing between all %s hosts", ethType);
-
-        if (!type.equals(EtherType.IPV4) && !type.equals(EtherType.IPV6)) {
-            print("Command only support IPv4 or IPv6");
-        } else {
-            print("%s", StringUtils.leftPad("", 100, '-'));
-            //Obtain the list of traces
-            List<StaticPacketTrace> traces = service.pingAll(type);
-
-            if (traces.size() == 0) {
-                print("No traces were obtained, please check system configuration");
-            }
-            boolean ipv4 = type.equals(EtherType.IPV4);
-            traces.forEach(trace -> {
-                if (trace.getInitialPacket() != null) {
-                    if (verbosity1) {
-                        printVerbose(trace);
-                    } else {
-                        printResultOnly(trace, ipv4);
-                    }
-                } else {
-                    if (trace.getEndpointHosts().isPresent()) {
-                        Host source = trace.getEndpointHosts().get().getLeft();
-                        Host destination = trace.getEndpointHosts().get().getRight();
-                        print("Source %s --> Destination %s", source.id(), destination.id());
-                    }
-                    print("Error in obtaining trace: %s", trace.resultMessage());
-                }
-                print("%s", StringUtils.leftPad("", 100, '-'));
-            });
-        }
-
-
-    }
-
-    private void printResultOnly(StaticPacketTrace trace, boolean ipv4) {
-        if (trace.getEndpointHosts().isPresent()) {
-            Host source = trace.getEndpointHosts().get().getLeft();
-            Host destination = trace.getEndpointHosts().get().getRight();
-            IpAddress srcIP;
-            IpAddress dstIP;
-            if (ipv4 && trace.getInitialPacket().getCriterion(Criterion.Type.IPV4_SRC) != null) {
-                srcIP = ((IPCriterion) trace.getInitialPacket().getCriterion(Criterion.Type.IPV4_SRC)).ip().address();
-                dstIP = ((IPCriterion) trace.getInitialPacket().getCriterion(Criterion.Type.IPV4_DST)).ip().address();
-                print("Source %s (%s) --> Destination %s (%s)", source.id(), srcIP, destination.id(), dstIP);
-            } else if (trace.getInitialPacket().getCriterion(Criterion.Type.IPV6_SRC) != null) {
-                srcIP = ((IPCriterion) trace.getInitialPacket().getCriterion(Criterion.Type.IPV6_SRC)).ip().address();
-                dstIP = ((IPCriterion) trace.getInitialPacket().getCriterion(Criterion.Type.IPV6_DST)).ip().address();
-                print("Source %s (%s) --> Destination %s (%s)", source.id(), srcIP, destination.id(), dstIP);
-            } else {
-                print("Source %s --> Destination %s", source.id(), destination.id());
-            }
-            print("%s", trace.resultMessage());
-        } else {
-            print("Can't gather host information from trace");
-            print("%s", trace.resultMessage());
-        }
-    }
-
-    private void printVerbose(StaticPacketTrace trace) {
-        if (trace.getEndpointHosts().isPresent()) {
-            Host source = trace.getEndpointHosts().get().getLeft();
-            print("Source host %s", printHost(source));
-            Host destination = trace.getEndpointHosts().get().getRight();
-            print("Destination host %s", printHost(destination));
-        }
-        print("%s", trace.getInitialPacket());
-        print("%s", T3CliUtils.printTrace(trace, false, false));
-    }
-
-    private String printHost(Host host) {
-        return String.format(FMT_SHORT, host.id(), host.mac(),
-                host.locations(),
-                host.vlan(), host.ipAddresses());
-    }
-}
diff --git a/src/main/java/org/onosproject/t3/impl/Generator.java b/src/main/java/org/onosproject/t3/impl/Generator.java
new file mode 100644
index 0000000..1f6bf22
--- /dev/null
+++ b/src/main/java/org/onosproject/t3/impl/Generator.java
@@ -0,0 +1,141 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.t3.impl;
+
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+/**
+ * Generator class that yields instances of T type objects as soon as they are ready.
+ *
+ * @param <T> type of the object.
+ */
+public abstract class Generator<T> implements Iterable<T> {
+
+    private class Condition {
+        private boolean isSet;
+
+        synchronized void set() {
+            isSet = true;
+            notify();
+        }
+
+        synchronized void await() throws InterruptedException {
+            try {
+                if (isSet) {
+                    return;
+                }
+                wait();
+            } finally {
+                isSet = false;
+            }
+        }
+    }
+
+    private static ThreadGroup threadGroup;
+
+    private Thread producer;
+    private boolean hasFinished;
+    private final Condition itemAvailableOrHasFinished = new Condition();
+    private final Condition itemRequested = new Condition();
+    private T nextItem;
+    private boolean nextItemAvailable;
+    private RuntimeException exceptionRaisedByProducer;
+
+    @Override
+    public Iterator<T> iterator() {
+        return new Iterator<T>() {
+            @Override
+            public boolean hasNext() {
+                return waitForNext();
+            }
+
+            @Override
+            public T next() {
+                if (!waitForNext()) {
+                    throw new NoSuchElementException();
+                }
+                nextItemAvailable = false;
+                return nextItem;
+            }
+
+            @Override
+            public void remove() {
+                throw new UnsupportedOperationException();
+            }
+
+            private boolean waitForNext() {
+                if (nextItemAvailable) {
+                    return true;
+                }
+                if (hasFinished) {
+                    return false;
+                }
+                if (producer == null) {
+                    startProducer();
+                }
+                itemRequested.set();
+                try {
+                    itemAvailableOrHasFinished.await();
+                } catch (InterruptedException e) {
+                    hasFinished = true;
+                }
+                if (exceptionRaisedByProducer != null) {
+                    throw exceptionRaisedByProducer;
+                }
+                return !hasFinished;
+            }
+        };
+    }
+
+    protected abstract void run() throws InterruptedException;
+
+    void yield(T element) throws InterruptedException {
+        nextItem = element;
+        nextItemAvailable = true;
+        itemAvailableOrHasFinished.set();
+        itemRequested.await();
+    }
+
+    private void startProducer() {
+        assert producer == null;
+        if (threadGroup == null) {
+            threadGroup = new ThreadGroup("onos-t3-generator");
+        }
+        producer = new Thread(threadGroup, () -> {
+            try {
+                itemRequested.await();
+                Generator.this.run();
+            } catch (InterruptedException e) {
+                // Remaining steps in run() will shut down thread.
+            } catch (RuntimeException e) {
+                exceptionRaisedByProducer = e;
+            }
+            hasFinished = true;
+            itemAvailableOrHasFinished.set();
+        });
+        producer.setDaemon(true);
+        producer.start();
+    }
+
+    @Override
+    protected void finalize() throws Throwable {
+        producer.interrupt();
+        producer.join();
+        super.finalize();
+    }
+}
\ No newline at end of file
diff --git a/src/main/java/org/onosproject/t3/impl/PingAllGenerator.java b/src/main/java/org/onosproject/t3/impl/PingAllGenerator.java
new file mode 100644
index 0000000..bf4d4b4
--- /dev/null
+++ b/src/main/java/org/onosproject/t3/impl/PingAllGenerator.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.t3.impl;
+
+import com.google.common.collect.Sets;
+import org.onlab.packet.EthType;
+import org.onlab.packet.IpAddress;
+import org.onosproject.net.host.HostService;
+import org.onosproject.t3.api.StaticPacketTrace;
+import org.slf4j.Logger;
+
+import java.util.List;
+import java.util.Set;
+
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * Implementation of the generator class that yields a set of Packet Traces.
+ */
+public class PingAllGenerator extends Generator<Set<StaticPacketTrace>> {
+
+    private static final Logger log = getLogger(PingAllGenerator.class);
+
+    private final EthType.EtherType etherType;
+    private final HostService hostService;
+    private final TroubleshootManager manager;
+
+    /**
+     * Creates a generator for obtaining traces of pings between all the hosts in the network.
+     *
+     * @param etherType the type of traffic we are tracing.
+     * @param service   the host service
+     * @param manager   the troubleshoot manager issuing the request.
+     */
+    PingAllGenerator(EthType.EtherType etherType, HostService service, TroubleshootManager manager) {
+        this.etherType = etherType;
+        this.hostService = service;
+        this.manager = manager;
+    }
+
+    @Override
+    protected void run() throws InterruptedException {
+        hostService.getHosts().forEach(host -> {
+            List<IpAddress> ipAddresses = manager.getIpAddresses(host, etherType, false);
+            if (ipAddresses.size() > 0) {
+                //check if the host has only local IPs of that ETH type
+                boolean onlyLocalSrc = ipAddresses.size() == 1 && ipAddresses.get(0).isLinkLocal();
+                hostService.getHosts().forEach(hostToPing -> {
+                    List<IpAddress> ipAddressesToPing = manager.getIpAddresses(hostToPing, etherType, false);
+                    //check if the other host has only local IPs of that ETH type
+                    boolean onlyLocalDst = ipAddressesToPing.size() == 1 && ipAddressesToPing.get(0).isLinkLocal();
+                    boolean sameLocation = Sets.intersection(host.locations(), hostToPing.locations()).size() > 0;
+                    //Trace is done only if they are both local and under the same location
+                    // or not local and if they are not the same host.
+                    if (((sameLocation && onlyLocalDst && onlyLocalSrc) ||
+                            (!onlyLocalSrc && !onlyLocalDst && ipAddressesToPing.size() > 0))
+                            && !host.equals(hostToPing)) {
+                        try {
+                            yield(manager.trace(host.id(), hostToPing.id(), etherType));
+                        } catch (InterruptedException e) {
+                            log.warn("Interrupted generator", e.getMessage());
+                            log.debug("exception", e);
+                        }
+                    }
+                });
+            }
+        });
+
+    }
+}
diff --git a/src/main/java/org/onosproject/t3/impl/TroubleshootManager.java b/src/main/java/org/onosproject/t3/impl/TroubleshootManager.java
index 0f21f06..7805893 100644
--- a/src/main/java/org/onosproject/t3/impl/TroubleshootManager.java
+++ b/src/main/java/org/onosproject/t3/impl/TroubleshootManager.java
@@ -160,6 +160,11 @@
     }
 
     @Override
+    public Generator<Set<StaticPacketTrace>> pingAllGenerator(EtherType type) {
+        return new PingAllGenerator(type, hostService, this);
+    }
+
+    @Override
     public Set<StaticPacketTrace> trace(HostId sourceHost, HostId destinationHost, EtherType etherType) {
         Host source = hostService.getHost(sourceHost);
         Host destination = hostService.getHost(destinationHost);
@@ -275,7 +280,7 @@
         return true;
     }
 
-    private List<IpAddress> getIpAddresses(Host host, EtherType etherType, boolean checklocal) {
+    List<IpAddress> getIpAddresses(Host host, EtherType etherType, boolean checklocal) {
         return host.ipAddresses().stream().filter(ipAddress -> {
             boolean correctIp = false;
             if (etherType.equals(EtherType.IPV4)) {
@@ -398,6 +403,7 @@
                 log.debug("Stopping here because host is expected destination {}, reached through", completePath);
                 if (computePath(completePath, trace, outputPath.getOutput())) {
                     trace.addResultMessage("Reached required destination Host " + cp);
+                    trace.setSuccess(true);
                 }
                 break;
             } else if (cp.port().equals(PortNumber.CONTROLLER)) {
@@ -457,6 +463,7 @@
                             .mac().isMulticast()) {
                 trace.addResultMessage("Packet is multicast and reached output " + outputPath.getOutput() +
                         " which is enabled and is edge port");
+                trace.setSuccess(true);
                 computePath(completePath, trace, outputPath.getOutput());
                 completePath.clear();
                 if (!hasOtherOutput(in.deviceId(), trace, outputPath.getOutput())) {
@@ -477,6 +484,7 @@
                                 .getCriterion(Criterion.Type.ETH_TYPE)).ethType() + " and reached " +
                                 cp + " with hosts " + hostsList);
                     }
+                    trace.setSuccess(true);
                     computePath(completePath, trace, outputPath.getOutput());
                 }