[ONOS-3203] End-to-end demo of Fault Management via SNMP.

This adds SNMP device-discovery, and a Fault Management app which makes alarms available to users via REST/GUI/CLI interfaces.
There is still code cleanup that could be done, but aim of this commit is an end-to-end proof of concept.

To demonstrate :

1) /opt/onos/bin/onos-service
onos> app activate org.onosproject.snmp
onos> app activate org.onosproject.faultmanagement

2) SNMP devices are seeded via config file. The default seed file contains connection details for devices (SNMP agents) available via internet  e.g. demo.snmplabs.com
cp /opt/onos/apache-karaf-3.0.3/etc/samples/org.onosproject.provider.snmp.device.impl.SnmpDeviceProvider.cfg   /opt/onos/apache-karaf-3.0.3/etc/

3) ONOS will poll these SNMP devices and store their alarms.

4) You can now manipulate the alarms via REST  e.g. http://<onos>:8181/onos/v1/fm/alarms , via CLI  via various "alarm-*” commands or in UI with an Alarms Overlay.

More info at https://wiki.onosproject.org/display/ONOS/Fault+Management

15/Dec/15: Updated regarding review comments from Thomas Vachuska.
17/Dec/15: Updated coreService.registerApplication(name) as per https://gerrit.onosproject.org/#/c/6878/

