Starting to experiment with flow tracking.
diff --git a/core/api/src/main/java/org/onlab/onos/net/LinkKey.java b/core/api/src/main/java/org/onlab/onos/net/LinkKey.java
index dee4e88..d3ff0f4 100644
--- a/core/api/src/main/java/org/onlab/onos/net/LinkKey.java
+++ b/core/api/src/main/java/org/onlab/onos/net/LinkKey.java
@@ -6,6 +6,7 @@
 
 // TODO Consider renaming.
 // it's an identifier for a Link, but it's not ElementId, so not using LinkId.
+
 /**
  * Immutable representation of a link identity.
  */
@@ -43,6 +44,15 @@
         this.dst = dst;
     }
 
+    /**
+     * Creates a link identifier for the specified link.
+     *
+     * @param link link descriptor
+     */
+    public LinkKey(Link link) {
+        this(link.src(), link.dst());
+    }
+
     @Override
     public int hashCode() {
         return Objects.hash(src(), dst);
diff --git a/core/api/src/main/java/org/onlab/onos/net/intent/InstallableIntent.java b/core/api/src/main/java/org/onlab/onos/net/intent/InstallableIntent.java
index 66bc759..488695c 100644
--- a/core/api/src/main/java/org/onlab/onos/net/intent/InstallableIntent.java
+++ b/core/api/src/main/java/org/onlab/onos/net/intent/InstallableIntent.java
@@ -1,8 +1,22 @@
 package org.onlab.onos.net.intent;
 
+import org.onlab.onos.net.Link;
+
+import java.util.Collection;
+
 /**
  * Abstraction of an intent that can be installed into
  * the underlying system without additional compilation.
  */
 public interface InstallableIntent extends Intent {
+
+    /**
+     * Returns the collection of links that are required for this installable
+     * intent to exist.
+     *
+     * @return collection of links
+     */
+    // FIXME: replace this with 'NetworkResource'
+    Collection<Link> requiredLinks();
+
 }
diff --git a/core/api/src/main/java/org/onlab/onos/net/intent/PathIntent.java b/core/api/src/main/java/org/onlab/onos/net/intent/PathIntent.java
index 6809ce2..4c3486f 100644
--- a/core/api/src/main/java/org/onlab/onos/net/intent/PathIntent.java
+++ b/core/api/src/main/java/org/onlab/onos/net/intent/PathIntent.java
@@ -1,13 +1,14 @@
 package org.onlab.onos.net.intent;
 
-import java.util.Objects;
-
+import com.google.common.base.MoreObjects;
 import org.onlab.onos.net.ConnectPoint;
+import org.onlab.onos.net.Link;
 import org.onlab.onos.net.Path;
 import org.onlab.onos.net.flow.TrafficSelector;
 import org.onlab.onos.net.flow.TrafficTreatment;
 
-import com.google.common.base.MoreObjects;
+import java.util.Collection;
+import java.util.Objects;
 
 /**
  * Abstraction of explicitly path specified connectivity intent.
@@ -86,4 +87,10 @@
                 .add("path", path)
                 .toString();
     }
+
+    @Override
+    public Collection<Link> requiredLinks() {
+        return path.links();
+    }
+
 }
diff --git a/core/api/src/main/java/org/onlab/onos/net/topology/TopologyEvent.java b/core/api/src/main/java/org/onlab/onos/net/topology/TopologyEvent.java
index 0be5323..268b6ac 100644
--- a/core/api/src/main/java/org/onlab/onos/net/topology/TopologyEvent.java
+++ b/core/api/src/main/java/org/onlab/onos/net/topology/TopologyEvent.java
@@ -1,12 +1,17 @@
 package org.onlab.onos.net.topology;
 
 import org.onlab.onos.event.AbstractEvent;
+import org.onlab.onos.event.Event;
+
+import java.util.List;
 
 /**
  * Describes network topology event.
  */
 public class TopologyEvent extends AbstractEvent<TopologyEvent.Type, Topology> {
 
+    private final List<Event> reasons;
+
     /**
      * Type of topology events.
      */
@@ -23,9 +28,11 @@
      *
      * @param type     topology event type
      * @param topology event topology subject
+     * @param reasons  list of events that triggered topology change
      */
-    public TopologyEvent(Type type, Topology topology) {
+    public TopologyEvent(Type type, Topology topology, List<Event> reasons) {
         super(type, topology);
+        this.reasons = reasons;
     }
 
     /**
@@ -33,10 +40,24 @@
      *
      * @param type     link event type
      * @param topology event topology subject
+     * @param reasons  list of events that triggered topology change
      * @param time     occurrence time
      */
-    public TopologyEvent(Type type, Topology topology, long time) {
+    public TopologyEvent(Type type, Topology topology, List<Event> reasons,
+                         long time) {
         super(type, topology, time);
+        this.reasons = reasons;
+    }
+
+
+    /**
+     * Returns the list of events that triggered the topology change.
+     *
+     * @return list of events responsible for change in topology; null if
+     * initial topology computation
+     */
+    public List<Event> reasons() {
+        return reasons;
     }
 
 }
diff --git a/core/api/src/test/java/org/onlab/onos/net/intent/TestInstallableIntent.java b/core/api/src/test/java/org/onlab/onos/net/intent/TestInstallableIntent.java
index a6ce52e..3265925 100644
--- a/core/api/src/test/java/org/onlab/onos/net/intent/TestInstallableIntent.java
+++ b/core/api/src/test/java/org/onlab/onos/net/intent/TestInstallableIntent.java
@@ -1,6 +1,10 @@
 package org.onlab.onos.net.intent;
 //TODO is this the right package?
 
+import org.onlab.onos.net.Link;
+
+import java.util.Collection;
+
 /**
  * An installable intent used in the unit test.
  *
@@ -25,4 +29,8 @@
         super();
     }
 
+    @Override
+    public Collection<Link> requiredLinks() {
+        return null;
+    }
 }
diff --git a/core/net/src/main/java/org/onlab/onos/net/intent/impl/FlowTracker.java b/core/net/src/main/java/org/onlab/onos/net/intent/impl/FlowTracker.java
new file mode 100644
index 0000000..8f4a5c7
--- /dev/null
+++ b/core/net/src/main/java/org/onlab/onos/net/intent/impl/FlowTracker.java
@@ -0,0 +1,130 @@
+package org.onlab.onos.net.intent.impl;
+
+import com.google.common.collect.HashMultimap;
+import com.google.common.collect.SetMultimap;
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Deactivate;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.apache.felix.scr.annotations.Service;
+import org.onlab.onos.event.Event;
+import org.onlab.onos.net.Link;
+import org.onlab.onos.net.LinkKey;
+import org.onlab.onos.net.intent.IntentId;
+import org.onlab.onos.net.link.LinkEvent;
+import org.onlab.onos.net.topology.TopologyEvent;
+import org.onlab.onos.net.topology.TopologyListener;
+import org.onlab.onos.net.topology.TopologyService;
+import org.slf4j.Logger;
+
+import java.util.Collection;
+import java.util.concurrent.ExecutorService;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.collect.Multimaps.synchronizedSetMultimap;
+import static java.util.concurrent.Executors.newSingleThreadExecutor;
+import static org.onlab.util.Tools.namedThreads;
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * Entity responsible for tracking installed flows and for monitoring topology
+ * events to determine what flows are affected by topology changes.
+ */
+@Component
+@Service
+public class FlowTracker implements FlowTrackerService {
+
+    private final Logger log = getLogger(getClass());
+
+    private final SetMultimap<LinkKey, IntentId> intentsByLink =
+            synchronizedSetMultimap(HashMultimap.<LinkKey, IntentId>create());
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected TopologyService topologyService;
+
+    private ExecutorService executorService =
+            newSingleThreadExecutor(namedThreads("onos-flowtracker"));
+
+    private TopologyListener listener = new InternalTopologyListener();
+    private TopologyChangeDelegate delegate;
+
+    @Activate
+    public void activate() {
+        topologyService.addListener(listener);
+        log.info("Started");
+    }
+
+    @Deactivate
+    public void deactivate() {
+        topologyService.removeListener(listener);
+        log.info("Stopped");
+    }
+
+    @Override
+    public void setDelegate(TopologyChangeDelegate delegate) {
+        checkNotNull(delegate, "Delegate cannot be null");
+        checkArgument(this.delegate == null || this.delegate == delegate,
+                      "Another delegate already set");
+        this.delegate = delegate;
+    }
+
+    @Override
+    public void unsetDelegate(TopologyChangeDelegate delegate) {
+        checkArgument(this.delegate == delegate, "Not the current delegate");
+        this.delegate = null;
+    }
+
+    @Override
+    public void addTrackedResources(IntentId intentId, Collection<Link> resources) {
+        for (Link link : resources) {
+            intentsByLink.put(new LinkKey(link), intentId);
+        }
+    }
+
+    @Override
+    public void removeTrackedResources(IntentId intentId, Collection<Link> resources) {
+        for (Link link : resources) {
+            intentsByLink.remove(new LinkKey(link), intentId);
+        }
+    }
+
+    // Internal re-actor to topology change events.
+    private class InternalTopologyListener implements TopologyListener {
+        @Override
+        public void event(TopologyEvent event) {
+            executorService.execute(new TopologyChangeHandler(event));
+        }
+    }
+
+    // Re-dispatcher of topology change events.
+    private class TopologyChangeHandler implements Runnable {
+
+        private final TopologyEvent event;
+
+        TopologyChangeHandler(TopologyEvent event) {
+            this.event = event;
+        }
+
+        @Override
+        public void run() {
+            if (event.reasons() == null) {
+                delegate.bumpIntents(intentsByLink.values());
+            } else {
+                for (Event reason : event.reasons()) {
+                    if (reason instanceof LinkEvent) {
+                        LinkEvent linkEvent = (LinkEvent) reason;
+                        if (linkEvent.type() == LinkEvent.Type.LINK_ADDED ||
+                                linkEvent.type() == LinkEvent.Type.LINK_UPDATED) {
+                            delegate.bumpIntents(intentsByLink.get(new LinkKey(linkEvent.subject())));
+                        } else if (linkEvent.type() == LinkEvent.Type.LINK_REMOVED) {
+                            delegate.failIntents(intentsByLink.get(new LinkKey(linkEvent.subject())));
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+}
diff --git a/core/net/src/main/java/org/onlab/onos/net/intent/impl/FlowTrackerService.java b/core/net/src/main/java/org/onlab/onos/net/intent/impl/FlowTrackerService.java
new file mode 100644
index 0000000..b96de7c
--- /dev/null
+++ b/core/net/src/main/java/org/onlab/onos/net/intent/impl/FlowTrackerService.java
@@ -0,0 +1,44 @@
+package org.onlab.onos.net.intent.impl;
+
+import org.onlab.onos.net.Link;
+import org.onlab.onos.net.intent.IntentId;
+
+import java.util.Collection;
+
+/**
+ * Auxiliary service for tracking intent path flows and for notifying the
+ * intent service of environment changes via topology change delegate.
+ */
+public interface FlowTrackerService {
+
+    /**
+     * Sets a topology change delegate.
+     *
+     * @param delegate topology change delegate
+     */
+    void setDelegate(TopologyChangeDelegate delegate);
+
+    /**
+     * Unsets topology change delegate.
+     *
+     * @param delegate topology change delegate
+     */
+    void unsetDelegate(TopologyChangeDelegate delegate);
+
+    /**
+     * Adds a path flow to be tracked.
+     *
+     * @param intentId intent identity on whose behalf the path is being tracked
+     * @param resources resources to track
+     */
+    public void addTrackedResources(IntentId intentId, Collection<Link> resources);
+
+    /**
+     * Removes a path flow to be tracked.
+     *
+     * @param intentId intent identity on whose behalf the path is being tracked
+     * @param resources resources to stop tracking
+     */
+    public void removeTrackedResources(IntentId intentId, Collection<Link> resources);
+
+}
diff --git a/core/net/src/main/java/org/onlab/onos/net/intent/impl/IntentManager.java b/core/net/src/main/java/org/onlab/onos/net/intent/impl/IntentManager.java
index 769e4c7..ebcb789 100644
--- a/core/net/src/main/java/org/onlab/onos/net/intent/impl/IntentManager.java
+++ b/core/net/src/main/java/org/onlab/onos/net/intent/impl/IntentManager.java
@@ -1,19 +1,6 @@
 package org.onlab.onos.net.intent.impl;
 
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.onlab.onos.net.intent.IntentState.FAILED;
-import static org.onlab.onos.net.intent.IntentState.INSTALLED;
-import static org.onlab.onos.net.intent.IntentState.WITHDRAWING;
-import static org.onlab.onos.net.intent.IntentState.WITHDRAWN;
-import static org.slf4j.LoggerFactory.getLogger;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.CopyOnWriteArrayList;
-
+import com.google.common.collect.ImmutableMap;
 import org.apache.felix.scr.annotations.Activate;
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.Deactivate;
@@ -38,7 +25,15 @@
 import org.onlab.onos.net.intent.IntentStoreDelegate;
 import org.slf4j.Logger;
 
-import com.google.common.collect.ImmutableMap;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.onlab.onos.net.intent.IntentState.*;
+import static org.slf4j.LoggerFactory.getLogger;
 
 /**
  * An implementation of Intent Manager.
@@ -57,37 +52,34 @@
             IntentCompiler<? extends Intent>> compilers = new ConcurrentHashMap<>();
     private final ConcurrentMap<Class<? extends InstallableIntent>,
             IntentInstaller<? extends InstallableIntent>> installers = new ConcurrentHashMap<>();
-    private final CopyOnWriteArrayList<IntentListener> listeners = new CopyOnWriteArrayList<>();
 
     private final AbstractListenerRegistry<IntentEvent, IntentListener>
-        listenerRegistry = new AbstractListenerRegistry<>();
+            listenerRegistry = new AbstractListenerRegistry<>();
 
     private final IntentStoreDelegate delegate = new InternalStoreDelegate();
+    private final TopologyChangeDelegate topoDelegate = new InternalTopoChangeDelegate();
 
     @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
     protected IntentStore store;
 
     @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected FlowTrackerService trackerService;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
     protected EventDeliveryService eventDispatcher;
 
     @Activate
     public void activate() {
         store.setDelegate(delegate);
+        trackerService.setDelegate(topoDelegate);
         eventDispatcher.addSink(IntentEvent.class, listenerRegistry);
-
-//        this.intentEvents = new IntentMap<>("intentState", IntentEvent.class, collectionsService);
-//        this.installableIntents =
-//                new IntentMap<>("installableIntents", IntentCompilationResult.class, collectionsService);
-//
-//
-//        this.intentEvents.addListener(new InternalEntryListener(new InternalIntentEventListener()));
-
         log.info("Started");
     }
 
     @Deactivate
     public void deactivate() {
         store.unsetDelegate(delegate);
+        trackerService.unsetDelegate(topoDelegate);
         eventDispatcher.removeSink(IntentEvent.class);
         log.info("Stopped");
     }
@@ -97,7 +89,6 @@
         checkNotNull(intent, INTENT_NULL);
         registerSubclassCompilerIfNeeded(intent);
         IntentEvent event = store.createIntent(intent);
-        eventDispatcher.post(event);
         processStoreEvent(event);
     }
 
@@ -105,7 +96,13 @@
     public void withdraw(Intent intent) {
         checkNotNull(intent, INTENT_NULL);
         IntentEvent event = store.setState(intent, WITHDRAWING);
-        eventDispatcher.post(event);
+        List<InstallableIntent> installables = store.getInstallableIntents(intent.getId());
+        if (installables != null) {
+            for (InstallableIntent installable : installables) {
+                trackerService.removeTrackedResources(intent.getId(),
+                                                      installable.requiredLinks());
+            }
+        }
         processStoreEvent(event);
     }
 
@@ -178,21 +175,10 @@
     }
 
     /**
-     * Invokes all of registered intent event listener.
-     *
-     * @param event event supplied to a listener as an argument
-     */
-    private void invokeListeners(IntentEvent event) {
-        for (IntentListener listener : listeners) {
-            listener.event(event);
-        }
-    }
-
-    /**
      * Returns the corresponding intent compiler to the specified intent.
      *
      * @param intent intent
-     * @param <T> the type of intent
+     * @param <T>    the type of intent
      * @return intent compiler corresponding to the specified intent
      */
     private <T extends Intent> IntentCompiler<T> getCompiler(T intent) {
@@ -206,8 +192,9 @@
 
     /**
      * Returns the corresponding intent installer to the specified installable intent.
+     *
      * @param intent intent
-     * @param <T> the type of installable intent
+     * @param <T>    the type of installable intent
      * @return intent installer corresponding to the specified installable intent
      */
     private <T extends InstallableIntent> IntentInstaller<T> getInstaller(T intent) {
@@ -229,10 +216,12 @@
         // TODO: implement compilation traversing tree structure
         List<InstallableIntent> installable = new ArrayList<>();
         for (Intent compiled : getCompiler(intent).compile(intent)) {
-            installable.add((InstallableIntent) compiled);
+            InstallableIntent installableIntent = (InstallableIntent) compiled;
+            installable.add(installableIntent);
+            trackerService.addTrackedResources(intent.getId(),
+                                               installableIntent.requiredLinks());
         }
         IntentEvent event = store.addInstallableIntents(intent.getId(), installable);
-        eventDispatcher.post(event);
         processStoreEvent(event);
     }
 
@@ -242,13 +231,14 @@
      * @param intent intent
      */
     private void installIntent(Intent intent) {
-        for (InstallableIntent installable : store.getInstallableIntents(intent.getId())) {
-            registerSubclassInstallerIfNeeded(installable);
-            getInstaller(installable).install(installable);
+        List<InstallableIntent> installables = store.getInstallableIntents(intent.getId());
+        if (installables != null) {
+            for (InstallableIntent installable : installables) {
+                registerSubclassInstallerIfNeeded(installable);
+                getInstaller(installable).install(installable);
+            }
         }
-
         IntentEvent event = store.setState(intent, INSTALLED);
-        eventDispatcher.post(event);
         processStoreEvent(event);
 
     }
@@ -259,10 +249,12 @@
      * @param intent intent
      */
     private void uninstallIntent(Intent intent) {
-        for (InstallableIntent installable : store.getInstallableIntents(intent.getId())) {
-            getInstaller(installable).uninstall(installable);
+        List<InstallableIntent> installables = store.getInstallableIntents(intent.getId());
+        if (installables != null) {
+            for (InstallableIntent installable : installables) {
+                getInstaller(installable).uninstall(installable);
+            }
         }
-
         store.removeInstalledIntents(intent.getId());
         store.setState(intent, WITHDRAWN);
     }
@@ -321,33 +313,32 @@
      * Handles state transition of submitted intents.
      */
     private void processStoreEvent(IntentEvent event) {
-            invokeListeners(event);
-            Intent intent = event.getIntent();
-
-            try {
-                switch (event.getState()) {
-                    case SUBMITTED:
-                        compileIntent(intent);
-                        break;
-                    case COMPILED:
-                        installIntent(intent);
-                        break;
-                    case INSTALLED:
-                        break;
-                    case WITHDRAWING:
-                        uninstallIntent(intent);
-                        break;
-                    case WITHDRAWN:
-                        break;
-                    case FAILED:
-                        break;
-                    default:
-                        throw new IllegalStateException(
-                                "the state of IntentEvent is illegal: " + event.getState());
-                }
-            } catch (IntentException e) {
-                store.setState(intent, FAILED);
+        eventDispatcher.post(event);
+        Intent intent = event.getIntent();
+        try {
+            switch (event.getState()) {
+                case SUBMITTED:
+                    compileIntent(intent);
+                    break;
+                case COMPILED:
+                    installIntent(intent);
+                    break;
+                case INSTALLED:
+                    break;
+                case WITHDRAWING:
+                    uninstallIntent(intent);
+                    break;
+                case WITHDRAWN:
+                    break;
+                case FAILED:
+                    break;
+                default:
+                    throw new IllegalStateException("the state of IntentEvent is illegal: " +
+                                                            event.getState());
             }
+        } catch (IntentException e) {
+            store.setState(intent, FAILED);
+        }
 
     }
 
@@ -355,9 +346,26 @@
     private class InternalStoreDelegate implements IntentStoreDelegate {
         @Override
         public void notify(IntentEvent event) {
-            eventDispatcher.post(event);
             processStoreEvent(event);
         }
     }
 
+    // Topology change delegate
+    private class InternalTopoChangeDelegate implements TopologyChangeDelegate {
+        @Override
+        public void bumpIntents(Iterable<IntentId> intentIds) {
+            for (IntentId intentId : intentIds) {
+                compileIntent(getIntent(intentId));
+            }
+        }
+
+        @Override
+        public void failIntents(Iterable<IntentId> intentIds) {
+            for (IntentId intentId : intentIds) {
+                Intent intent = getIntent(intentId);
+                uninstallIntent(intent);
+                compileIntent(intent);
+            }
+        }
+    }
 }
diff --git a/core/net/src/main/java/org/onlab/onos/net/intent/impl/TopologyChangeDelegate.java b/core/net/src/main/java/org/onlab/onos/net/intent/impl/TopologyChangeDelegate.java
new file mode 100644
index 0000000..8c39c75
--- /dev/null
+++ b/core/net/src/main/java/org/onlab/onos/net/intent/impl/TopologyChangeDelegate.java
@@ -0,0 +1,26 @@
+package org.onlab.onos.net.intent.impl;
+
+import org.onlab.onos.net.intent.IntentId;
+
+/**
+ * Auxiliary delegate for integration of intent manager and flow trackerService.
+ */
+public interface TopologyChangeDelegate {
+
+    /**
+     * Notifies that topology has changed in such a way that the specified
+     * intents should be recompiled.
+     *
+     * @param intentIds intents that should be recompiled
+     */
+    void bumpIntents(Iterable<IntentId> intentIds);
+
+    /**
+     * Notifies that topology has changed in such a way that the specified
+     * intents should be marked failed and then recompiled.
+     *
+     * @param intentIds intents that should be failed and recompiled
+     */
+    void failIntents(Iterable<IntentId> intentIds);
+
+}
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/topology/impl/DistributedTopologyStore.java b/core/store/dist/src/main/java/org/onlab/onos/store/topology/impl/DistributedTopologyStore.java
index 567861e..9ae9d7b 100644
--- a/core/store/dist/src/main/java/org/onlab/onos/store/topology/impl/DistributedTopologyStore.java
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/topology/impl/DistributedTopologyStore.java
@@ -125,7 +125,8 @@
         // Promote the new topology to current and return a ready-to-send event.
         synchronized (this) {
             current = newTopology;
-            return new TopologyEvent(TopologyEvent.Type.TOPOLOGY_CHANGED, current);
+            return new TopologyEvent(TopologyEvent.Type.TOPOLOGY_CHANGED,
+                                     current, reasons);
         }
     }
 
diff --git a/core/store/hz/net/src/main/java/org/onlab/onos/store/topology/impl/DistributedTopologyStore.java b/core/store/hz/net/src/main/java/org/onlab/onos/store/topology/impl/DistributedTopologyStore.java
index 4728850..04f5fce 100644
--- a/core/store/hz/net/src/main/java/org/onlab/onos/store/topology/impl/DistributedTopologyStore.java
+++ b/core/store/hz/net/src/main/java/org/onlab/onos/store/topology/impl/DistributedTopologyStore.java
@@ -125,7 +125,8 @@
         // Promote the new topology to current and return a ready-to-send event.
         synchronized (this) {
             current = newTopology;
-            return new TopologyEvent(TopologyEvent.Type.TOPOLOGY_CHANGED, current);
+            return new TopologyEvent(TopologyEvent.Type.TOPOLOGY_CHANGED,
+                                     current, reasons);
         }
     }
 
diff --git a/core/store/trivial/src/main/java/org/onlab/onos/store/trivial/impl/SimpleTopologyStore.java b/core/store/trivial/src/main/java/org/onlab/onos/store/trivial/impl/SimpleTopologyStore.java
index 4e7d5ed..bd7db8a 100644
--- a/core/store/trivial/src/main/java/org/onlab/onos/store/trivial/impl/SimpleTopologyStore.java
+++ b/core/store/trivial/src/main/java/org/onlab/onos/store/trivial/impl/SimpleTopologyStore.java
@@ -124,7 +124,8 @@
         // Promote the new topology to current and return a ready-to-send event.
         synchronized (this) {
             current = newTopology;
-            return new TopologyEvent(TopologyEvent.Type.TOPOLOGY_CHANGED, current);
+            return new TopologyEvent(TopologyEvent.Type.TOPOLOGY_CHANGED,
+                                     current, reasons);
         }
     }
 
diff --git a/tools/test/bin/onos-patch-vm b/tools/test/bin/onos-patch-vm
index f80f349..52038ce 100755
--- a/tools/test/bin/onos-patch-vm
+++ b/tools/test/bin/onos-patch-vm
@@ -15,7 +15,7 @@
 
 ssh $remote "
     sudo perl -pi.bak -e \"s/127.0.1.1.*/127.0.1.1       $name/g\" /etc/hosts
-    sudo perl -pi.bak -e \"s/.*/$name/g\" /etc/hostname
+    sudo perl -pi.bak -e \"local \$/ = ''; s/.*/$name/g\" /etc/hostname
     sudo hostname $name
 " 2>/dev/null