[ONOS-4260]Alarm and fault managment application refactoring according to ONOS architecture

Change-Id: I47e9db37eb5fc27ac19db2e4cb87774736b44685
diff --git a/BUCK b/BUCK
index e132bdf..c5663b2 100644
--- a/BUCK
+++ b/BUCK
@@ -76,7 +76,6 @@
     '//providers/pcep/topology:onos-pcep-provider-topology',
     '//providers/pcep/tunnel:onos-pcep-provider-tunnel',
     '//providers/rest/device:onos-restsb-provider-device',
-    '//providers/snmp/alarm:onos-snmp-provider-alarm',
     '//providers/snmp/device:onos-snmp-provider-device',
 
     '//web/api:onos-rest',
diff --git a/apps/faultmanagement/fmcli/src/main/java/org/onosproject/faultmanagement/alarms/cli/GetAllAlarmsCounts.java b/apps/faultmanagement/fmcli/src/main/java/org/onosproject/faultmanagement/alarms/cli/GetAllAlarmsCounts.java
index 9f8973a..578cee9 100644
--- a/apps/faultmanagement/fmcli/src/main/java/org/onosproject/faultmanagement/alarms/cli/GetAllAlarmsCounts.java
+++ b/apps/faultmanagement/fmcli/src/main/java/org/onosproject/faultmanagement/alarms/cli/GetAllAlarmsCounts.java
@@ -35,9 +35,9 @@
         printCounts(alarmCounts);
     }
 