Change-Id: I886f8511f178dc4600ab96e5ff10cc90329cabec
diff --git a/apps/faultmanagement/fmgui/src/main/java/org/onosproject/faultmanagement/alarms/gui/AlarmServiceUtil.java b/apps/faultmanagement/fmgui/src/main/java/org/onosproject/faultmanagement/alarms/gui/AlarmServiceUtil.java
new file mode 100644
index 0000000..fca8bbd
--- /dev/null
+++ b/apps/faultmanagement/fmgui/src/main/java/org/onosproject/faultmanagement/alarms/gui/AlarmServiceUtil.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * 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.faultmanagement.alarms.gui;
+
+import java.util.Map;
+import java.util.Set;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.incubator.net.faultmanagement.alarm.Alarm;
+import org.onosproject.incubator.net.faultmanagement.alarm.AlarmId;
+import org.onosproject.incubator.net.faultmanagement.alarm.AlarmService;
+import org.onosproject.net.DeviceId;
+
+/**
+ *
+ * Utility for invoking on alarm service.
+ */
+public final class AlarmServiceUtil {
+
+    static Alarm lookupAlarm(AlarmId alarmId) {
+        return alarmService().getAlarm(alarmId);
+    }
+
+    static Set<Alarm> lookUpAlarms() {
+        return alarmService().getAlarms();
+    }
+
+    static Set<Alarm> lookUpAlarms(DeviceId deviceId) {
+        return alarmService().getAlarms(deviceId);
+    }
+
+    static Map<Alarm.SeverityLevel, Long> lookUpAlarmCounts(DeviceId deviceId) {
+        return alarmService().getAlarmCounts(deviceId);
+    }
+
+    static Map<Alarm.SeverityLevel, Long> lookUpAlarmCounts() {
+        return alarmService().getAlarmCounts();
+    }
+
+    private static AlarmService alarmService() {
+        return AbstractShellCommand.get(AlarmService.class);
+    }
+
+    private AlarmServiceUtil() {
+    }
+}
diff --git a/apps/faultmanagement/fmgui/src/main/java/org/onosproject/faultmanagement/alarms/gui/AlarmTableComponent.java b/apps/faultmanagement/fmgui/src/main/java/org/onosproject/faultmanagement/alarms/gui/AlarmTableComponent.java
new file mode 100644
index 0000000..bf9eb94
--- /dev/null
+++ b/apps/faultmanagement/fmgui/src/main/java/org/onosproject/faultmanagement/alarms/gui/AlarmTableComponent.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * 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.faultmanagement.alarms.gui;
+
+import com.google.common.collect.ImmutableList;
+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.onosproject.ui.UiExtension;
+import org.onosproject.ui.UiExtensionService;
+import org.onosproject.ui.UiMessageHandlerFactory;
+import org.onosproject.ui.UiView;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+
+/**
+ * Skeletal ONOS UI Table-View application component.
+ */
+@Component(immediate = true)
+public class AlarmTableComponent {
+
+    private static final String VIEW_ID = "alarmTable";
+    private static final String VIEW_TEXT = "Alarms";
+
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected UiExtensionService uiExtensionService;
+
+    // List of application views
+    private final List<UiView> uiViews = ImmutableList.of(
+            new UiView(UiView.Category.OTHER, VIEW_ID, VIEW_TEXT)
+    );
+
+    // Factory for UI message handlers
+    private final UiMessageHandlerFactory messageHandlerFactory =
+            () -> ImmutableList.of(
+                    new AlarmTableMessageHandler()
+            );
+
+    // Application UI extension
+    protected UiExtension extension =
+            new UiExtension.Builder(getClass().getClassLoader(), uiViews)
+                    .resourcePath(VIEW_ID)
+                    .messageHandlerFactory(messageHandlerFactory)
+                    .build();
+
+    @Activate
+    protected void activate() {
+        uiExtensionService.register(extension);
+        log.info("Started");
+    }
+
+    @Deactivate
+    protected void deactivate() {
+        uiExtensionService.unregister(extension);
+        log.info("Stopped");
+    }
+
+}
diff --git a/apps/faultmanagement/fmgui/src/main/java/org/onosproject/faultmanagement/alarms/gui/AlarmTableMessageHandler.java b/apps/faultmanagement/fmgui/src/main/java/org/onosproject/faultmanagement/alarms/gui/AlarmTableMessageHandler.java
new file mode 100644
index 0000000..df475e2
--- /dev/null
+++ b/apps/faultmanagement/fmgui/src/main/java/org/onosproject/faultmanagement/alarms/gui/AlarmTableMessageHandler.java
@@ -0,0 +1,177 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * 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.faultmanagement.alarms.gui;
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.google.common.base.Strings;
+import com.google.common.collect.ImmutableSet;
+import org.onosproject.ui.RequestHandler;
+import org.onosproject.ui.UiMessageHandler;
+import org.onosproject.ui.table.TableModel;
+import org.onosproject.ui.table.TableRequestHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Collection;
+import java.util.Set;
+import org.joda.time.DateTime;
+import org.onosproject.incubator.net.faultmanagement.alarm.Alarm;
+import org.onosproject.incubator.net.faultmanagement.alarm.AlarmId;
+import org.onosproject.net.DeviceId;
+import org.onosproject.ui.table.cell.TimeFormatter;
+
+/**
+ * Skeletal ONOS UI Table-View message handler.
+ */
+public class AlarmTableMessageHandler extends UiMessageHandler {
+
+    private static final String ALARM_TABLE_DATA_REQ = "alarmTableDataRequest";
+    private static final String ALARM_TABLE_DATA_RESP = "alarmTableDataResponse";
+    private static final String ALARM_TABLES = "alarmTables";
+
+    private static final String ALARM_TABLE_DETAIL_REQ = "alarmTableDetailsRequest";
+    private static final String ALARM_TABLE_DETAIL_RESP = "alarmTableDetailsResponse";
+    private static final String DETAILS = "details";
+
+    private static final String ID = "id";
+    private static final String DEVICE_ID_STR = "alarmDeviceId";
+    private static final String DESCRIPTION = "alarmDesc";
+    private static final String SOURCE = "alarmSource";
+    private static final String TIME_RAISED = "alarmTimeRaised";
+    private static final String TIME_UPDATED = "alarmTimeUpdated";
+    private static final String TIME_CLEARED = "alarmTimeCleared";
+    private static final String SEVERITY = "alarmSeverity";
+    private static final String RESULT = "result";
+
+    // TODO No need to show id column in ONOS-GUI
+
+    // TODO Replace SEVERITY column by color-coding of row depending on severity ie. red=critical, green=cleared etc
+    private static final String[] COLUMN_IDS = {ID, DEVICE_ID_STR, DESCRIPTION, SOURCE, TIME_RAISED, SEVERITY};
+
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    @Override
+    protected Collection<RequestHandler> createRequestHandlers() {
+        return ImmutableSet.of(
+                new AlarmTableDataRequestHandler(),
+                new AlarmTableDetailRequestHandler()
+        );
+    }
+
+    // handler for alarm table requests
+    private final class AlarmTableDataRequestHandler extends TableRequestHandler {
+
+        private AlarmTableDataRequestHandler() {
+            super(ALARM_TABLE_DATA_REQ, ALARM_TABLE_DATA_RESP, ALARM_TABLES);
+        }
+
+        @Override
+        protected String defaultColumnId() {
+            // if necessary, override defaultColumnId() -- if it isn't "id"
+            return ID;
+        }
+
+        @Override
+        protected String[] getColumnIds() {
+            return COLUMN_IDS;
+        }
+
+        @Override
+        protected TableModel createTableModel() {
+            // if required, override createTableModel() to set column formatters / comparators
+            TableModel tm = super.createTableModel();
+            tm.setFormatter(TIME_RAISED, new TimeFormatter());
+            return tm;
+        }
+
+        @Override
+        protected void populateTable(TableModel tm, ObjectNode payload) {
+            log.debug(" populateTable tm={} payload ={}", tm, payload);
+            String devId = string(payload, "devId");
+
+            Set<Alarm> alarms = Strings.isNullOrEmpty(devId) ?
+                    AlarmServiceUtil.lookUpAlarms() :
+                    AlarmServiceUtil.lookUpAlarms(DeviceId.deviceId(devId));
+
+            alarms.stream().forEach((alarm) -> {
+                populateRow(tm.addRow(), alarm);
+            });
+
+        }
+
+        private void populateRow(TableModel.Row row, Alarm alarm) {
+            log.debug("populate table Row row={} item ={}", row, alarm);
+
+            row.cell(ID, alarm.id().fingerprint())
+                    .cell(DEVICE_ID_STR, alarm.deviceId())
+                    .cell(DESCRIPTION, alarm.description())
+                    .cell(SOURCE, alarm.source())
+                    .cell(TIME_RAISED, new DateTime(alarm.timeRaised()))
+                    .cell(SEVERITY, alarm.severity());
+        }
+    }
+
+    // handler for alarm details requests
+    private final class AlarmTableDetailRequestHandler extends RequestHandler {
+
+        private AlarmTableDetailRequestHandler() {
+            super(ALARM_TABLE_DETAIL_REQ);
+        }
+
+        @Override
+        public void process(long sid, ObjectNode payload) {
+            log.debug("sid={}, payload ={}", sid, payload);
+
+            String id = string(payload, ID, "(none)");
+            Alarm alarm = AlarmServiceUtil.lookupAlarm(AlarmId.alarmId(Long.parseLong(id)));
+            ObjectNode rootNode = objectNode();
+            ObjectNode data = objectNode();
+            rootNode.set(DETAILS, data);
+
+            if (alarm == null) {
+                rootNode.put(RESULT, "Item with id '" + id + "' not found");
+                log.warn("attempted to get item detail for id '{}'", id);
+
+            } else {
+                rootNode.put(RESULT, "Found item with id '" + id + "'");
+
+                data.put(ID, alarm.id().fingerprint());
+                data.put(DESCRIPTION, alarm.description());
+                data.put(DEVICE_ID_STR, alarm.deviceId().toString());
+                data.put(SOURCE, alarm.source().toString());
+                long timeRaised = alarm.timeRaised();
+                data.put(TIME_RAISED,
+                        formatTime(timeRaised)
+                );
+                data.put(TIME_UPDATED, formatTime(alarm.timeUpdated()));
+                data.put(TIME_CLEARED, formatTime(alarm.timeCleared()));
+                data.put(SEVERITY, alarm.severity().toString());
+            }
+            log.debug("send ={}", rootNode);
+
+            sendMessage(ALARM_TABLE_DETAIL_RESP, 0, rootNode);
+        }
+    }
+
+    private static String formatTime(Long msSinceStartOfEpoch) {
+        if (msSinceStartOfEpoch == null) {
+            return "-";
+        }
+        return new TimeFormatter().format(new DateTime(msSinceStartOfEpoch));
+    }
+
+
+}
diff --git a/apps/faultmanagement/fmgui/src/main/java/org/onosproject/faultmanagement/alarms/gui/AlarmTopovComponent.java b/apps/faultmanagement/fmgui/src/main/java/org/onosproject/faultmanagement/alarms/gui/AlarmTopovComponent.java
new file mode 100644
index 0000000..901d30f
--- /dev/null
+++ b/apps/faultmanagement/fmgui/src/main/java/org/onosproject/faultmanagement/alarms/gui/AlarmTopovComponent.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * 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.faultmanagement.alarms.gui;
+
+import com.google.common.collect.ImmutableList;
+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.onosproject.ui.UiExtension;
+import org.onosproject.ui.UiExtensionService;
+import org.onosproject.ui.UiMessageHandlerFactory;
+import org.onosproject.ui.UiTopoOverlayFactory;
+import org.onosproject.ui.UiView;
+import org.onosproject.ui.UiViewHidden;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+
+/**
+ * Skeletal ONOS UI Topology-Overlay application component.
+ */
+@Component(immediate = true)
+public class AlarmTopovComponent {
+
+    private static final ClassLoader CL = AlarmTopovComponent.class.getClassLoader();
+    private static final String VIEW_ID = "alarmTopov";
+
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected UiExtensionService uiExtensionService;
+
+    // List of application views
+    private final List<UiView> uiViews = ImmutableList.of(
+            new UiViewHidden(VIEW_ID)
+    );
+
+    // Factory for UI message handlers
+    private final UiMessageHandlerFactory messageHandlerFactory =
+            () -> ImmutableList.of(
+                    new AlarmTopovMessageHandler()
+            );
+
+    // Factory for UI topology overlays
+    private final UiTopoOverlayFactory topoOverlayFactory =
+            () -> ImmutableList.of(
+                    new AlarmTopovOverlay()
+            );
+
+    // Application UI extension
+    protected UiExtension extension =
+            new UiExtension.Builder(CL, uiViews)
+                    .resourcePath(VIEW_ID)
+                    .messageHandlerFactory(messageHandlerFactory)
+                    .topoOverlayFactory(topoOverlayFactory)
+                    .build();
+
+    @Activate
+    protected void activate() {
+        uiExtensionService.register(extension);
+        log.info("Started");
+    }
+
+    @Deactivate
+    protected void deactivate() {
+        uiExtensionService.unregister(extension);
+        log.info("Stopped");
+    }
+
+}
diff --git a/apps/faultmanagement/fmgui/src/main/java/org/onosproject/faultmanagement/alarms/gui/AlarmTopovMessageHandler.java b/apps/faultmanagement/fmgui/src/main/java/org/onosproject/faultmanagement/alarms/gui/AlarmTopovMessageHandler.java
new file mode 100644
index 0000000..adeb9d5
--- /dev/null
+++ b/apps/faultmanagement/fmgui/src/main/java/org/onosproject/faultmanagement/alarms/gui/AlarmTopovMessageHandler.java
@@ -0,0 +1,224 @@
+/*
+ * Copyright 2014,2015 Open Networking Laboratory
+ *
+ * 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.faultmanagement.alarms.gui;
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.google.common.base.Strings;
+import com.google.common.collect.ImmutableSet;
+import org.onlab.osgi.ServiceDirectory;
+import org.onosproject.net.Device;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.Element;
+import org.onosproject.net.HostId;
+import org.onosproject.net.device.DeviceService;
+import org.onosproject.net.host.HostService;
+import org.onosproject.ui.RequestHandler;
+import org.onosproject.ui.UiConnection;
+import org.onosproject.ui.UiMessageHandler;
+import org.onosproject.ui.topo.DeviceHighlight;
+import org.onosproject.ui.topo.Highlights;
+import org.onosproject.ui.topo.NodeBadge;
+import org.onosproject.ui.topo.NodeBadge.Status;
+import org.onosproject.ui.topo.TopoJson;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Collection;
+import java.util.Set;
+import org.onosproject.incubator.net.faultmanagement.alarm.Alarm;
+import org.onosproject.incubator.net.faultmanagement.alarm.AlarmService;
+
+/**
+ * Skeletal ONOS UI Topology-Overlay message handler.
+ */
+public class AlarmTopovMessageHandler extends UiMessageHandler {
+
+    private static final String ALARM_TOPOV_DISPLAY_START = "alarmTopovDisplayStart";
+    private static final String ALARM_TOPOV_DISPLAY_UPDATE = "alarmTopovDisplayUpdate";
+    private static final String ALARM_TOPOV_DISPLAY_STOP = "alarmTopovDisplayStop";
+
+    private static final String ID = "id";
+    private static final String MODE = "mode";
+
+    private enum Mode {
+
+        IDLE, MOUSE
+    }
+
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    private DeviceService deviceService;
+    private HostService hostService;
+    private AlarmService alarmService;
+
+    private Mode currentMode = Mode.IDLE;
+    private Element elementOfNote;
+
+    // ===============-=-=-=-=-=-======================-=-=-=-=-=-=-================================
+    @Override
+    public void init(UiConnection connection, ServiceDirectory directory) {
+        super.init(connection, directory);
+        deviceService = directory.get(DeviceService.class);
+        hostService = directory.get(HostService.class);
+        alarmService = directory.get(AlarmService.class);
+    }
+
+    @Override
+    protected Collection<RequestHandler> createRequestHandlers() {
+        return ImmutableSet.of(
+                new DisplayStartHandler(),
+                new DisplayUpdateHandler(),
+                new DisplayStopHandler()
+        );
+    }
+
+    // === -------------------------
+    // === Handler classes
+    private final class DisplayStartHandler extends RequestHandler {
+
+        public DisplayStartHandler() {
+            super(ALARM_TOPOV_DISPLAY_START);
+        }
+
+        @Override
+        public void process(long sid, ObjectNode payload) {
+            String mode = string(payload, MODE);
+
+            log.debug("Start Display: mode [{}]", mode);
+            clearState();
+            clearForMode();
+
+            switch (mode) {
+                case "mouse":
+                    currentMode = Mode.MOUSE;
+
+                    sendMouseData();
+                    break;
+
+                default:
+                    currentMode = Mode.IDLE;
+
+                    break;
+            }
+        }
+    }
+
+    private final class DisplayUpdateHandler extends RequestHandler {
+
+        public DisplayUpdateHandler() {
+            super(ALARM_TOPOV_DISPLAY_UPDATE);
+        }
+
+        @Override
+        public void process(long sid, ObjectNode payload) {
+            String id = string(payload, ID);
+            log.debug("Update Display: id [{}]", id);
+            if (!Strings.isNullOrEmpty(id)) {
+                updateForMode(id);
+            } else {
+                clearForMode();
+            }
+        }
+    }
+
+    private final class DisplayStopHandler extends RequestHandler {
+
+        public DisplayStopHandler() {
+            super(ALARM_TOPOV_DISPLAY_STOP);
+        }
+
+        @Override
+        public void process(long sid, ObjectNode payload) {
+            log.debug("Stop Display");
+            clearState();
+            clearForMode();
+        }
+    }
+
+    // === ------------
+    private void clearState() {
+        currentMode = Mode.IDLE;
+        elementOfNote = null;
+    }
+
+    private void updateForMode(String id) {
+        log.debug("host service: {}", hostService);
+        log.debug("device service: {}", deviceService);
+
+        try {
+            HostId hid = HostId.hostId(id);
+            log.debug("host id {}", hid);
+            elementOfNote = hostService.getHost(hid);
+            log.debug("host element {}", elementOfNote);
+
+        } catch (RuntimeException e) {
+            try {
+                DeviceId did = DeviceId.deviceId(id);
+                log.debug("device id {}", did);
+                elementOfNote = deviceService.getDevice(did);
+                log.debug("device element {}", elementOfNote);
+
+            } catch (RuntimeException e2) {
+                log.debug("Unable to process ID [{}]", id);
+                elementOfNote = null;
+            }
+        }
+
+        switch (currentMode) {
+            case MOUSE:
+                sendMouseData();
+                break;
+
+            default:
+                break;
+        }
+
+    }
+
+    private void clearForMode() {
+        sendHighlights(new Highlights());
+    }
+
+    private void sendHighlights(Highlights highlights) {
+        sendMessage(TopoJson.highlightsMessage(highlights));
+    }
+
+    private void sendMouseData() {
+        if (elementOfNote != null && elementOfNote instanceof Device) {
+            DeviceId devId = (DeviceId) elementOfNote.id();
+            Set<Alarm> alarmsOnDevice = alarmService.getAlarms(devId);
+            Highlights highlights = new Highlights();
+
+            addDeviceBadge(highlights, devId, alarmsOnDevice.size());
+            sendHighlights(highlights);
+        }
+        // Note: could also process Host, if available
+    }
+
+    private void addDeviceBadge(Highlights h, DeviceId devId, int n) {
+        DeviceHighlight dh = new DeviceHighlight(devId.toString());
+        dh.setBadge(createBadge(n));
+        h.add(dh);
+    }
+
+    private NodeBadge createBadge(int n) {
+        Status status = n > 0 ? Status.ERROR : Status.INFO;
+        String noun = n > 0 ? "(Alarmed)" : "(Normal)";
+        String msg = "Alarms: " + n + " " + noun;
+        return NodeBadge.number(status, n, msg);
+    }
+
+}
diff --git a/apps/faultmanagement/fmgui/src/main/java/org/onosproject/faultmanagement/alarms/gui/AlarmTopovOverlay.java b/apps/faultmanagement/fmgui/src/main/java/org/onosproject/faultmanagement/alarms/gui/AlarmTopovOverlay.java
new file mode 100644
index 0000000..7fc87db
--- /dev/null
+++ b/apps/faultmanagement/fmgui/src/main/java/org/onosproject/faultmanagement/alarms/gui/AlarmTopovOverlay.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * 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.faultmanagement.alarms.gui;
+
+import java.util.Map;
+import org.onosproject.incubator.net.faultmanagement.alarm.Alarm;
+import org.onosproject.net.DeviceId;
+import org.onosproject.ui.UiTopoOverlay;
+import org.onosproject.ui.topo.ButtonId;
+import org.onosproject.ui.topo.PropertyPanel;
+import org.onosproject.ui.topo.TopoConstants.CoreButtons;
+import static org.onosproject.ui.topo.TopoConstants.Properties.*;
+
+/**
+ * Our topology overlay.
+ */
+public class AlarmTopovOverlay extends UiTopoOverlay {
+
+    // NOTE: this must match the ID defined in alarmTopov.js
+    private static final String OVERLAY_ID = "alarmsTopo-overlay";
+
+    private static final ButtonId ALARM1_BUTTON = new ButtonId("alarm1button");
+    private static final ButtonId ALARM2_BUTTON = new ButtonId("alarm2button");
+
+    public AlarmTopovOverlay() {
+        super(OVERLAY_ID);
+    }
+
+    @Override
+    public void modifySummary(PropertyPanel pp) {
+        pp.title("Alarms Overview");
+        // We could just remove some properties here but lets keep it uncluttered, unless
+        //    there is feedback other properties are essential.
+        pp.removeAllProps();
+        Map<Alarm.SeverityLevel, Long> countsForAll = AlarmServiceUtil.lookUpAlarmCounts();
+        addAlarmCountsProperties(pp, countsForAll);
+
+    }
+
+    @Override
+    public void modifyDeviceDetails(PropertyPanel pp, DeviceId deviceId) {
+        pp.title("Alarm Details");
+        pp.removeProps(LATITUDE, LONGITUDE, PORTS, FLOWS, TUNNELS, SERIAL_NUMBER, PROTOCOL);
+
+        Map<Alarm.SeverityLevel, Long> countsForDevice = AlarmServiceUtil.lookUpAlarmCounts(deviceId);
+        addAlarmCountsProperties(pp, countsForDevice);
+
+        pp.addButton(ALARM1_BUTTON)
+                .addButton(ALARM2_BUTTON);
+
+        pp.removeButtons(CoreButtons.SHOW_PORT_VIEW)
+                .removeButtons(CoreButtons.SHOW_GROUP_VIEW);
+    }
+
+    private void addAlarmCountsProperties(PropertyPanel pp, Map<Alarm.SeverityLevel, Long> countsForDevice) {
+
+        // TODO we could show these as color-coded squares with a count inside, to save space on the screen.
+
+        long cr = countsForDevice.getOrDefault(Alarm.SeverityLevel.CRITICAL, 0L);
+        long ma = countsForDevice.getOrDefault(Alarm.SeverityLevel.MAJOR, 0L);
+        long mi = countsForDevice.getOrDefault(Alarm.SeverityLevel.MINOR, 0L);
+        long wa = countsForDevice.getOrDefault(Alarm.SeverityLevel.WARNING, 0L);
+        long in = countsForDevice.getOrDefault(Alarm.SeverityLevel.INDETERMINATE, 0L);
+        long cl = countsForDevice.getOrDefault(Alarm.SeverityLevel.CLEARED, 0L);
+
+        // Unfortunately the PropertyPanel does not righ justify numbers even when using longs,
+        // but that not in scope of fault management work
+        pp.addProp("Critical", cr);
+        pp.addProp("Major", ma);
+        pp.addProp("Minor", mi);
+        pp.addProp("Warning", wa);
+        pp.addProp("Indeter.", in);
+        pp.addProp("Cleared", cl);
+        pp.addSeparator();
+        pp.addProp("Total", cr + ma + mi + wa + in + cl);
+
+    }
+
+}
diff --git a/apps/faultmanagement/fmgui/src/main/java/org/onosproject/faultmanagement/alarms/gui/package-info.java b/apps/faultmanagement/fmgui/src/main/java/org/onosproject/faultmanagement/alarms/gui/package-info.java
new file mode 100644
index 0000000..fcb4284
--- /dev/null
+++ b/apps/faultmanagement/fmgui/src/main/java/org/onosproject/faultmanagement/alarms/gui/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * 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.
+ */
+
+/**
+ * Fault Management GUI implementation.
+ */
+package org.onosproject.faultmanagement.alarms.gui;