[ONOS-3943] SNMP protocol and provider refactoring according to ONOS architecture

Change-Id: Ie87ee6c181c9550ffac602397f2ee74a691bbdfa
diff --git a/protocols/snmp/api/BUCK b/protocols/snmp/api/BUCK
new file mode 100644
index 0000000..d2e504b
--- /dev/null
+++ b/protocols/snmp/api/BUCK
@@ -0,0 +1,21 @@
+SRC = 'src/main/java/org/onosproject/**/'
+
+CURRENT_NAME = 'onos-snmp-api'
+CURRENT_TARGET = ':' + CURRENT_NAME
+
+COMPILE_DEPS = [
+    '//lib:CORE_DEPS',
+    '//incubator/api:onos-incubator-api',
+    '//lib:org.apache.servicemix.bundles.snmp4j',
+    '//lib:snmp-core',
+    '//lib:bti7000',
+    '//lib:mibs-net-snmp',
+    '//lib:mibs-rfc',
+]
+
+java_library(
+    name = CURRENT_NAME,
+    srcs = glob([SRC + '/*.java']),
+    deps = COMPILE_DEPS,
+    visibility = ['PUBLIC'],
+)
diff --git a/protocols/snmp/api/pom.xml b/protocols/snmp/api/pom.xml
new file mode 100644
index 0000000..cb3dbdb
--- /dev/null
+++ b/protocols/snmp/api/pom.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>onos-snmp-protocol</artifactId>
+        <groupId>org.onosproject</groupId>
+        <version>1.6.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>onos-snmp-api</artifactId>
+    <packaging>bundle</packaging>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-incubator-api</artifactId>
+            <version>1.6.0-SNAPSHOT</version>
+        </dependency>
+    </dependencies>
+
+
+</project>
\ No newline at end of file
diff --git a/protocols/snmp/api/src/main/java/org/onosproject/snmp/SnmpController.java b/protocols/snmp/api/src/main/java/org/onosproject/snmp/SnmpController.java
new file mode 100644
index 0000000..d730107
--- /dev/null
+++ b/protocols/snmp/api/src/main/java/org/onosproject/snmp/SnmpController.java
@@ -0,0 +1,73 @@
+/*
+ * 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.snmp;
+
+import com.btisystems.pronx.ems.core.snmp.ISnmpSession;
+import org.onosproject.incubator.net.faultmanagement.alarm.DefaultAlarm;
+import org.onosproject.net.DeviceId;
+
+import java.io.IOException;
+import java.util.Collection;
+
+/**
+ * Snmp Controller.
+ */
+public interface SnmpController {
+
+    /**
+     * Return all the devices that this controller has notion of.
+     * @return Set of all Snmp devices
+     */
+    Collection<SnmpDevice> getDevices();
+
+    /**
+     * Gets a device for a specific deviceId.
+     * @param deviceId device id of the device
+     * @return SnmpDevice for given deviceId
+     */
+    SnmpDevice getDevice(DeviceId deviceId);
+
+    /**
+     * Removes a specific device.
+     * @param deviceId device id of the device to be removed
+     */
+    void removeDevice(DeviceId deviceId);
+
+    /**
+     * Add a device with a specific DeviceId.
+     * @param deviceId deviceId of the device
+     * @param device device to add to this controller
+     */
+    void addDevice(DeviceId deviceId, SnmpDevice device);
+
+    /**
+     * Gets an Instance of ISnmpSession for a specific device.
+     *
+     * @param deviceId device to retrieve the session for.
+     * @return ISnmp session.
+     * @throws IOException if the session can't be established.
+     */
+    ISnmpSession getSession(DeviceId deviceId) throws IOException;
+
+    /**
+     * Creates an error alarm if the interaction with the device failed.
+     *
+     * @param deviceId the device with a failed interaction
+     * @return default alarm error
+     */
+    DefaultAlarm buildWalkFailedAlarm(DeviceId deviceId);
+}
diff --git a/protocols/snmp/api/src/main/java/org/onosproject/snmp/SnmpDevice.java b/protocols/snmp/api/src/main/java/org/onosproject/snmp/SnmpDevice.java
new file mode 100644
index 0000000..f8876c3
--- /dev/null
+++ b/protocols/snmp/api/src/main/java/org/onosproject/snmp/SnmpDevice.java
@@ -0,0 +1,79 @@
+/*
+ * 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.snmp;
+
+import org.onosproject.net.DeviceId;
+
+/**
+ * Abstraction a default Snmp Device.
+ */
+public interface SnmpDevice {
+
+    /**
+     * Returns host IP and host Port, used by this particular SNMP Device.
+     *
+     * @return Device Information.
+     */
+    String deviceInfo();
+
+    /**
+     * Terminates the device connection.
+     */
+    void disconnect();
+
+    /**
+     * Retrieves the device state.
+     *
+     * @return true if connected
+     */
+    boolean isReachable();
+
+    /**
+     * Returns the IP used connect ssh on the device.
+     *
+     * @return SNMP Device IP
+     */
+    String getSnmpHost();
+
+    /**
+     * Returns the SSH Port used connect the device.
+     *
+     * @return SSH Port number
+     */
+    int getSnmpPort();
+
+    /**
+     * Retrieves the username of the device.
+     *
+     * @return username
+     */
+    String getUsername();
+
+    /**
+     * Retrieves the community (password) of the device.
+     *
+     * @return password
+     */
+    String getCommunity();
+
+    /**
+     * Return the SNMP device deviceID.
+     *
+     * @return DeviceId
+     */
+    DeviceId deviceId();
+}
diff --git a/protocols/snmp/api/src/main/java/org/onosproject/snmp/package-info.java b/protocols/snmp/api/src/main/java/org/onosproject/snmp/package-info.java
new file mode 100644
index 0000000..5a4afb2
--- /dev/null
+++ b/protocols/snmp/api/src/main/java/org/onosproject/snmp/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * 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 for SNMP apis interfaces.
+ */
+package org.onosproject.snmp;