-    static void printCounts(Map<Alarm.SeverityLevel, Long> alarmCounts) {
+    void printCounts(Map<Alarm.SeverityLevel, Long> alarmCounts) {
         alarmCounts.entrySet().stream().forEach((countEntry) -> {
-            System.out.println(String.format("%s, %d",
+            print(String.format("%s, %d",
                     countEntry.getKey(), countEntry.getValue()));
 
         });
diff --git a/apps/faultmanagement/fmcli/src/main/java/org/onosproject/faultmanagement/alarms/cli/GetDeviceAlarmsCounts.java b/apps/faultmanagement/fmcli/src/main/java/org/onosproject/faultmanagement/alarms/cli/GetDeviceAlarmsCounts.java
index bf0ae56..0d62c39 100644
--- a/apps/faultmanagement/fmcli/src/main/java/org/onosproject/faultmanagement/alarms/cli/GetDeviceAlarmsCounts.java
+++ b/apps/faultmanagement/fmcli/src/main/java/org/onosproject/faultmanagement/alarms/cli/GetDeviceAlarmsCounts.java
@@ -38,7 +38,14 @@
         Map<Alarm.SeverityLevel, Long> alarmCounts = AbstractShellCommand.get(AlarmService.class).
                 getAlarmCounts(DeviceId.deviceId(deviceId));
         // Deliberately using same formatting for both ...
-        GetAllAlarmsCounts.printCounts(alarmCounts);
+        printCounts(alarmCounts);
     }
 
+    void printCounts(Map<Alarm.SeverityLevel, Long> alarmCounts) {
+        alarmCounts.entrySet().stream().forEach((countEntry) -> {
+            print(String.format("%s, %d",
+                                countEntry.getKey(), countEntry.getValue()));
+
+        });
+    }
 }
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
index 162cf7d..3268343 100644
--- 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
@@ -42,7 +42,7 @@
 import org.onosproject.incubator.net.faultmanagement.alarm.AlarmService;
 
 /**
- * Skeletal ONOS UI Topology-Overlay message handler.
+ * FaultManagement UI Topology-Overlay message handler.
  */
 public class AlarmTopovMessageHandler extends UiMessageHandler {
 
diff --git a/apps/faultmanagement/fmmgr/pom.xml b/apps/faultmanagement/fmmgr/pom.xml
index 07a2910..3e1f3bd 100644
--- a/apps/faultmanagement/fmmgr/pom.xml
+++ b/apps/faultmanagement/fmmgr/pom.xml
@@ -45,11 +45,6 @@
             <version>${project.version}</version>
         </dependency>
         <dependency>
-            <groupId>org.onosproject</groupId>
-            <artifactId>onos-snmp-provider-alarm</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.compendium</artifactId>
             <version>5.0.0</version>
diff --git a/apps/faultmanagement/fmmgr/src/main/java/org/onosproject/faultmanagement/impl/AlarmsManager.java b/apps/faultmanagement/fmmgr/src/main/java/org/onosproject/faultmanagement/impl/AlarmsManager.java
index 90ccaff..c7f724e 100644
--- a/apps/faultmanagement/fmmgr/src/main/java/org/onosproject/faultmanagement/impl/AlarmsManager.java
+++ b/apps/faultmanagement/fmmgr/src/main/java/org/onosproject/faultmanagement/impl/AlarmsManager.java
@@ -15,95 +15,79 @@
  */
 package org.onosproject.faultmanagement.impl;
 
-import static com.google.common.base.Preconditions.checkNotNull;
-import java.util.Dictionary;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.stream.Collectors;
+import com.google.common.collect.ImmutableSet;
 import org.apache.commons.collections.CollectionUtils;
 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.Modified;
-import org.apache.felix.scr.annotations.Property;
-import static org.onlab.util.Tools.nullIsNotFound;
-
+import org.apache.felix.scr.annotations.Service;
+import org.onlab.util.ItemNotFoundException;
 import org.onosproject.incubator.net.faultmanagement.alarm.Alarm;
 import org.onosproject.incubator.net.faultmanagement.alarm.AlarmEntityId;
-import org.onosproject.incubator.net.faultmanagement.alarm.AlarmEvent;
 import org.onosproject.incubator.net.faultmanagement.alarm.AlarmId;
-import org.onosproject.incubator.net.faultmanagement.alarm.AlarmListener;
+import org.onosproject.incubator.net.faultmanagement.alarm.AlarmProvider;
+import org.onosproject.incubator.net.faultmanagement.alarm.AlarmProviderRegistry;
+import org.onosproject.incubator.net.faultmanagement.alarm.AlarmProviderService;
 import org.onosproject.incubator.net.faultmanagement.alarm.AlarmService;
+import org.onosproject.incubator.net.faultmanagement.alarm.DefaultAlarm;
 import org.onosproject.net.ConnectPoint;
 import org.onosproject.net.DeviceId;
-import org.slf4j.Logger;
-import static org.slf4j.LoggerFactory.getLogger;
-import org.apache.felix.scr.annotations.Service;
-import static org.onlab.util.Tools.get;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.IdGenerator;
-import org.onosproject.core.CoreService;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.ReferenceCardinality;
-import org.onlab.util.ItemNotFoundException;
-import org.onosproject.incubator.net.faultmanagement.alarm.AlarmProvider;
-import org.onosproject.incubator.net.faultmanagement.alarm.DefaultAlarm;
-import org.onosproject.net.device.DeviceService;
+import org.onosproject.net.provider.AbstractProviderRegistry;
+import org.onosproject.net.provider.AbstractProviderService;
 import org.osgi.service.component.ComponentContext;
-import static java.util.concurrent.TimeUnit.SECONDS;
+import org.slf4j.Logger;
 
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.atomic.AtomicLong;
-import static org.onlab.util.Tools.groupedThreads;
-import org.onosproject.net.Device;
+import java.util.stream.Collectors;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.onlab.util.Tools.nullIsNotFound;
+import static org.slf4j.LoggerFactory.getLogger;
 
 /**
  * Implementation of the Alarm service.
  */
 @Component(immediate = true)
 @Service
-public class AlarmsManager implements AlarmService {
-
-    // For subscribing to device-related events
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
-    protected CoreService coreService;
-
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
-    protected DeviceService deviceService;
-
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
-    protected AlarmProvider alarmProvider;
+public class AlarmsManager
+        extends AbstractProviderRegistry<AlarmProvider, AlarmProviderService>
+        implements AlarmService, AlarmProviderRegistry {
 
     private final Logger log = getLogger(getClass());
-    private ApplicationId appId;
-    private IdGenerator idGenerator;
 
-    private ScheduledExecutorService alarmPollExecutor;
-
-    // dummy data
     private final AtomicLong alarmIdGenerator = new AtomicLong(0);
 
+    // TODO Later should must be persisted to disk or database
+    protected final Map<AlarmId, Alarm> alarms = new ConcurrentHashMap<>();
+
+    private static final String NOT_SUPPORTED_YET = "Not supported yet.";
+
+    @Activate
+    public void activate(ComponentContext context) {
+        log.info("Started");
+    }
+
+    @Deactivate
+    public void deactivate(ComponentContext context) {
+        alarms.clear();
+        log.info("Stopped");
+    }
+
+    @Modified
+    public boolean modified(ComponentContext context) {
+        log.info("Modified");
+        return true;
+    }
+
     private AlarmId generateAlarmId() {
         return AlarmId.alarmId(alarmIdGenerator.incrementAndGet());
     }
 
-    private static final int DEFAULT_POLL_FREQUENCY_SECONDS = 120;
-    @Property(name = "alarmPollFrequencySeconds", intValue = DEFAULT_POLL_FREQUENCY_SECONDS,
-            label = "Frequency (in seconds) for polling alarm from devices")
-    private int alarmPollFrequencySeconds = DEFAULT_POLL_FREQUENCY_SECONDS;
-
-    // TODO implement purging of old alarms.
-    private static final int DEFAULT_CLEAR_FREQUENCY_SECONDS = 500;
-    @Property(name = "clearedAlarmPurgeSeconds", intValue = DEFAULT_CLEAR_FREQUENCY_SECONDS,
-            label = "Frequency (in seconds) for deleting cleared alarms")
-    private int clearedAlarmPurgeFrequencySeconds = DEFAULT_CLEAR_FREQUENCY_SECONDS;
-
-    // TODO Later should must be persisted to disk or database
-    private final Map<AlarmId, Alarm> alarms = new ConcurrentHashMap<>();
-
     @Override
     public Alarm updateBookkeepingFields(AlarmId id, boolean isAcknowledged, String assignedUser) {
 
@@ -120,7 +104,6 @@
     }
 
     public Alarm clear(AlarmId id) {
-
         Alarm found = alarms.get(id);
         if (found == null) {
             log.warn("id {} cant be cleared as it is already gone.", id);
@@ -133,33 +116,25 @@
 
     @Override
     public Map<Alarm.SeverityLevel, Long> getAlarmCounts(DeviceId deviceId) {
-
         return getAlarms(deviceId).stream().collect(
                 Collectors.groupingBy(Alarm::severity, Collectors.counting()));
-
     }
 
     @Override
     public Map<Alarm.SeverityLevel, Long> getAlarmCounts() {
-
         return getAlarms().stream().collect(
                 Collectors.groupingBy(Alarm::severity, Collectors.counting()));
     }
 
-
-    private static final String NOT_SUPPORTED_YET = "Not supported yet.";
-
     @Override
     public Alarm getAlarm(AlarmId alarmId) {
-        return nullIsNotFound(
-                alarms.get(
-                        checkNotNull(alarmId, "Alarm Id cannot be null")),
-                "Alarm is not found");
+        return nullIsNotFound(alarms.get(checkNotNull(alarmId, "Alarm Id cannot be null")),
+                              "Alarm is not found");
     }
 
     @Override
     public Set<Alarm> getAlarms() {
-        return new HashSet<>(alarms.values());
+        return ImmutableSet.copyOf(alarms.values());
     }
 
     @Override
@@ -198,122 +173,21 @@
 
     @Override
     public Set<Alarm> getAlarmsForLink(ConnectPoint src, ConnectPoint dst) {
-        //TODO
         throw new UnsupportedOperationException(NOT_SUPPORTED_YET);
     }
 
     @Override
     public Set<Alarm> getAlarmsForFlow(DeviceId deviceId, long flowId) {
-        //TODO
         throw new UnsupportedOperationException(NOT_SUPPORTED_YET);
     }
 
-    private final AlarmListener alarmListener = new InternalAlarmListener();
-
-    private class InternalAlarmListener implements AlarmListener {
-
-        @Override
-        public void event(AlarmEvent event) {
-            log.debug("AlarmsManager. InternalAlarmListener received {}", event);
-            try {
-
-                switch (event.type()) {
-                    case DEVICE_DISCOVERY:
-                        DeviceId deviceId = checkNotNull(event.getDeviceRefreshed(), "Listener cannot be null");
-                        log.info("New alarm set for {} received!", deviceId);
-                        updateAlarms(event.subject(), deviceId);
-                        break;
-
-                    case NOTIFICATION:
-                        throw new IllegalArgumentException(
-                                "Alarm Notifications (Traps) not expected or implemented yet. Received =" + event);
-                    default:
-                        break;
-                }
-            } catch (Exception e) {
-                log.warn("Failed to process {}", event, e);
-            }
-        }
-    }
-
-    @Activate
-    public void activate(ComponentContext context) {
-        appId = coreService.registerApplication("org.onosproject.faultmanagement.alarms");
-        idGenerator = coreService.getIdGenerator("alarm-ids");
-        log.info("Started with appId={}", appId);
-
-        alarmProvider.addAlarmListener(alarmListener);
-
-        probeActiveDevices();
-
-        boolean result = modified(context);
-        log.info("modified result = {}", result);
-
-        alarmPollExecutor = newSingleThreadScheduledExecutor(groupedThreads("onos/fm", "alarms-poll-%d"));
-        alarmPollExecutor.scheduleAtFixedRate(new PollAlarmsTask(),
-                alarmPollFrequencySeconds, alarmPollFrequencySeconds, SECONDS);
-
-    }
-
-    /**
-     * Auxiliary task to keep alarms up to date. IN future release alarm-notifications will be used as an optimization
-     * so we dont have to wait until polling to detect changes. Furthermore with simple polling flapping alarms may be
-     * missed.
-     */
-    private final class PollAlarmsTask implements Runnable {
-
-        @Override
-        public void run() {
-            if (Thread.currentThread().isInterrupted()) {
-                log.info("Interrupted, quitting");
-                return;
-            }
-            try {
-                probeActiveDevices();
-            } catch (RuntimeException e) {
-                log.error("Exception thrown during alarm synchronization process", e);
-            }
-        }
-    }
-
-    private void probeActiveDevices() {
-        Iterable<Device> devices = deviceService.getAvailableDevices();
-        log.info("Refresh alarms for all available devices={} ...", devices);
-        for (Device d : devices) {
-            log.info("Lets tell alarm provider to refresh alarms for {} ...", d.id());
-            alarmProvider.triggerProbe(d.id());
-        }
-    }
-
-    @Deactivate
-    public void deactivate(ComponentContext context) {
-        log.info("Deactivate ...");
-        alarmProvider.removeAlarmListener(alarmListener);
-
-        if (alarmPollExecutor != null) {
-            alarmPollExecutor.shutdownNow();
-        }
-        alarms.clear();
-        log.info("Stopped");
-    }
-
-    @Modified
-    public boolean modified(ComponentContext context) {
-        log.info("context={}", context);
-        if (context == null) {
-            log.info("No configuration file");
-            return false;
-        }
-        Dictionary<?, ?> properties = context.getProperties();
-        String clearedAlarmPurgeSeconds = get(properties, "clearedAlarmPurgeSeconds");
-
-        log.info("Settings: clearedAlarmPurgeSeconds={}", clearedAlarmPurgeSeconds);
-
-        return true;
+    @Override
+    protected AlarmProviderService createProviderService(AlarmProvider provider) {
+        return new InternalAlarmProviderService(provider);
     }
 
     // Synchronised to prevent duplicate NE alarms being raised
-    synchronized void updateAlarms(Set<Alarm> discoveredSet, DeviceId deviceId) {
+    protected synchronized void updateAlarms(DeviceId deviceId, Set<Alarm> discoveredSet) {
         Set<Alarm> storedSet = getActiveAlarms(deviceId);
         log.trace("currentNeAlarms={}. discoveredAlarms={}", storedSet, discoveredSet);
 
@@ -324,16 +198,31 @@
 
         storedSet.stream().filter(
                 (stored) -> (!discoveredSet.contains(stored))).forEach((stored) -> {
-                    log.info("Alarm will be cleared as it is not on the element. Cleared alarm: {}.", stored);
-                    clear(stored.id());
-                });
+            log.debug("Alarm will be cleared as it is not on the element. Cleared alarm: {}.", stored);
+            clear(stored.id());
+        });
 
         discoveredSet.stream().filter(
                 (discovered) -> (!storedSet.contains(discovered))).forEach((discovered) -> {
-            log.info("Alarm will be raised as it is missing. New alarm: {}.", discovered);
+            log.info("New alarm raised as it is missing. New alarm: {}.", discovered);
             AlarmId id = generateAlarmId();
             alarms.put(id, new DefaultAlarm.Builder(discovered).withId(id).build());
         });
     }
 
+    private class InternalAlarmProviderService
+            extends AbstractProviderService<AlarmProvider>
+            implements AlarmProviderService {
+
+        InternalAlarmProviderService(AlarmProvider provider) {
+            super(provider);
+
+
+        }
+
+        @Override
+        public void updateAlarmList(DeviceId deviceId, Collection<Alarm> alarms) {
+            updateAlarms(deviceId, ImmutableSet.copyOf(alarms));
+        }
+    }
 }
diff --git a/apps/faultmanagement/fmmgr/src/test/java/org/onosproject/faultmanagement/impl/AlarmsManagerTest.java b/apps/faultmanagement/fmmgr/src/test/java/org/onosproject/faultmanagement/impl/AlarmsManagerTest.java
index e943c56..7bc1b77 100644
--- a/apps/faultmanagement/fmmgr/src/test/java/org/onosproject/faultmanagement/impl/AlarmsManagerTest.java
+++ b/apps/faultmanagement/fmmgr/src/test/java/org/onosproject/faultmanagement/impl/AlarmsManagerTest.java
@@ -15,100 +15,32 @@
  */
 package org.onosproject.faultmanagement.impl;
 
-import com.google.common.collect.Sets;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
+import com.google.common.collect.ImmutableSet;
+import org.junit.Before;
+import org.junit.Rule;
 import org.junit.Test;
-import static org.junit.Assert.*;
+import org.junit.rules.ExpectedException;
 import org.onlab.util.ItemNotFoundException;
-import org.onosproject.net.DeviceId;
-import static org.hamcrest.Matchers.containsString;
 import org.onosproject.incubator.net.faultmanagement.alarm.Alarm;
-import static org.onosproject.incubator.net.faultmanagement.alarm.Alarm.SeverityLevel.*;
 import org.onosproject.incubator.net.faultmanagement.alarm.AlarmEntityId;
 import org.onosproject.incubator.net.faultmanagement.alarm.AlarmId;
 import org.onosproject.incubator.net.faultmanagement.alarm.DefaultAlarm;
+import org.onosproject.net.DeviceId;
 
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.onosproject.incubator.net.faultmanagement.alarm.Alarm.SeverityLevel.CLEARED;
+import static org.onosproject.incubator.net.faultmanagement.alarm.Alarm.SeverityLevel.CRITICAL;
+
+/**
+ * Alarm manager test suite.
+ */
 public class AlarmsManagerTest {
 
-    @Test
-    public void testGettersWhenNoAlarms() {
-        AlarmsManager am = new AlarmsManager();
-        assertTrue("No alarms", am.getAlarms().isEmpty());
-        assertTrue("No active alarms", am.getActiveAlarms().isEmpty());
-        assertTrue("No alarms gives empty map per unknown device", am.getAlarmCounts(DeviceId.NONE).keySet().isEmpty());
-        assertTrue("No alarms gives empty map", am.getAlarmCounts().keySet().isEmpty());
-
-        assertEquals("Zero alarms for that device", 0, am.getAlarms(DeviceId.NONE).size());
-        assertEquals("Zero major alarms", 0, am.getAlarms(Alarm.SeverityLevel.MAJOR).size());
-
-        try {
-            assertEquals("no alarms", 0, am.getAlarm(null));
-        } catch (NullPointerException ex) {
-            assertThat(ex.getMessage(),
-                    containsString("cannot be null"));
-        }
-
-        try {
-            assertEquals("no alarms", 0, am.getAlarm(AlarmId.alarmId(1)));
-        } catch (ItemNotFoundException ex) {
-            assertThat(ex.getMessage(),
-                    containsString("not found"));
-        }
-    }
-
-    @Test
-    public void testAlarmUpdates() {
-        AlarmsManager am = new AlarmsManager();
-        assertTrue("no alarms", am.getAlarms().isEmpty());
-
-        am.updateAlarms(new HashSet<>(), DEVICE_ID);
-        assertTrue("still no alarms", am.getAlarms().isEmpty());
-        Map<Alarm.SeverityLevel, Long> zeroAlarms = new CountsMapBuilder().create();
-        assertEquals(zeroAlarms, am.getAlarmCounts());
-        assertEquals(zeroAlarms, am.getAlarmCounts(DEVICE_ID));
-
-        am.updateAlarms(Sets.newHashSet(ALARM_B, ALARM_A), DEVICE_ID);
-        verifyGettingSetsOfAlarms(am, 2, 2);
-        Map<Alarm.SeverityLevel, Long> critical2 = new CountsMapBuilder().with(CRITICAL, 2L).create();
-        assertEquals(critical2, am.getAlarmCounts());
-        assertEquals(critical2, am.getAlarmCounts(DEVICE_ID));
-
-        am.updateAlarms(Sets.newHashSet(ALARM_A), DEVICE_ID);
-        verifyGettingSetsOfAlarms(am, 2, 1);
-        Map<Alarm.SeverityLevel, Long> critical1cleared1 =
-                new CountsMapBuilder().with(CRITICAL, 1L).with(CLEARED, 1L).create();
-        assertEquals(critical1cleared1, am.getAlarmCounts());
-        assertEquals(critical1cleared1, am.getAlarmCounts(DEVICE_ID));
-
-        // No change map when same alarms sent
-        am.updateAlarms(Sets.newHashSet(ALARM_A), DEVICE_ID);
-        verifyGettingSetsOfAlarms(am, 2, 1);
-        assertEquals(critical1cleared1, am.getAlarmCounts());
-        assertEquals(critical1cleared1, am.getAlarmCounts(DEVICE_ID));
-
-        am.updateAlarms(Sets.newHashSet(ALARM_A, ALARM_A_WITHSRC), DEVICE_ID);
-        verifyGettingSetsOfAlarms(am, 3, 2);
-        Map<Alarm.SeverityLevel, Long> critical2cleared1 =
-                new CountsMapBuilder().with(CRITICAL, 2L).with(CLEARED, 1L).create();
-        assertEquals(critical2cleared1, am.getAlarmCounts());
-        assertEquals(critical2cleared1, am.getAlarmCounts(DEVICE_ID));
-
-        am.updateAlarms(Sets.newHashSet(), DEVICE_ID);
-        verifyGettingSetsOfAlarms(am, 3, 0);
-        assertEquals(new CountsMapBuilder().with(CLEARED, 3L).create(), am.getAlarmCounts(DEVICE_ID));
-
-        assertEquals("No alarms for unknown devices", zeroAlarms, am.getAlarmCounts(DeviceId.NONE));
-        assertEquals("No alarms for unknown devices", zeroAlarms, am.getAlarmCounts(DeviceId.deviceId("junk:junk")));
-
-    }
-
-    private void verifyGettingSetsOfAlarms(AlarmsManager am, int expectedTotal, int expectedActive) {
-        assertEquals("Wrong total", expectedTotal, am.getAlarms().size());
-        assertEquals("Wrong active count", expectedActive, am.getActiveAlarms().size());
-    }
     private static final DeviceId DEVICE_ID = DeviceId.deviceId("foo:bar");
     private static final DefaultAlarm ALARM_A = new DefaultAlarm.Builder(
             DEVICE_ID, "aaa", Alarm.SeverityLevel.CRITICAL, 0).build();
@@ -119,6 +51,101 @@
     private static final DefaultAlarm ALARM_B = new DefaultAlarm.Builder(
             DEVICE_ID, "bbb", Alarm.SeverityLevel.CRITICAL, 0).build();
 
+    private AlarmsManager am;
+
+    @Rule
+    public final ExpectedException exception = ExpectedException.none();
+
+    @Before
+    public void setUp() throws Exception {
+        am = new AlarmsManager();
+    }
+
+    @Test
+    public void deactivate() throws Exception {
+        am.updateAlarms(DEVICE_ID, ImmutableSet.of(ALARM_B, ALARM_A));
+        verifyGettingSetsOfAlarms(am, 2, 2);
+        am.deactivate(null);
+        assertEquals("Alarms should be purged", 0, am.alarms.size());
+    }
+
+    @Test
+    public void testGettersWhenNoAlarms() {
+
+        assertTrue("No alarms should be present", am.getAlarms().isEmpty());
+        assertTrue("No active alarms should be present", am.getActiveAlarms().isEmpty());
+        assertTrue("The map should be empty per unknown device",
+                   am.getAlarmCounts(DeviceId.NONE).keySet().isEmpty());
+        assertTrue("The counts should be empty", am.getAlarmCounts().keySet().isEmpty());
+
+        assertEquals("Incorrect number of alarms for unknown device",
+                     0, am.getAlarms(DeviceId.NONE).size());
+        assertEquals("Incorrect number of major alarms for unknown device",
+                     0, am.getAlarms(Alarm.SeverityLevel.MAJOR).size());
+
+        exception.expect(NullPointerException.class);
+        am.getAlarm(null);
+
+        exception.expect(ItemNotFoundException.class);
+        am.getAlarm(AlarmId.alarmId(1));
+    }
+
+    @Test
+    public void testAlarmUpdates() {
+
+        assertTrue("No alarms should be present", am.getAlarms().isEmpty());
+        am.updateAlarms(DEVICE_ID, ImmutableSet.of());
+        assertTrue("No alarms should be present", am.getAlarms().isEmpty());
+        Map<Alarm.SeverityLevel, Long> zeroAlarms = new CountsMapBuilder().create();
+        assertEquals("No alarms count should be present", zeroAlarms, am.getAlarmCounts());
+        assertEquals("No alarms count should be present", zeroAlarms, am.getAlarmCounts(DEVICE_ID));
+
+        am.updateAlarms(DEVICE_ID, ImmutableSet.of(ALARM_B, ALARM_A));
+        verifyGettingSetsOfAlarms(am, 2, 2);
+        Map<Alarm.SeverityLevel, Long> critical2 = new CountsMapBuilder().with(CRITICAL, 2L).create();
+        assertEquals("A critical should be present", critical2, am.getAlarmCounts());
+        assertEquals("A critical should be present", critical2, am.getAlarmCounts(DEVICE_ID));
+
+        am.updateAlarms(DEVICE_ID, ImmutableSet.of(ALARM_A));
+        verifyGettingSetsOfAlarms(am, 2, 1);
+        Map<Alarm.SeverityLevel, Long> critical1cleared1 =
+                new CountsMapBuilder().with(CRITICAL, 1L).with(CLEARED, 1L).create();
+        assertEquals("A critical should be present and cleared", critical1cleared1,
+                     am.getAlarmCounts());
+        assertEquals("A critical should be present and cleared", critical1cleared1,
+                     am.getAlarmCounts(DEVICE_ID));
+
+        // No change map when same alarms sent
+        am.updateAlarms(DEVICE_ID, ImmutableSet.of(ALARM_A));
+        verifyGettingSetsOfAlarms(am, 2, 1);
+        assertEquals("Map should not be changed for same alarm", critical1cleared1,
+                     am.getAlarmCounts());
+        assertEquals("Map should not be changed for same alarm", critical1cleared1,
+                     am.getAlarmCounts(DEVICE_ID));
+
+        am.updateAlarms(DEVICE_ID, ImmutableSet.of(ALARM_A, ALARM_A_WITHSRC));
+        verifyGettingSetsOfAlarms(am, 3, 2);
+        Map<Alarm.SeverityLevel, Long> critical2cleared1 =
+                new CountsMapBuilder().with(CRITICAL, 2L).with(CLEARED, 1L).create();
+        assertEquals("A critical should be present", critical2cleared1, am.getAlarmCounts());
+        assertEquals("A critical should be present", critical2cleared1, am.getAlarmCounts(DEVICE_ID));
+
+        am.updateAlarms(DEVICE_ID, ImmutableSet.of());
+        verifyGettingSetsOfAlarms(am, 3, 0);
+        assertEquals(new CountsMapBuilder().with(CLEARED, 3L).create(), am.getAlarmCounts(DEVICE_ID));
+
+        assertEquals("The counts should be empty for unknown devices", zeroAlarms,
+                     am.getAlarmCounts(DeviceId.NONE));
+        assertEquals("The counts should be empty for unknown devices", zeroAlarms,
+                     am.getAlarmCounts(DeviceId.deviceId("junk:junk")));
+
+    }
+
+    private void verifyGettingSetsOfAlarms(AlarmsManager am, int expectedTotal, int expectedActive) {
+        assertEquals("Incorrect total alarms", expectedTotal, am.getAlarms().size());
+        assertEquals("Incorrect active alarms count", expectedActive, am.getActiveAlarms().size());
+    }
+
     private static class CountsMapBuilder {
 
         private final Map<Alarm.SeverityLevel, Long> map = new HashMap<>();
diff --git a/apps/faultmanagement/fmweb/src/main/java/org/onosproject/faultmanagement/web/AlarmsWebResource.java b/apps/faultmanagement/fmweb/src/main/java/org/onosproject/faultmanagement/web/AlarmsWebResource.java
index 8c3268c..ef875cd 100644
--- a/apps/faultmanagement/fmweb/src/main/java/org/onosproject/faultmanagement/web/AlarmsWebResource.java
+++ b/apps/faultmanagement/fmweb/src/main/java/org/onosproject/faultmanagement/web/AlarmsWebResource.java
@@ -46,7 +46,7 @@
 @Path("alarms")
 public class AlarmsWebResource extends AbstractWebResource {
 
-    public static final String ALARM_NOT_FOUND = "Alarm is not found";
+    private static final String ALARM_NOT_FOUND = "Alarm is not found";
 
     private final Logger log = getLogger(getClass());
 
@@ -63,7 +63,7 @@
             @DefaultValue("") @QueryParam("devId") String devId
     ) {
 
-        log.info("Requesting all alarms, includeCleared={}", includeCleared);
+        log.debug("Requesting all alarms, includeCleared={}", includeCleared);
         AlarmService service = get(AlarmService.class);
 
         Iterable<Alarm> alarms;
@@ -90,7 +90,7 @@
     @Path("{id}")
     @Produces(MediaType.APPLICATION_JSON)
     public Response getAlarm(@PathParam("id") String id) {
-        log.info("HTTP GET alarm for id={}", id);
+        log.debug("HTTP GET alarm for id={}", id);
 
         AlarmId alarmId = toAlarmId(id);
         Alarm alarm = get(AlarmService.class).getAlarm(alarmId);
@@ -113,11 +113,11 @@
     @Consumes(MediaType.APPLICATION_JSON)
     @Produces(MediaType.APPLICATION_JSON)
     public Response update(@PathParam("alarm_id") String alarmIdPath, InputStream stream) {
-        log.info("PUT NEW ALARM at /{}", alarmIdPath);
+        log.debug("PUT NEW ALARM at /{}", alarmIdPath);
 
         try {
             ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
-            log.info("jsonTree={}", jsonTree);
+            log.debug("jsonTree={}", jsonTree);
 
             Alarm alarm = new AlarmCodec().decode(jsonTree, this);
 
@@ -139,7 +139,7 @@
         }
     }
 
-    private static AlarmId toAlarmId(String id) {
+    private AlarmId toAlarmId(String id) {
         try {
             return AlarmId.alarmId(Long.parseLong(id));
         } catch (NumberFormatException ex) {
diff --git a/drivers/bti/BUCK b/drivers/bti/BUCK
index 166fce9..791f198 100644
--- a/drivers/bti/BUCK
+++ b/drivers/bti/BUCK
@@ -6,6 +6,7 @@
 COMPILE_DEPS = [
     '//lib:CORE_DEPS',
     '//protocols/snmp/api:onos-snmp-api',
+    '//incubator/api:onos-incubator-api',
     '//lib:org.apache.servicemix.bundles.snmp4j',
     '//lib:snmp-core',
     '//lib:bti7000',
diff --git a/providers/snmp/alarm/src/main/java/org/onosproject/provider/snmp/alarm/impl/Bti7000SnmpAlarmProvider.java b/drivers/bti/src/main/java/org/onosproject/drivers/bti/Bti7000SnmpAlarmConsumer.java
similarity index 69%
rename from providers/snmp/alarm/src/main/java/org/onosproject/provider/snmp/alarm/impl/Bti7000SnmpAlarmProvider.java
rename to drivers/bti/src/main/java/org/onosproject/drivers/bti/Bti7000SnmpAlarmConsumer.java
index e444134..2c30915 100644
--- a/providers/snmp/alarm/src/main/java/org/onosproject/provider/snmp/alarm/impl/Bti7000SnmpAlarmProvider.java
+++ b/drivers/bti/src/main/java/org/onosproject/drivers/bti/Bti7000SnmpAlarmConsumer.java
@@ -13,7 +13,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.onosproject.provider.snmp.alarm.impl;
+
+package org.onosproject.drivers.bti;
 
 import com.btisystems.mibbler.mibs.bti7000.bti7000_13_2_0.I_Device;
 import com.btisystems.mibbler.mibs.bti7000.bti7000_13_2_0._OidRegistry;
@@ -23,31 +24,34 @@
 import com.btisystems.pronx.ems.core.model.IClassRegistry;
 import com.btisystems.pronx.ems.core.model.NetworkDevice;
 import com.btisystems.pronx.ems.core.snmp.ISnmpSession;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.TimeZone;
+import com.google.common.collect.ImmutableList;
 import org.apache.commons.lang.StringUtils;
 import org.onosproject.incubator.net.faultmanagement.alarm.Alarm;
+import org.onosproject.incubator.net.faultmanagement.alarm.AlarmConsumer;
 import org.onosproject.incubator.net.faultmanagement.alarm.AlarmEntityId;
 import org.onosproject.incubator.net.faultmanagement.alarm.DefaultAlarm;
 import org.onosproject.net.DeviceId;
+import org.onosproject.net.driver.AbstractHandlerBehaviour;
+import org.onosproject.snmp.SnmpController;
 import org.slf4j.Logger;
-import static org.slf4j.LoggerFactory.getLogger;
-import org.snmp4j.smi.OID;
 import org.snmp4j.smi.OctetString;
 
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.List;
+import java.util.TimeZone;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.slf4j.LoggerFactory.getLogger;
+
 /**
  * BTI 7000 specific implementation to provide a list of current alarms.
- * @deprecated 1.5.0 Falcon, not compliant with ONOS SB and driver architecture.
  */
-@Deprecated
-public class Bti7000SnmpAlarmProvider implements SnmpDeviceAlarmProvider {
+public class Bti7000SnmpAlarmConsumer extends AbstractHandlerBehaviour implements AlarmConsumer {
     private final Logger log = getLogger(getClass());
     protected static final IClassRegistry CLASS_REGISTRY = new ClassRegistry(_OidRegistry.oidRegistry, I_Device.class);
 
@@ -55,40 +59,6 @@
     static final int ALARM_SEVERITY_MAJOR = 3;
     static final int ALARM_SEVERITY_CRITICAL = 4;
 
-    @Override
-    public Collection<Alarm> getAlarms(ISnmpSession session, DeviceId deviceID) {
-        log.info("Getting alarms for BTI 7000 device at {}", deviceID);
-        Set<Alarm> alarms = new HashSet<>();
-        NetworkDevice networkDevice = new NetworkDevice(CLASS_REGISTRY,
-                session.getAddress().getHostAddress());
-
-        try {
-            session.walkDevice(networkDevice, Arrays.asList(
-                    new OID[]{CLASS_REGISTRY.getClassToOidMap().get(ActAlarmTable.class)}));
-
-            IActAlarmTable deviceAlarms = (IActAlarmTable) networkDevice.getRootObject()
-                .getEntity(CLASS_REGISTRY.getClassToOidMap().get(ActAlarmTable.class));
-        if ((deviceAlarms != null) && (deviceAlarms.getActAlarmEntry() != null)
-                && (!deviceAlarms.getActAlarmEntry().isEmpty())) {
-
-            deviceAlarms.getActAlarmEntry().values().stream().forEach((alarm) -> {
-                DefaultAlarm.Builder alarmBuilder = new DefaultAlarm.Builder(
-                        deviceID, alarm.getActAlarmDescription(),
-                        mapAlarmSeverity(alarm.getActAlarmSeverity()),
-                        getLocalDateAndTime(alarm.getActAlarmDateAndTime(), null, null).getTime())
-                        .forSource(AlarmEntityId.alarmEntityId("other:" + alarm.getActAlarmInstanceIdx()));
-                alarms.add(alarmBuilder.build());
-            });
-
-        }
-        log.info("Conditions retrieved: {}", deviceAlarms);
-
-        } catch (IOException ex) {
-            log.error("Error reading alarms for device {}.", deviceID, ex);
-        }
-
-        return alarms;
-    }
 
     private Alarm.SeverityLevel mapAlarmSeverity(int intAlarmSeverity) {
         Alarm.SeverityLevel mappedSeverity;
@@ -108,18 +78,19 @@
         }
         return mappedSeverity;
     }
+
     /**
      * Converts an SNMP string representation into a {@link Date} object,
      * and applies time zone conversion to provide the time on the local machine, ie PSM server.
      *
      * @param actAlarmDateAndTime MIB-II DateAndTime formatted. May optionally contain
-     * a timezone offset in 3 extra bytes
-     * @param sysInfoTimeZone Must be supplied if actAlarmDateAndTime is just local time (with no timezone)
-     * @param swVersion Must be supplied if actAlarmDateAndTime is just local time (with no timezone)
+     *                            a timezone offset in 3 extra bytes
+     * @param sysInfoTimeZone     Must be supplied if actAlarmDateAndTime is just local time (with no timezone)
+     * @param swVersion           Must be supplied if actAlarmDateAndTime is just local time (with no timezone)
      * @return adjusted {@link Date} or a simple conversion if other fields are null.
      */
     public static Date getLocalDateAndTime(String actAlarmDateAndTime, String sysInfoTimeZone,
-            String swVersion) {
+                                           String swVersion) {
         if (StringUtils.isBlank(actAlarmDateAndTime)) {
             return null;
         }
@@ -141,14 +112,13 @@
     /**
      * This method is similar to SNMP4J approach with some fixes for the 11-bytes version (ie the one with timezone
      * offset).
-     *
+     * <p>
      * For original makeCalendar refer @see http://www.snmp4j.org/agent/doc/org/snmp4j/agent/mo/snmp/DateAndTime.html
-     *
+     * <p>
      * Creates a <code>GregorianCalendar</code> from a properly formatted SNMP4J DateAndTime <code>OctetString</code>.
      *
      * @param dateAndTimeValue an OctetString conforming to the DateAndTime TC.
      * @return the corresponding <code>GregorianCalendar</code> instance.
-     *
      */
     public static GregorianCalendar btiMakeCalendar(OctetString dateAndTimeValue) {
         int year = (dateAndTimeValue.get(0) & 0xFF) * 256
@@ -179,4 +149,44 @@
     private static TimeZone getTimeZone() {
         return Calendar.getInstance().getTimeZone();
     }
+
+    @Override
+    public List<Alarm> consumeAlarms() {
+        SnmpController controller = checkNotNull(handler().get(SnmpController.class));
+        ISnmpSession session;
+        List<Alarm> alarms = new ArrayList<>();
+        DeviceId deviceId = handler().data().deviceId();
+        try {
+            session = controller.getSession(deviceId);
+            log.debug("Getting alarms for BTI 7000 device at {}", deviceId);
+            NetworkDevice networkDevice = new NetworkDevice(CLASS_REGISTRY,
+                                                            session.getAddress().getHostAddress());
+            session.walkDevice(networkDevice, Collections.singletonList(
+                    CLASS_REGISTRY.getClassToOidMap().get(ActAlarmTable.class)));
+
+            IActAlarmTable deviceAlarms = (IActAlarmTable) networkDevice.getRootObject()
+                    .getEntity(CLASS_REGISTRY.getClassToOidMap().get(ActAlarmTable.class));
+            if ((deviceAlarms != null) && (deviceAlarms.getActAlarmEntry() != null)
+                    && (!deviceAlarms.getActAlarmEntry().isEmpty())) {
+
+                deviceAlarms.getActAlarmEntry().values().stream().forEach((alarm) -> {
+                    DefaultAlarm.Builder alarmBuilder = new DefaultAlarm.Builder(
+                            deviceId, alarm.getActAlarmDescription(),
+                            mapAlarmSeverity(alarm.getActAlarmSeverity()),
+                            getLocalDateAndTime(alarm.getActAlarmDateAndTime(), null, null).getTime())
+                            .forSource(AlarmEntityId.alarmEntityId("other:" + alarm.getActAlarmInstanceIdx()));
+                    alarms.add(alarmBuilder.build());
+                });
+
+            }
+            log.debug("Conditions retrieved: {}", deviceAlarms);
+
+        } catch (IOException ex) {
+            log.error("Error reading alarms for device {}.", deviceId, ex);
+            alarms.add(controller.buildWalkFailedAlarm(deviceId));
+
+        }
+
+        return ImmutableList.copyOf(alarms);
+    }
 }
diff --git a/drivers/bti/src/main/java/org/onosproject/drivers/bti/NetSnmpAlarmConsumer.java b/drivers/bti/src/main/java/org/onosproject/drivers/bti/NetSnmpAlarmConsumer.java
new file mode 100644
index 0000000..9a5c529
--- /dev/null
+++ b/drivers/bti/src/main/java/org/onosproject/drivers/bti/NetSnmpAlarmConsumer.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2016 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.drivers.bti;
+
+import com.btisystems.mibbler.mibs.netsnmp.netsnmp.I_Device;
+import com.btisystems.mibbler.mibs.netsnmp.netsnmp._OidRegistry;
+import com.btisystems.mibbler.mibs.netsnmp.netsnmp.mib_2.interfaces.IfTable;
+import com.btisystems.pronx.ems.core.model.ClassRegistry;
+import com.btisystems.pronx.ems.core.model.IClassRegistry;
+import com.btisystems.pronx.ems.core.model.NetworkDevice;
+import com.btisystems.pronx.ems.core.snmp.ISnmpSession;
+import com.google.common.collect.ImmutableList;
+import org.onosproject.incubator.net.faultmanagement.alarm.Alarm;
+import org.onosproject.incubator.net.faultmanagement.alarm.AlarmConsumer;
+import org.onosproject.incubator.net.faultmanagement.alarm.AlarmEntityId;
+import org.onosproject.incubator.net.faultmanagement.alarm.DefaultAlarm;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.driver.AbstractHandlerBehaviour;
+import org.onosproject.snmp.SnmpController;
+import org.slf4j.Logger;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * Net SNMP specific implementation to provide a list of current alarms.
+ */
+public class NetSnmpAlarmConsumer extends AbstractHandlerBehaviour implements AlarmConsumer {
+    private final Logger log = getLogger(getClass());
+    protected static final IClassRegistry CLASS_REGISTRY =
+            new ClassRegistry(_OidRegistry.oidRegistry, I_Device.class);
+
+    @Override
+    public List<Alarm> consumeAlarms() {
+        SnmpController controller = checkNotNull(handler().get(SnmpController.class));
+        List<Alarm> alarms = new ArrayList<>();
+        ISnmpSession session;
+        DeviceId deviceId = handler().data().deviceId();
+        try {
+            session = controller.getSession(deviceId);
+
+            NetworkDevice networkDevice = new NetworkDevice(CLASS_REGISTRY,
+                                                            session.getAddress()
+                                                                    .getHostAddress());
+            session.walkDevice(networkDevice, Collections.singletonList(
+                    CLASS_REGISTRY.getClassToOidMap().get(IfTable.class)));
+
+            IfTable interfaceTable = (IfTable) networkDevice.getRootObject()
+                    .getEntity(CLASS_REGISTRY.getClassToOidMap().get(IfTable.class));
+            if (interfaceTable != null) {
+                interfaceTable.getEntries().values().stream().forEach((ifEntry) -> {
+                    if (ifEntry.getIfAdminStatus() == 1 && ifEntry.getIfOperStatus() == 2) {
+                        alarms.add(new DefaultAlarm.Builder(deviceId, "Link Down.",
+                                                            Alarm.SeverityLevel.CRITICAL,
+                                                            System.currentTimeMillis())
+                                           .forSource(AlarmEntityId
+                                                              .alarmEntityId("port:" + ifEntry.
+                                                                      getIfDescr())).build());
+                    }
+                    log.debug("Interface: " + ifEntry);
+                });
+            }
+        } catch (IOException ex) {
+            log.error("Error reading alarms for device {}.", deviceId, ex);
+            alarms.add(controller.buildWalkFailedAlarm(deviceId));
+        }
+        return ImmutableList.copyOf(alarms);
+    }
+}
diff --git a/drivers/bti/src/main/resources/bti-drivers.xml b/drivers/bti/src/main/resources/bti-drivers.xml
index e46ea58..33971c2 100644
--- a/drivers/bti/src/main/resources/bti-drivers.xml
+++ b/drivers/bti/src/main/resources/bti-drivers.xml
@@ -19,10 +19,14 @@
     <driver name="bti7000" manufacturer="bti" hwVersion="1.0.0" swVersion="1.0.0">
         <behaviour api="org.onosproject.net.device.DeviceDescriptionDiscovery"
                    impl="org.onosproject.drivers.bti.Bti7000DeviceDescriptor"/>
+        <behaviour api="org.onosproject.incubator.net.faultmanagement.alarm.AlarmConsumer"
+                   impl="org.onosproject.drivers.bti.Bti7000SnmpAlarmConsumer"/>
     </driver>
     <driver name="NetSnmp" manufacturer="bti" hwVersion="1.0.0" swVersion="1.0.0">
         <behaviour api="org.onosproject.net.device.DeviceDescriptionDiscovery"
                    impl="org.onosproject.drivers.bti.NetSnmpDeviceDescriptor"/>
+        <behaviour api="org.onosproject.incubator.net.faultmanagement.alarm.AlarmConsumer"
+                   impl="org.onosproject.drivers.bti.NetSnmpAlarmConsumer"/>
     </driver>
 </drivers>
 
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmConsumer.java b/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmConsumer.java
new file mode 100644
index 0000000..d417afa
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmConsumer.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2016 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.incubator.net.faultmanagement.alarm;
+
+import org.onosproject.net.driver.HandlerBehaviour;
+
+import java.util.List;
+
+/**
+ * Abstraction of a device behaviour capable of retrieving/consuming list of
+ * pending alarms from the device.
+ */
+public interface AlarmConsumer extends HandlerBehaviour {
+
+    /**
+     * Returns the list of active alarms consumed from the device.
+     * This means that subsequent retrieval of alarms will not contain
+     * any duplicates.
+     *
+     * @return list of alarms consumed from the device
+     */
+    List<Alarm> consumeAlarms();
+
+}
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmProvider.java b/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmProvider.java
index 8ee6f2f..0b5b875 100644
--- a/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmProvider.java
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmProvider.java
@@ -19,30 +19,18 @@
 import org.onosproject.net.provider.Provider;
 
 /**
- * Abstraction of a Alarm provider.
+ * Abstraction of an entity capable of supplying alarms collected from
+ * network devices.
  */
 public interface AlarmProvider extends Provider {
 
     /**
-     * Triggers an asynchronous discovery of the alarms on the specified device, intended to refresh internal alarm
-     * model for the device. An indirect result of this should be a event sent later with discovery result ie a set of
-     * alarms.
+     * Triggers an asynchronous discovery of the alarms on the specified device,
+     * intended to refresh internal alarm model for the device. An indirect
+     * result of this should be a event sent later with discovery result
+     * ie a set of alarms.
      *
      * @param deviceId ID of device to be probed
      */
     void triggerProbe(DeviceId deviceId);
-
-    /**
-     * Register a listener for alarms.
-     *
-     * @param listener the listener to notify
-     */
-    void addAlarmListener(AlarmListener listener);
-
-    /**
-     * Unregister a listener.
-     *
-     * @param listener the listener to unregister
-     */
-    void removeAlarmListener(AlarmListener listener);
 }
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmListener.java b/incubator/api/src/test/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmProviderRegistryAdapter.java
similarity index 60%
rename from incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmListener.java
rename to incubator/api/src/test/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmProviderRegistryAdapter.java
index f09c196..327fd1e 100644
--- a/incubator/api/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmListener.java
+++ b/incubator/api/src/test/java/org/onosproject/incubator/net/faultmanagement/alarm/AlarmProviderRegistryAdapter.java
@@ -13,13 +13,30 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package org.onosproject.incubator.net.faultmanagement.alarm;
 
-import org.onosproject.event.EventListener;
+import org.onosproject.net.provider.ProviderId;
 
+import java.util.Set;
 
 /**
- * Entity capable of receiving Alarm related events.
+ * Adapter for Alarm Provider Registry.
  */
-public interface AlarmListener extends EventListener<AlarmEvent> {
+public class AlarmProviderRegistryAdapter implements AlarmProviderRegistry {
+
+    @Override
+    public AlarmProviderService register(AlarmProvider provider) {
+        return null;
+    }
+
+    @Override
+    public void unregister(AlarmProvider provider) {
+
+    }
+
+    @Override
+    public Set<ProviderId> getProviders() {
+        return null;
+    }
 }
diff --git a/incubator/core/pom.xml b/incubator/core/pom.xml
index 15040e3..8e512c7 100644
--- a/incubator/core/pom.xml
+++ b/incubator/core/pom.xml
@@ -55,7 +55,6 @@
         <dependency>
             <groupId>org.apache.felix</groupId>
             <artifactId>org.apache.felix.scr</artifactId>
-            <version>1.8.2</version>
         </dependency>
         <dependency>
             <groupId>org.osgi</groupId>
@@ -71,5 +70,4 @@
             </plugin>
         </plugins>
     </build>
-
 </project>
diff --git a/incubator/net/BUCK b/incubator/net/BUCK
index 28ee974..02f00bf 100644
--- a/incubator/net/BUCK
+++ b/incubator/net/BUCK
@@ -14,6 +14,9 @@
     '//core/common:onos-core-common-tests',
     '//incubator/store:onos-incubator-store',
     '//core/store/serializers:onos-core-serializers',
+    '//utils/osgi:onlab-osgi',
+    '//utils/osgi:onlab-osgi-tests',
+    '//incubator/api:onos-incubator-api-tests',
 ]
 
 osgi_jar(
diff --git a/incubator/net/pom.xml b/incubator/net/pom.xml
index f93f680..dc63226 100644
--- a/incubator/net/pom.xml
+++ b/incubator/net/pom.xml
@@ -41,6 +41,15 @@
 
         <dependency>
             <groupId>org.onosproject</groupId>
+            <artifactId>onos-incubator-api</artifactId>
+            <version>${project.version}</version>
+            <classifier>tests</classifier>
+            <scope>test</scope>
+        </dependency>
+
+
+        <dependency>
+            <groupId>org.onosproject</groupId>
             <artifactId>onos-core-common</artifactId>
             <version>${project.version}</version>
             <classifier>tests</classifier>
@@ -67,11 +76,6 @@
         </dependency>
 
         <dependency>
-            <groupId>org.apache.felix</groupId>
-            <artifactId>org.apache.felix.scr.annotations</artifactId>
-        </dependency>
-
-        <dependency>
             <groupId>org.apache.karaf.features</groupId>
             <artifactId>org.apache.karaf.features.core</artifactId>
         </dependency>
@@ -87,6 +91,19 @@
             <version>${project.version}</version>
             <scope>test</scope>
         </dependency>
+
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.scr.annotations</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onlab-osgi</artifactId>
+            <version>${project.version}</version>
+            <classifier>tests</classifier>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
     <build>
diff --git a/incubator/net/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/impl/PollingAlarmProvider.java b/incubator/net/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/impl/PollingAlarmProvider.java
new file mode 100644
index 0000000..7f1ee40
--- /dev/null
+++ b/incubator/net/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/impl/PollingAlarmProvider.java
@@ -0,0 +1,229 @@
+/*
+ * Copyright 2016 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.incubator.net.faultmanagement.alarm.impl;
+
+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.Modified;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.onosproject.incubator.net.faultmanagement.alarm.AlarmConsumer;
+import org.onosproject.incubator.net.faultmanagement.alarm.AlarmProvider;
+import org.onosproject.incubator.net.faultmanagement.alarm.AlarmProviderRegistry;
+import org.onosproject.incubator.net.faultmanagement.alarm.AlarmProviderService;
+import org.onosproject.mastership.MastershipEvent;
+import org.onosproject.mastership.MastershipListener;
+import org.onosproject.mastership.MastershipService;
+import org.onosproject.net.Device;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.device.DeviceEvent;
+import org.onosproject.net.device.DeviceListener;
+import org.onosproject.net.device.DeviceService;
+import org.onosproject.net.provider.AbstractProvider;
+import org.onosproject.net.provider.ProviderId;
+import org.osgi.service.component.ComponentContext;
+import org.slf4j.Logger;
+
+import java.util.Dictionary;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.TimeUnit;
+
+import static com.google.common.base.Strings.isNullOrEmpty;
+import static org.onlab.util.Tools.get;
+import static org.onlab.util.Tools.groupedThreads;
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * Alarm provider capable of polling the environment using the device driver
+ * {@link AlarmConsumer} behaviour.
+ */
+@Component(immediate = true)
+public class PollingAlarmProvider extends AbstractProvider implements AlarmProvider {
+
+    private final Logger log = getLogger(getClass());
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected DeviceService deviceService;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected MastershipService mastershipService;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected AlarmProviderRegistry providerRegistry;
+
+    protected AlarmProviderService providerService;
+
+    protected ScheduledExecutorService alarmsExecutor;
+
+    private ScheduledFuture<?> scheduledTask;
+
+    private ExecutorService eventHandlingExecutor;
+
+    protected final MastershipListener mastershipListener = new InternalMastershipListener();
+
+    protected final DeviceListener deviceListener = new InternalDeviceListener();
+
+    private static final int CORE_POOL_SIZE = 10;
+
+    private static final int DEFAULT_POLL_FREQUENCY_SECONDS = 60;
+    @Property(name = "alarmPollFrequencySeconds", intValue = DEFAULT_POLL_FREQUENCY_SECONDS,
+            label = "Frequency (in seconds) for polling alarm from devices")
+    protected int alarmPollFrequencySeconds = DEFAULT_POLL_FREQUENCY_SECONDS;
+
+    // TODO implement purging of old alarms.
+    private static final int DEFAULT_CLEAR_FREQUENCY_SECONDS = 500;
+    @Property(name = "clearedAlarmPurgeSeconds", intValue = DEFAULT_CLEAR_FREQUENCY_SECONDS,
+            label = "Frequency (in seconds) for deleting cleared alarms")
+    private int clearedAlarmPurgeFrequencySeconds = DEFAULT_CLEAR_FREQUENCY_SECONDS;
+
+    public PollingAlarmProvider() {
+        super(new ProviderId("default", "org.onosproject.core"));
+    }
+
+    @Activate
+    public void activate(ComponentContext context) {
+        alarmsExecutor = Executors.newScheduledThreadPool(CORE_POOL_SIZE);
+        eventHandlingExecutor =
+                Executors.newFixedThreadPool(CORE_POOL_SIZE,
+                                             groupedThreads("onos/pollingalarmprovider",
+                                                            "device-installer-%d", log));
+
+        providerService = providerRegistry.register(this);
+
+        deviceService.addListener(deviceListener);
+        mastershipService.addListener(mastershipListener);
+
+        if (context == null) {
+            alarmPollFrequencySeconds = DEFAULT_POLL_FREQUENCY_SECONDS;
+            log.info("No component configuration");
+        } else {
+            Dictionary<?, ?> properties = context.getProperties();
+            alarmPollFrequencySeconds = getNewPollFrequency(properties, alarmPollFrequencySeconds);
+        }
+        scheduledTask = schedulePolling();
+        log.info("Started");
+    }
+
+    @Deactivate
+    public void deactivate() {
+        providerRegistry.unregister(this);
+        mastershipService.removeListener(mastershipListener);
+        deviceService.removeListener(deviceListener);
+        alarmsExecutor.shutdown();
+        providerService = null;
+        log.info("Stopped");
+    }
+
+    @Modified
+    public void modified(ComponentContext context) {
+        if (context == null) {
+            log.info("No component configuration");
+            return;
+        }
+
+        Dictionary<?, ?> properties = context.getProperties();
+        int newPollFrequency = getNewPollFrequency(properties, alarmPollFrequencySeconds);
+        if (newPollFrequency != alarmPollFrequencySeconds) {
+            alarmPollFrequencySeconds = newPollFrequency;
+            //stops the old scheduled task
+            scheduledTask.cancel(true);
+            //schedules new task at the new polling rate
+            scheduledTask = schedulePolling();
+        }
+    }
+
+    private ScheduledFuture schedulePolling() {
+        return alarmsExecutor.scheduleAtFixedRate(this::consumeAlarms,
+                                                  alarmPollFrequencySeconds / 4, alarmPollFrequencySeconds,
+                                                  TimeUnit.SECONDS);
+    }
+
+    private int getNewPollFrequency(Dictionary<?, ?> properties, int pollFrequency) {
+        int newPollFrequency;
+        try {
+            String s = get(properties, "pollFrequency");
+            newPollFrequency = isNullOrEmpty(s) ? pollFrequency : Integer.parseInt(s.trim());
+        } catch (NumberFormatException | ClassCastException e) {
+            newPollFrequency = DEFAULT_POLL_FREQUENCY_SECONDS;
+        }
+        return newPollFrequency;
+    }
+
+    @Override
+    public void triggerProbe(DeviceId deviceId) {
+        if (mastershipService.isLocalMaster(deviceId)) {
+            triggerProbe(deviceService.getDevice(deviceId));
+        }
+    }
+
+    private void triggerProbe(Device device) {
+        alarmsExecutor.submit(() -> consumeAlarms(device));
+    }
+
+    private void consumeAlarms() {
+        deviceService.getAvailableDevices().forEach(device -> {
+            if (mastershipService.isLocalMaster(device.id())) {
+                consumeAlarms(device);
+            }
+        });
+    }
+
+    private void consumeAlarms(Device device) {
+        if (device.is(AlarmConsumer.class)) {
+            providerService.updateAlarmList(device.id(),
+                                            device.as(AlarmConsumer.class).consumeAlarms());
+        } else {
+            log.info("Device {} does not support alarm consumer behaviour", device.id());
+        }
+    }
+
+    private class InternalMastershipListener implements MastershipListener {
+
+        @Override
+        public boolean isRelevant(MastershipEvent event) {
+            return mastershipService.isLocalMaster(event.subject());
+        }
+
+        @Override
+        public void event(MastershipEvent event) {
+            triggerProbe(event.subject());
+        }
+    }
+
+    /**
+     * Internal listener for device service events.
+     */
+    private class InternalDeviceListener implements DeviceListener {
+
+        @Override
+        public boolean isRelevant(DeviceEvent event) {
+            return event.type().equals(DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED)
+                    && deviceService.isAvailable(event.subject().id());
+        }
+
+        @Override
+        public void event(DeviceEvent event) {
+            log.debug("InternalDeviceListener has got event from device-service{} with ", event);
+            eventHandlingExecutor.execute(() -> triggerProbe(event.subject().id()));
+        }
+
+    }
+}
diff --git a/providers/snmp/alarm/src/main/java/org/onosproject/provider/snmp/alarm/impl/package-info.java b/incubator/net/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/impl/package-info.java
similarity index 73%
rename from providers/snmp/alarm/src/main/java/org/onosproject/provider/snmp/alarm/impl/package-info.java
rename to incubator/net/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/impl/package-info.java
index bbad1e7..168e055 100644
--- a/providers/snmp/alarm/src/main/java/org/onosproject/provider/snmp/alarm/impl/package-info.java
+++ b/incubator/net/src/main/java/org/onosproject/incubator/net/faultmanagement/alarm/impl/package-info.java
@@ -1,9 +1,5 @@
 /*
-<<<<<<< HEAD
  * Copyright 2015-present Open Networking Laboratory
-=======
- * Copyright 2015-present Open Networking Laboratory
->>>>>>> master
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,8 +13,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 /**
- * Provider that will support SNMP alarm discoveries.
+ * Abstractions for interacting with alarms. An alarm is a persistent indication
+ * of a fault that clears only when the triggering condition has been resolved.
  */
-package org.onosproject.provider.snmp.alarm.impl;
+package org.onosproject.incubator.net.faultmanagement.alarm.impl;
diff --git a/incubator/net/src/test/java/org/onosproject/incubator/net/faultmanagement/alarm/impl/PollingAlarmProviderTest.java b/incubator/net/src/test/java/org/onosproject/incubator/net/faultmanagement/alarm/impl/PollingAlarmProviderTest.java
new file mode 100644
index 0000000..82108c7
--- /dev/null
+++ b/incubator/net/src/test/java/org/onosproject/incubator/net/faultmanagement/alarm/impl/PollingAlarmProviderTest.java
@@ -0,0 +1,365 @@
+/*
+ * Copyright 2016 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.incubator.net.faultmanagement.alarm.impl;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import org.junit.Before;
+import org.junit.Test;
+import org.onlab.osgi.ComponentContextAdapter;
+import org.onlab.packet.ChassisId;
+import org.onosproject.cluster.NodeId;
+import org.onosproject.cluster.RoleInfo;
+import org.onosproject.incubator.net.faultmanagement.alarm.Alarm;
+import org.onosproject.incubator.net.faultmanagement.alarm.AlarmConsumer;
+import org.onosproject.incubator.net.faultmanagement.alarm.AlarmProvider;
+import org.onosproject.incubator.net.faultmanagement.alarm.AlarmProviderRegistry;
+import org.onosproject.incubator.net.faultmanagement.alarm.AlarmProviderRegistryAdapter;
+import org.onosproject.incubator.net.faultmanagement.alarm.AlarmProviderService;
+import org.onosproject.incubator.net.faultmanagement.alarm.DefaultAlarm;
+import org.onosproject.mastership.MastershipEvent;
+import org.onosproject.mastership.MastershipListener;
+import org.onosproject.mastership.MastershipService;
+import org.onosproject.mastership.MastershipServiceAdapter;
+import org.onosproject.net.AbstractProjectableModel;
+import org.onosproject.net.Annotations;
+import org.onosproject.net.DefaultAnnotations;
+import org.onosproject.net.DefaultDevice;
+import org.onosproject.net.Device;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.device.DeviceEvent;
+import org.onosproject.net.device.DeviceListener;
+import org.onosproject.net.device.DeviceService;
+import org.onosproject.net.device.DeviceServiceAdapter;
+import org.onosproject.net.driver.AbstractHandlerBehaviour;
+import org.onosproject.net.driver.Behaviour;
+import org.onosproject.net.driver.Driver;
+import org.onosproject.net.driver.DriverAdapter;
+import org.onosproject.net.driver.DriverHandler;
+import org.onosproject.net.driver.DriverServiceAdapter;
+import org.onosproject.net.provider.ProviderId;
+import org.osgi.service.component.ComponentContext;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import static org.junit.Assert.*;
+import static org.onlab.junit.TestTools.assertAfter;
+
+/**
+ * Test for the polling alarm provider based on the driver subsystem.
+ */
+public class PollingAlarmProviderTest {
+
+    private final DeviceService deviceService = new MockDeviceService();
+
+    private final MastershipService mastershipService = new MockMastershipService();
+
+    private final AlarmProviderRegistry providerRegistry = new MockDeviceProviderRegistry();
+
+    private final AlarmProviderService alarmProviderService = new MockAlarmProviderService();
+
+    private final ComponentContext context = new MockComponentContext();
+
+    private static final DeviceId DEVICE_ID = DeviceId.deviceId("foo:1.1.1.1:1");
+
+    private Device device = new MockDevice(ProviderId.NONE, DEVICE_ID, Device.Type.OTHER,
+                                           "foo.inc", "0", "0", "0", null,
+                                           DefaultAnnotations.builder().build());
+
+    private final NodeId nodeId = NodeId.nodeId("fooNode");
+
+    private final MastershipEvent mastershipEvent =
+            new MastershipEvent(MastershipEvent.Type.MASTER_CHANGED, DEVICE_ID,
+                                new RoleInfo(nodeId, ImmutableList.of()));
+
+    private final DeviceEvent deviceEvent =
+            new DeviceEvent(DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED, device);
+
+
+    private static final DefaultAlarm ALARM = new DefaultAlarm.Builder(
+            DEVICE_ID, "aaa", Alarm.SeverityLevel.CRITICAL, 0).build();
+
+    private final Driver driver = new MockDriver();
+
+    private PollingAlarmProvider provider = new PollingAlarmProvider();
+    private Set<DeviceListener> deviceListeners = new HashSet<>();
+    private Set<MastershipListener> mastershipListeners = new HashSet<>();
+    private HashMap<DeviceId, Collection<Alarm>> alarmStore = new HashMap<>();
+
+    @Before
+    public void setUp() {
+        provider.providerRegistry = providerRegistry;
+        provider.deviceService = deviceService;
+        provider.mastershipService = mastershipService;
+        AbstractProjectableModel.setDriverService(null, new DriverServiceAdapter());
+        provider.activate(context);
+    }
+
+    @Test
+    public void activate() throws Exception {
+        assertFalse("Provider should be registered", providerRegistry.getProviders().contains(provider));
+        assertEquals("Device listener should be added", 1, deviceListeners.size());
+        assertEquals("Incorrect alarm provider service", alarmProviderService, provider.providerService);
+        assertEquals("Mastership listener should be added", 1, mastershipListeners.size());
+        assertEquals("Incorrect polling frequency", 1, provider.alarmPollFrequencySeconds);
+        assertFalse("Executor should be running", provider.alarmsExecutor.isShutdown());
+        provider.activate(null);
+        assertEquals("Incorrect polling frequency, should be default", 60, provider.alarmPollFrequencySeconds);
+    }
+
+    @Test
+    public void deactivate() throws Exception {
+        provider.deactivate();
+        assertEquals("Device listener should be removed", 0, deviceListeners.size());
+        assertEquals("Mastership listener should be removed", 0, mastershipListeners.size());
+        assertFalse("Provider should not be registered", providerRegistry.getProviders().contains(provider));
+        assertTrue(provider.alarmsExecutor.isShutdown());
+        assertNull(provider.providerService);
+    }
+
+    @Test
+    public void modified() throws Exception {
+        provider.modified(null);
+        assertEquals("Incorrect polling frequency", 1, provider.alarmPollFrequencySeconds);
+        provider.activate(null);
+        provider.modified(context);
+        assertEquals("Incorrect polling frequency", 1, provider.alarmPollFrequencySeconds);
+    }
+
+    @Test
+    public void alarmsPresent() throws IOException {
+        assertAfter(1100, () -> {
+            assertTrue("Alarms should be added", alarmStore.containsKey(DEVICE_ID));
+            assertTrue("Alarms should be added", alarmStore.get(DEVICE_ID).contains(ALARM));
+        });
+    }
+
+    @Test
+    public void mastershipListenerEvent() throws Exception {
+        assertTrue("Incorrect relevant event", provider.mastershipListener
+                .isRelevant(mastershipEvent));
+        provider.mastershipListener.event(mastershipEvent);
+        assertAfter(1100, () -> {
+            assertTrue("Alarms should be added", alarmStore.containsKey(DEVICE_ID));
+        });
+    }
+
+    @Test
+    public void deviceListenerEvent() throws Exception {
+        assertTrue("Incorrect relevant event", provider.deviceListener
+                .isRelevant(deviceEvent));
+        provider.deviceListener.event(deviceEvent);
+        assertAfter(1100, () -> {
+            assertTrue("Alarms should be added", alarmStore.containsKey(DEVICE_ID));
+        });
+    }
+
+    //TODO add test for modified context and event handling form device listener.
+
+    private class MockDeviceService extends DeviceServiceAdapter {
+
+        @Override
+        public Device getDevice(DeviceId did) {
+            if (did.equals(DEVICE_ID)) {
+                return device;
+            }
+            return null;
+        }
+
+        @Override
+        public Iterable<Device> getAvailableDevices() {
+            return ImmutableSet.of(device);
+        }
+
+        @Override
+        public boolean isAvailable(DeviceId did) {
+            return did.equals(DEVICE_ID);
+        }
+
+        @Override
+        public void addListener(DeviceListener listener) {
+            deviceListeners.add(listener);
+        }
+
+        @Override
+        public void removeListener(DeviceListener listener) {
+            deviceListeners.remove(listener);
+        }
+    }
+
+    private class MockMastershipService extends MastershipServiceAdapter {
+
+        @Override
+        public boolean isLocalMaster(DeviceId deviceId) {
+            return true;
+        }
+
+        @Override
+        public void addListener(MastershipListener listener) {
+            mastershipListeners.add(listener);
+        }
+
+        @Override
+        public void removeListener(MastershipListener listener) {
+            mastershipListeners.remove(listener);
+        }
+    }
+
+    private class MockDeviceProviderRegistry extends AlarmProviderRegistryAdapter {
+
+        Set<ProviderId> providers = new HashSet<>();
+
+        @Override
+        public AlarmProviderService register(AlarmProvider provider) {
+            return alarmProviderService;
+        }
+
+        @Override
+        public void unregister(AlarmProvider provider) {
+            providers.remove(provider.id());
+        }
+
+        @Override
+        public Set<ProviderId> getProviders() {
+            return providers;
+        }
+
+    }
+
+    private class MockAlarmProviderService implements AlarmProviderService {
+
+        @Override
+        public void updateAlarmList(DeviceId deviceId, Collection<Alarm> alarms) {
+            if (alarmStore.containsKey(deviceId)) {
+                Collection<Alarm> deviceAlarms = alarmStore.get(deviceId);
+                deviceAlarms.addAll(alarms);
+                alarmStore.put(deviceId, deviceAlarms);
+            } else {
+                alarmStore.put(deviceId, alarms);
+            }
+
+        }
+
+        @Override
+        public AlarmProvider provider() {
+            return null;
+        }
+    }
+
+    private class MockComponentContext extends ComponentContextAdapter {
+        @Override
+        public Dictionary getProperties() {
+            return new MockDictionary();
+        }
+    }
+
+    private class MockDictionary extends Dictionary {
+
+        @Override
+        public int size() {
+            return 0;
+        }
+
+        @Override
+        public boolean isEmpty() {
+            return false;
+        }
+
+        @Override
+        public Enumeration keys() {
+            return null;
+        }
+
+        @Override
+        public Enumeration elements() {
+            return null;
+        }
+
+        @Override
+        public Object get(Object key) {
+            if (key.equals("pollFrequency")) {
+                return "1";
+            }
+            return null;
+        }
+
+        @Override
+        public Object put(Object key, Object value) {
+            return null;
+        }
+
+        @Override
+        public Object remove(Object key) {
+            return null;
+        }
+    }
+
+    private class MockDevice extends DefaultDevice {
+        /**
+         * Creates a network element attributed to the specified provider.
+         *
+         * @param providerId   identity of the provider
+         * @param id           device identifier
+         * @param type         device type
+         * @param manufacturer device manufacturer
+         * @param hwVersion    device HW version
+         * @param swVersion    device SW version
+         * @param serialNumber device serial number
+         * @param chassisId    chassis id
+         * @param annotations  optional key/value annotations
+         */
+        public MockDevice(ProviderId providerId, DeviceId id, Type type,
+                          String manufacturer, String hwVersion, String swVersion,
+                          String serialNumber, ChassisId chassisId, Annotations... annotations) {
+            super(providerId, id, type, manufacturer, hwVersion, swVersion, serialNumber,
+                  chassisId, annotations);
+        }
+
+        @Override
+        protected Driver locateDriver() {
+            return driver;
+        }
+
+        @Override
+        public Driver driver() {
+            return driver;
+        }
+    }
+
+    private class MockDriver extends DriverAdapter {
+        @Override
+        public <T extends Behaviour> T createBehaviour(DriverHandler handler, Class<T> behaviourClass) {
+            return (T) new TestAlarmConsumer();
+        }
+    }
+
+    private class TestAlarmConsumer extends AbstractHandlerBehaviour implements AlarmConsumer {
+
+        @Override
+        public List<Alarm> consumeAlarms() {
+            return ImmutableList.of(ALARM);
+        }
+    }
+
+}
diff --git a/incubator/pom.xml b/incubator/pom.xml
index 435af3c..2fd2b64 100644
--- a/incubator/pom.xml
+++ b/incubator/pom.xml
@@ -77,7 +77,6 @@
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
             </plugin>
-
             <plugin>
                 <groupId>org.onosproject</groupId>
                 <artifactId>onos-maven-plugin</artifactId>
diff --git a/incubator/store/pom.xml b/incubator/store/pom.xml
index ca7655b..614ca72 100644
--- a/incubator/store/pom.xml
+++ b/incubator/store/pom.xml
@@ -83,7 +83,6 @@
         </dependency>
     </dependencies>
 
-
     <build>
         <plugins>
             <plugin>
@@ -92,5 +91,4 @@
             </plugin>
         </plugins>
     </build>
-
 </project>
diff --git a/providers/snmp/alarm/BUCK b/providers/snmp/alarm/BUCK
deleted file mode 100644
index 7217309..0000000
--- a/providers/snmp/alarm/BUCK
+++ /dev/null
@@ -1,36 +0,0 @@
-SRC = 'src/main/java/org/onosproject/**/'
-TEST = 'src/test/java/org/onosproject/**/'
-
-CURRENT_NAME = 'onos-snmp-provider-alarm'
-CURRENT_TARGET = ':' + CURRENT_NAME
-
-COMPILE_DEPS = [
-    '//lib:CORE_DEPS',
-    '//lib:org.apache.servicemix.bundles.snmp4j',
-    '//lib:snmp-core',
-    '//lib:bti7000',
-    '//lib:mibs-net-snmp',
-    '//lib:mibs-rfc',
-    '//incubator/api:onos-incubator-api',
-    '//protocols/snmp/api:onos-snmp-api',
-]
-
-TEST_DEPS = [
-    '//lib:TEST',
-]
-
-osgi_jar(
-    name = CURRENT_NAME,
-    srcs = glob([SRC + '/*.java']),
-    deps = COMPILE_DEPS,
-    visibility = ['PUBLIC'],
-)
-
-java_test(
-    name = 'tests',
-    srcs = glob([TEST + '/*.java']),
-    deps = COMPILE_DEPS +
-           TEST_DEPS +
-           [CURRENT_TARGET],
-    source_under_test = [CURRENT_TARGET],
-)
diff --git a/providers/snmp/app/app.xml b/providers/snmp/app/app.xml
index a680546..dbd5388 100644
--- a/providers/snmp/app/app.xml
+++ b/providers/snmp/app/app.xml
@@ -20,7 +20,6 @@
      features="${project.artifactId}">
     <description>${project.description}</description>
     <artifact>mvn:${project.groupId}/onos-snmp-provider-device/${project.version}</artifact>
-    <artifact>mvn:${project.groupId}/onos-snmp-provider-alarm/${project.version}</artifact>
 
     <artifact>mvn:${project.groupId}/onos-snmp-api/${project.version}</artifact>
     <artifact>mvn:${project.groupId}/onos-snmp-ctl/${project.version}</artifact>
diff --git a/providers/snmp/app/features.xml b/providers/snmp/app/features.xml
index 20245a9..7398624 100644
--- a/providers/snmp/app/features.xml
+++ b/providers/snmp/app/features.xml
@@ -22,7 +22,6 @@
         <bundle>mvn:${project.groupId}/onos-snmp-api/${project.version}</bundle>
         <bundle>mvn:${project.groupId}/onos-snmp-ctl/${project.version}</bundle>
         <bundle>mvn:${project.groupId}/onos-snmp-provider-device/${project.version}</bundle>
-        <bundle>mvn:${project.groupId}/onos-snmp-provider-alarm/${project.version}</bundle>
 
         <bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.snmp4j/2.3.4_1</bundle>
         <bundle>mvn:com.btisystems/snmp-core/1.3-SNAPSHOT</bundle>
diff --git a/providers/snmp/app/pom.xml b/providers/snmp/app/pom.xml
index 5598c49..fc90e08 100644
--- a/providers/snmp/app/pom.xml
+++ b/providers/snmp/app/pom.xml
@@ -37,11 +37,6 @@
             <artifactId>onos-snmp-provider-device</artifactId>
             <version>${project.version}</version>
         </dependency>
-        <dependency>
-            <groupId>org.onosproject</groupId>
-            <artifactId>onos-snmp-provider-alarm</artifactId>
-            <version>${project.version}</version>
-        </dependency>
     </dependencies>
 
 </project>
diff --git a/providers/snmp/device/pom.xml b/providers/snmp/device/pom.xml
index 86d077c..9e69cd0 100644
--- a/providers/snmp/device/pom.xml
+++ b/providers/snmp/device/pom.xml
@@ -77,12 +77,12 @@
         <dependency>
             <groupId>org.onosproject</groupId>
             <artifactId>onos-core-net</artifactId>
-            <version>1.6.0-SNAPSHOT</version>
+            <version>${project.version}</version>
         </dependency>
         <dependency>
             <groupId>org.onosproject</groupId>
             <artifactId>onos-api</artifactId>
-            <version>1.6.0-SNAPSHOT</version>
+            <version>${project.version}</version>
             <classifier>tests</classifier>
             <scope>test</scope>
         </dependency>
@@ -96,4 +96,3 @@
         </plugins>
     </build>
 </project>
-   
diff --git a/providers/snmp/device/src/main/test/org/onosproject/provider/snmp/device/impl/SnmpDeviceProviderTest.java b/providers/snmp/device/src/main/test/org/onosproject/provider/snmp/device/impl/SnmpDeviceProviderTest.java
index b49b80e..ac7e2e0 100644
--- a/providers/snmp/device/src/main/test/org/onosproject/provider/snmp/device/impl/SnmpDeviceProviderTest.java
+++ b/providers/snmp/device/src/main/test/org/onosproject/provider/snmp/device/impl/SnmpDeviceProviderTest.java
@@ -48,7 +48,6 @@
 import org.onosproject.net.device.DeviceServiceAdapter;
 import org.onosproject.net.device.DeviceStore;
 import org.onosproject.net.device.DeviceStoreAdapter;
-import org.onosproject.net.driver.DriverService;
 import org.onosproject.net.driver.DriverServiceAdapter;
 import org.onosproject.net.provider.ProviderId;
 import org.onosproject.snmp.SnmpController;
diff --git a/providers/snmp/pom.xml b/providers/snmp/pom.xml
index 1fc946d..c1038e7 100644
--- a/providers/snmp/pom.xml
+++ b/providers/snmp/pom.xml
@@ -34,7 +34,6 @@
     <modules>
         <module>device</module>
         <module>app</module>
-        <module>alarm</module>
     </modules>
 
     <repositories>