[ONOS-3943] SNMP protocol and provider refactoring according to ONOS architecture
Change-Id: Ie87ee6c181c9550ffac602397f2ee74a691bbdfa
diff --git a/drivers/bti/BUCK b/drivers/bti/BUCK
new file mode 100644
index 0000000..a9a69f3
--- /dev/null
+++ b/drivers/bti/BUCK
@@ -0,0 +1,19 @@
+SRC = 'src/main/java/org/onosproject/**/'
+
+CURRENT_NAME = 'onos-drivers-bti'
+CURRENT_TARGET = ':' + CURRENT_NAME
+
+COMPILE_DEPS = [
+ '//lib:CORE_DEPS',
+ '//protocols/netconf/api:onos-snmp-api',
+ '//incubator/api:onos-incubator-api'
+]
+
+java_library(
+ name = CURRENT_NAME,
+ srcs = glob([SRC + '/*.java']),
+ deps = COMPILE_DEPS,
+ visibility = ['PUBLIC'],
+ resources_root = 'src/main/resources',
+ resources = glob(['src/main/resources/**']),
+)
diff --git a/drivers/bti/features.xml b/drivers/bti/features.xml
new file mode 100644
index 0000000..25f1595
--- /dev/null
+++ b/drivers/bti/features.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+
+<!--
+ ~ 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.
+ -->
+<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" name="${project.artifactId}-${project.version}">
+ <feature name="${project.artifactId}" version="${project.version}"
+ description="${project.description}">
+ <feature>onos-api</feature>
+
+ <bundle>mvn:${project.groupId}/${project.artifactId}/${project.version}</bundle>
+
+ <bundle>mvn:${project.groupId}/onos-snmp-api/${project.version}</bundle>
+
+ <bundle>mvn:${project.groupId}/onos-incubator-api/${project.version}</bundle>
+
+ </feature>
+</features>
diff --git a/drivers/bti/pom.xml b/drivers/bti/pom.xml
new file mode 100644
index 0000000..42502c3
--- /dev/null
+++ b/drivers/bti/pom.xml
@@ -0,0 +1,55 @@
+<?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-drivers-general</artifactId>
+ <groupId>org.onosproject</groupId>
+ <version>1.6.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>onos-drivers-bti</artifactId>
+ <packaging>bundle</packaging>
+
+ <properties>
+ <onos.app.name>org.onosproject.drivers.bti</onos.app.name>
+ <onos.app.origin>ON.Lab</onos.app.origin>
+ <onos.app.category>Drivers</onos.app.category>
+ <onos.app.title>Bti Device Drivers</onos.app.title>
+ <onos.app.url>http://onosproject.org</onos.app.url>
+ <onos.app.requires>
+ org.onosproject.snmp
+ </onos.app.requires>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-snmp-api</artifactId>
+ <version>1.6.0-SNAPSHOT</version>
+ </dependency>
+ <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/drivers/bti/src/main/java/org/onosproject/drivers/bti/Bti7000DeviceDescriptor.java b/drivers/bti/src/main/java/org/onosproject/drivers/bti/Bti7000DeviceDescriptor.java
new file mode 100644
index 0000000..15242a4
--- /dev/null
+++ b/drivers/bti/src/main/java/org/onosproject/drivers/bti/Bti7000DeviceDescriptor.java
@@ -0,0 +1,114 @@
+/*
+ * 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.bti7000.bti7000_13_2_0.I_Device;
+import com.btisystems.mibbler.mibs.bti7000.bti7000_13_2_0._OidRegistry;
+import com.btisystems.mibbler.mibs.bti7000.bti7000_13_2_0.mib_2.System;
+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.ISnmpConfiguration;
+import com.btisystems.pronx.ems.core.snmp.ISnmpSession;
+import com.btisystems.pronx.ems.core.snmp.V2cSnmpConfiguration;
+import com.google.common.collect.ImmutableList;
+import org.onosproject.net.Device;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.SparseAnnotations;
+import org.onosproject.net.device.DefaultDeviceDescription;
+import org.onosproject.net.device.DeviceDescription;
+import org.onosproject.net.device.DeviceDescriptionDiscovery;
+import org.onosproject.net.device.DeviceService;
+import org.onosproject.net.device.PortDescription;
+import org.onosproject.net.driver.AbstractHandlerBehaviour;
+import org.onosproject.snmp.SnmpController;
+import org.onosproject.snmp.SnmpDevice;
+import org.slf4j.Logger;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * Bti 7000 SNMP device description behaviour. Provides device description and port information.
+ */
+public class Bti7000DeviceDescriptor extends AbstractHandlerBehaviour implements DeviceDescriptionDiscovery {
+
+ private final Logger log = getLogger(getClass());
+ protected static final IClassRegistry CLASS_REGISTRY =
+ new ClassRegistry(_OidRegistry.oidRegistry, I_Device.class);
+ private static final String UNKNOWN = "unknown";
+
+ @Override
+ public DeviceDescription discoverDeviceDetails() {
+ SnmpController controller = checkNotNull(handler().get(SnmpController.class));
+ DeviceId deviceId = handler().data().deviceId();
+ SnmpDevice snmpDevice = controller.getDevice(deviceId);
+ DeviceService deviceService = checkNotNull(handler().get(DeviceService.class));
+ Device device = deviceService.getDevice(deviceId);
+ DeviceDescription desc = null;
+ String ipAddress = snmpDevice.getSnmpHost();
+ int port = snmpDevice.getSnmpPort();
+
+ ISnmpConfiguration config = new V2cSnmpConfiguration();
+ config.setPort(port);
+
+ try (ISnmpSession session = controller.getSession(deviceId)) {
+ // Each session will be auto-closed.
+ String deviceOid = session.identifyDevice();
+ desc = populateDescription(session, device);
+
+ } catch (IOException | RuntimeException ex) {
+ log.error("Failed to walk device.", ex.getMessage());
+ log.debug("Detailed problem was ", ex);
+ }
+ return desc;
+ }
+
+ @Override
+ public List<PortDescription> discoverPortDetails() {
+ //TODO implement
+ return ImmutableList.of();
+ }
+
+ private DeviceDescription populateDescription(ISnmpSession session, Device device) {
+ NetworkDevice networkDevice = new NetworkDevice(CLASS_REGISTRY,
+ session.getAddress().getHostAddress());
+ try {
+ session.walkDevice(networkDevice, Collections.singletonList(CLASS_REGISTRY.getClassToOidMap().get(
+ System.class)));
+
+ com.btisystems.mibbler.mibs.bti7000.bti7000_13_2_0.mib_2.System systemTree =
+ (com.btisystems.mibbler.mibs.bti7000.bti7000_13_2_0.mib_2.System)
+ networkDevice.getRootObject().getEntity(CLASS_REGISTRY.getClassToOidMap().get(
+ com.btisystems.mibbler.mibs.bti7000.bti7000_13_2_0.mib_2.System.class));
+ if (systemTree != null) {
+ String[] systemComponents = systemTree.getSysDescr().split(";");
+ return new DefaultDeviceDescription(device.id().uri(), device.type(),
+ systemComponents[0], systemComponents[2],
+ systemComponents[3], UNKNOWN, device.chassisId(),
+ (SparseAnnotations) device.annotations());
+ }
+ } catch (IOException ex) {
+ throw new IllegalArgumentException("Error reading details for device." + session.getAddress(), ex);
+ }
+ return null;
+ }
+}
diff --git a/drivers/bti/src/main/java/org/onosproject/drivers/bti/BtiDriversLoader.java b/drivers/bti/src/main/java/org/onosproject/drivers/bti/BtiDriversLoader.java
new file mode 100644
index 0000000..60b9275
--- /dev/null
+++ b/drivers/bti/src/main/java/org/onosproject/drivers/bti/BtiDriversLoader.java
@@ -0,0 +1,31 @@
+/*
+ * 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 org.apache.felix.scr.annotations.Component;
+import org.onosproject.net.driver.AbstractDriverLoader;
+
+/**
+ * Loader for BTI device drivers.
+ */
+@Component(immediate = true)
+public class BtiDriversLoader extends AbstractDriverLoader {
+
+ public BtiDriversLoader() {
+ super("/bti-drivers.xml");
+ }
+}
diff --git a/drivers/bti/src/main/java/org/onosproject/drivers/bti/NetSnmpDeviceDescriptor.java b/drivers/bti/src/main/java/org/onosproject/drivers/bti/NetSnmpDeviceDescriptor.java
new file mode 100644
index 0000000..ab0b659
--- /dev/null
+++ b/drivers/bti/src/main/java/org/onosproject/drivers/bti/NetSnmpDeviceDescriptor.java
@@ -0,0 +1,119 @@
+/*
+ * 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.System;
+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.ISnmpConfiguration;
+import com.btisystems.pronx.ems.core.snmp.ISnmpSession;
+import com.btisystems.pronx.ems.core.snmp.V2cSnmpConfiguration;
+import com.google.common.collect.ImmutableList;
+import org.apache.commons.lang.StringUtils;
+import org.onosproject.net.Device;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.SparseAnnotations;
+import org.onosproject.net.device.DefaultDeviceDescription;
+import org.onosproject.net.device.DeviceDescription;
+import org.onosproject.net.device.DeviceDescriptionDiscovery;
+import org.onosproject.net.device.DeviceService;
+import org.onosproject.net.device.PortDescription;
+import org.onosproject.net.driver.AbstractHandlerBehaviour;
+import org.onosproject.snmp.SnmpController;
+import org.onosproject.snmp.SnmpDevice;
+import org.slf4j.Logger;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * Net SNMP device description behaviour. Provides device description and port information.
+ */
+public class NetSnmpDeviceDescriptor extends AbstractHandlerBehaviour implements DeviceDescriptionDiscovery {
+ private final Logger log = getLogger(getClass());
+ protected static final IClassRegistry CLASS_REGISTRY =
+ new ClassRegistry(_OidRegistry.oidRegistry, I_Device.class);
+ private static final String UNKNOWN = "unknown";
+
+
+ //TODO evaluate a common abstract class for all Snmp description discovery
+ @Override
+ public DeviceDescription discoverDeviceDetails() {
+ SnmpController controller = checkNotNull(handler().get(SnmpController.class));
+ DeviceId deviceId = handler().data().deviceId();
+ SnmpDevice snmpDevice = controller.getDevice(deviceId);
+ DeviceService deviceService = checkNotNull(handler().get(DeviceService.class));
+ Device device = deviceService.getDevice(deviceId);
+ DeviceDescription desc = null;
+ String ipAddress = snmpDevice.getSnmpHost();
+ int port = snmpDevice.getSnmpPort();
+
+ ISnmpConfiguration config = new V2cSnmpConfiguration();
+ config.setPort(port);
+
+ try (ISnmpSession session = controller.getSession(deviceId)) {
+ // Each session will be auto-closed.
+ String deviceOid = session.identifyDevice();
+ //TODO obtain desctiption
+ desc = populateDescription(session, device);
+
+ } catch (IOException | RuntimeException ex) {
+ log.error("Failed to walk device.", ex.getMessage());
+ log.debug("Detailed problem was ", ex);
+ }
+
+ return desc;
+ }
+
+ @Override
+ public List<PortDescription> discoverPortDetails() {
+ //TODO implement
+ return ImmutableList.of();
+ }
+
+ private DeviceDescription populateDescription(ISnmpSession session, Device device) {
+ NetworkDevice networkDevice = new NetworkDevice(CLASS_REGISTRY,
+ session.getAddress().getHostAddress());
+ try {
+ session.walkDevice(networkDevice, Collections.singletonList(CLASS_REGISTRY.getClassToOidMap().get(
+ System.class)));
+
+ com.btisystems.mibbler.mibs.netsnmp.netsnmp.mib_2.System systemTree =
+ (com.btisystems.mibbler.mibs.netsnmp.netsnmp.mib_2.System)
+ networkDevice.getRootObject().getEntity(CLASS_REGISTRY.getClassToOidMap().get(
+ com.btisystems.mibbler.mibs.netsnmp.netsnmp.mib_2.System.class));
+ if (systemTree != null) {
+ // TODO SNMP sys-contacts may be verbose; ONOS-GUI doesn't abbreviate fields neatly;
+ // so cut it here until supported in prop displayer
+ String manufacturer = StringUtils.abbreviate(systemTree.getSysContact(), 20);
+ return new DefaultDeviceDescription(device.id().uri(), device.type(),
+ manufacturer, UNKNOWN, UNKNOWN, UNKNOWN,
+ device.chassisId(), (SparseAnnotations) device.annotations());
+ }
+ } catch (IOException ex) {
+ throw new IllegalArgumentException("Error reading details for device." + session.getAddress(), ex);
+ }
+ return null;
+ }
+}
diff --git a/drivers/bti/src/main/java/org/onosproject/drivers/bti/package-info.java b/drivers/bti/src/main/java/org/onosproject/drivers/bti/package-info.java
new file mode 100644
index 0000000..9e6dc6e
--- /dev/null
+++ b/drivers/bti/src/main/java/org/onosproject/drivers/bti/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 BTI device drivers.
+ */
+package org.onosproject.drivers.bti;
\ No newline at end of file
diff --git a/drivers/bti/src/main/resources/bti-drivers.xml b/drivers/bti/src/main/resources/bti-drivers.xml
new file mode 100644
index 0000000..dc0012b
--- /dev/null
+++ b/drivers/bti/src/main/resources/bti-drivers.xml
@@ -0,0 +1,28 @@
+<?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.
+ -->
+<drivers>
+ <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"/>
+ </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"/>
+ </driver>
+</drivers>
+
diff --git a/drivers/lumentum/features.xml b/drivers/lumentum/features.xml
index 17413d9..44abebd 100644
--- a/drivers/lumentum/features.xml
+++ b/drivers/lumentum/features.xml
@@ -20,8 +20,6 @@
<feature>onos-api</feature>
<bundle>mvn:${project.groupId}/${project.artifactId}/${project.version}</bundle>
- <bundle>mvn:${project.groupId}/onos-restsb-api/${project.version}</bundle>
-
<bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.snmp4j/2.3.4_1</bundle>
</feature>
diff --git a/drivers/lumentum/pom.xml b/drivers/lumentum/pom.xml
index 1046b81..33f29fa 100644
--- a/drivers/lumentum/pom.xml
+++ b/drivers/lumentum/pom.xml
@@ -35,6 +35,9 @@
<onos.app.category>Drivers</onos.app.category>
<onos.app.title>Lumentum Device Drivers</onos.app.title>
<onos.app.url>http://onosproject.org</onos.app.url>
+ <onos.app.requires>
+ org.onosproject.snmp
+ </onos.app.requires>
</properties>
<dependencies>
diff --git a/drivers/lumentum/src/main/java/org/onosproject/drivers/lumentum/PortDiscoveryLumentumRoadm.java b/drivers/lumentum/src/main/java/org/onosproject/drivers/lumentum/LumentumRoadmDeviceDescription.java
similarity index 76%
rename from drivers/lumentum/src/main/java/org/onosproject/drivers/lumentum/PortDiscoveryLumentumRoadm.java
rename to drivers/lumentum/src/main/java/org/onosproject/drivers/lumentum/LumentumRoadmDeviceDescription.java
index 9d250c0..4a53502 100644
--- a/drivers/lumentum/src/main/java/org/onosproject/drivers/lumentum/PortDiscoveryLumentumRoadm.java
+++ b/drivers/lumentum/src/main/java/org/onosproject/drivers/lumentum/LumentumRoadmDeviceDescription.java
@@ -19,9 +19,14 @@
import com.google.common.collect.Lists;
import org.onosproject.net.AnnotationKeys;
import org.onosproject.net.DefaultAnnotations;
+import org.onosproject.net.Device;
+import org.onosproject.net.DeviceId;
import org.onosproject.net.PortNumber;
import org.onosproject.net.SparseAnnotations;
-import org.onosproject.net.behaviour.PortDiscovery;
+import org.onosproject.net.device.DefaultDeviceDescription;
+import org.onosproject.net.device.DeviceDescription;
+import org.onosproject.net.device.DeviceDescriptionDiscovery;
+import org.onosproject.net.device.DeviceService;
import org.onosproject.net.device.OmsPortDescription;
import org.onosproject.net.device.PortDescription;
import org.onosproject.net.driver.AbstractHandlerBehaviour;
@@ -34,22 +39,37 @@
import java.util.Collections;
import java.util.List;
+import static com.google.common.base.Preconditions.checkNotNull;
import static org.slf4j.LoggerFactory.getLogger;
/**
- * Discovers the ports of a Lumentum SDN ROADM device using SNMP.
+ * Device description behaviour for Lumentum Snmp devices.
*/
-public class PortDiscoveryLumentumRoadm extends AbstractHandlerBehaviour
- implements PortDiscovery {
+public class LumentumRoadmDeviceDescription extends AbstractHandlerBehaviour implements DeviceDescriptionDiscovery {
- private final Logger log = getLogger(PortDiscoveryLumentumRoadm.class);
+ private final Logger log = getLogger(getClass());
private static final String CTRL_PORT_STATE = ".1.3.6.1.4.1.46184.1.4.1.1.3.";
private LumentumSnmpDevice snmp;
@Override
- public List<PortDescription> getPorts() {
+ public DeviceDescription discoverDeviceDetails() {
+ //TODO get device description
+ DeviceService deviceService = checkNotNull(handler().get(DeviceService.class));
+ DeviceId deviceId = handler().data().deviceId();
+ Device device = deviceService.getDevice(deviceId);
+ return new DefaultDeviceDescription(device.id().uri(), Device.Type.ROADM,
+ "Lumentum", "SDN ROADM", "1.0", "v1",
+ device.chassisId(), (SparseAnnotations) device.annotations());
+ }
+
+ @Override
+ public List<PortDescription> discoverPortDetails() {
+ return this.getPorts();
+ }
+
+ private List<PortDescription> getPorts() {
try {
snmp = new LumentumSnmpDevice(handler().data().deviceId());
} catch (IOException e) {
@@ -119,5 +139,3 @@
return ports;
}
}
-
-
diff --git a/drivers/lumentum/src/main/resources/lumentum-drivers.xml b/drivers/lumentum/src/main/resources/lumentum-drivers.xml
index 0465fe0..a041bee 100644
--- a/drivers/lumentum/src/main/resources/lumentum-drivers.xml
+++ b/drivers/lumentum/src/main/resources/lumentum-drivers.xml
@@ -16,8 +16,8 @@
-->
<drivers>
<driver name="lumentum" manufacturer="Lumentum" hwVersion="SDN ROADM" swVersion="1.0">
- <behaviour api="org.onosproject.net.behaviour.PortDiscovery"
- impl="org.onosproject.drivers.lumentum.PortDiscoveryLumentumRoadm"/>
+ <behaviour api="org.onosproject.net.device.DeviceDescriptionDiscovery"
+ impl="org.onosproject.drivers.lumentum.LumentumRoadmDeviceDescription"/>
<behaviour api="org.onosproject.net.behaviour.LambdaQuery"
impl="org.onosproject.drivers.lumentum.LambdaQueryLumentumRoadm"/>
<behaviour api="org.onosproject.net.flow.FlowRuleProgrammable"
diff --git a/drivers/pom.xml b/drivers/pom.xml
index cdfdb49..1fb64a7 100644
--- a/drivers/pom.xml
+++ b/drivers/pom.xml
@@ -40,6 +40,7 @@
<module>ovsdb</module>
<module>utilities</module>
<module>lumentum</module>
+ <module>bti</module>
</modules>
<!--<properties>
diff --git a/protocols/pom.xml b/protocols/pom.xml
index 12fbc29..85fe571 100644
--- a/protocols/pom.xml
+++ b/protocols/pom.xml
@@ -40,6 +40,7 @@
<module>rest</module>
<module>ospf</module>
<module>isis</module>
+ <module>snmp</module>
</modules>
<dependencies>
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;
diff --git a/protocols/snmp/ctl/BUCK b/protocols/snmp/ctl/BUCK
new file mode 100644
index 0000000..0c83b08
--- /dev/null
+++ b/protocols/snmp/ctl/BUCK
@@ -0,0 +1,35 @@
+SRC = 'src/main/java/org/onosproject/**/'
+TEST = 'src/test/java/org/onosproject/**/'
+CURRENT_NAME = 'onos-snmp-ctl'
+CURRENT_TARGET = ':' + CURRENT_NAME
+
+COMPILE_DEPS = [
+ '//lib:CORE_DEPS',
+ '//incubator/api:onos-incubator-api',
+ '//protocols/snmp/api:onos-snmp-api',
+ '//lib:org.apache.servicemix.bundles.snmp4j',
+ '//lib:snmp-core',
+ '//lib:bti7000',
+ '//lib:mibs-net-snmp',
+ '//lib:mibs-rfc',
+]
+
+TEST_DEPS = [
+ '//lib:TEST',
+]
+
+java_library(
+ 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/protocols/snmp/ctl/pom.xml b/protocols/snmp/ctl/pom.xml
new file mode 100644
index 0000000..fb213d1
--- /dev/null
+++ b/protocols/snmp/ctl/pom.xml
@@ -0,0 +1,54 @@
+<?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>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>onos-snmp-ctl</artifactId>
+ <packaging>bundle</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-snmp-api</artifactId>
+ <version>1.6.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.scr.annotations</artifactId>
+ </dependency>
+
+ <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/ctl/src/main/java/org/onosproject/snmp/ctl/DefaultSnmpController.java b/protocols/snmp/ctl/src/main/java/org/onosproject/snmp/ctl/DefaultSnmpController.java
new file mode 100644
index 0000000..35556cd
--- /dev/null
+++ b/protocols/snmp/ctl/src/main/java/org/onosproject/snmp/ctl/DefaultSnmpController.java
@@ -0,0 +1,129 @@
+/*
+ * 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.ctl;
+
+import com.btisystems.pronx.ems.core.snmp.DefaultSnmpConfigurationFactory;
+import com.btisystems.pronx.ems.core.snmp.ISnmpConfiguration;
+import com.btisystems.pronx.ems.core.snmp.ISnmpSession;
+import com.btisystems.pronx.ems.core.snmp.ISnmpSessionFactory;
+import com.btisystems.pronx.ems.core.snmp.SnmpSessionFactory;
+import com.btisystems.pronx.ems.core.snmp.V2cSnmpConfiguration;
+import com.google.common.base.Preconditions;
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Deactivate;
+import org.apache.felix.scr.annotations.Service;
+import org.onosproject.incubator.net.faultmanagement.alarm.Alarm;
+import org.onosproject.incubator.net.faultmanagement.alarm.DefaultAlarm;
+import org.onosproject.net.DeviceId;
+import org.onosproject.snmp.SnmpController;
+import org.onosproject.snmp.SnmpDevice;
+import org.osgi.service.component.ComponentContext;
+import org.osgi.service.component.annotations.Component;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * Default implementation of the SNMP sub-controller.
+ */
+@Component(immediate = true)
+@Service
+public class DefaultSnmpController implements SnmpController {
+
+ private final Logger log = LoggerFactory
+ .getLogger(getClass());
+
+ private ISnmpSessionFactory sessionFactory;
+
+ private final Map<DeviceId, ISnmpSession> sessionMap = new HashMap<>();
+ protected Map<DeviceId, SnmpDevice> snmpDeviceMap = new ConcurrentHashMap<>();
+
+ @Activate
+ public void activate(ComponentContext context) {
+ sessionFactory = new SnmpSessionFactory(
+ new DefaultSnmpConfigurationFactory(new V2cSnmpConfiguration()));
+ log.info("Started");
+ }
+
+ @Deactivate
+ public void deactivate() {
+ snmpDeviceMap.clear();
+ log.info("Stopped");
+ }
+
+ @Override
+ public ISnmpSession getSession(DeviceId deviceId) throws IOException {
+ if (!sessionMap.containsKey(deviceId)) {
+ SnmpDevice device = snmpDeviceMap.get(deviceId);
+ String ipAddress = null;
+ int port = -1;
+ if (device != null) {
+ ipAddress = device.getSnmpHost();
+ port = device.getSnmpPort();
+ } else {
+ String[] deviceComponents = deviceId.toString().split(":");
+ if (deviceComponents.length > 1) {
+ ipAddress = deviceComponents[1];
+ port = Integer.parseInt(deviceComponents[2]);
+
+ } else {
+ log.error("Cannot obtain correct information from device id", deviceId);
+ }
+ }
+ Preconditions.checkNotNull(ipAddress, "ip address is empty, cannot start session");
+ Preconditions.checkArgument(port != -1, "port is incorrect, cannot start session");
+
+ ISnmpConfiguration config = new V2cSnmpConfiguration();
+ config.setPort(port);
+ sessionMap.put(deviceId, sessionFactory.createSession(config, ipAddress));
+ }
+ return sessionMap.get(deviceId);
+ }
+
+ @Override
+ public Collection<SnmpDevice> getDevices() {
+ return snmpDeviceMap.values();
+ }
+
+ @Override
+ public SnmpDevice getDevice(DeviceId did) {
+ return snmpDeviceMap.get(did);
+ }
+
+ @Override
+ public void removeDevice(DeviceId did) {
+ snmpDeviceMap.remove(did);
+ }
+
+ @Override
+ public void addDevice(DeviceId did, SnmpDevice device) {
+ snmpDeviceMap.put(did, device);
+ }
+
+ @Override
+ public DefaultAlarm buildWalkFailedAlarm(DeviceId deviceId) {
+ return new DefaultAlarm.Builder(
+ deviceId, "SNMP alarm retrieval failed",
+ Alarm.SeverityLevel.CRITICAL,
+ System.currentTimeMillis()).build();
+ }
+}
diff --git a/protocols/snmp/ctl/src/main/java/org/onosproject/snmp/ctl/DefaultSnmpDevice.java b/protocols/snmp/ctl/src/main/java/org/onosproject/snmp/ctl/DefaultSnmpDevice.java
new file mode 100644
index 0000000..a76e86b
--- /dev/null
+++ b/protocols/snmp/ctl/src/main/java/org/onosproject/snmp/ctl/DefaultSnmpDevice.java
@@ -0,0 +1,117 @@
+/*
+ * 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.ctl;
+
+import org.onosproject.net.DeviceId;
+import org.onosproject.snmp.SnmpDevice;
+import org.slf4j.Logger;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * This is a logical representation of actual SNMP device, carrying all the necessary information to connect and execute
+ * SNMP operations.
+ */
+public class DefaultSnmpDevice implements SnmpDevice {
+
+ private final Logger log = getLogger(DefaultSnmpDevice.class);
+
+
+ private static final int DEFAULT_SNMP_PORT = 161;
+
+ private static final String SCHEME = "snmp";
+
+ private final String snmpHost;
+ private final DeviceId deviceId;
+ private int snmpPort = DEFAULT_SNMP_PORT;
+ private final String username;
+ //Community is a conventional name for password in SNMP.
+ private final String community;
+ private boolean reachable = false;
+
+
+ public DefaultSnmpDevice(String snmpHost, int snmpPort, String username, String community) {
+
+ this.snmpHost = checkNotNull(snmpHost, "SNMP Device IP cannot be null");
+ this.snmpPort = checkNotNull(snmpPort, "SNMP Device port cannot be null");
+ this.username = username;
+ this.community = community;
+ this.deviceId = createDeviceId();
+ reachable = true;
+ }
+
+ @Override
+ public String deviceInfo() {
+ return new StringBuilder("host: ").append(snmpHost).append(". port: ")
+ .append(snmpPort).toString();
+ }
+
+ @Override
+ public void disconnect() {
+ log.info("disconnect");
+ reachable = false;
+ }
+
+ @Override
+ public boolean isReachable() {
+ return reachable;
+ }
+
+ @Override
+ public String getSnmpHost() {
+ return snmpHost;
+ }
+
+
+ @Override
+ public int getSnmpPort() {
+ return snmpPort;
+ }
+
+ @Override
+ public String getUsername() {
+ return username;
+ }
+
+ @Override
+ public String getCommunity() {
+ return community;
+ }
+
+ @Override
+ public DeviceId deviceId() {
+ return deviceId;
+ }
+
+ private DeviceId createDeviceId() {
+ String additionalSsp = new StringBuilder(
+ snmpHost).append(":")
+ .append(snmpPort).toString();
+ try {
+ return DeviceId.deviceId(new URI(SCHEME, additionalSsp,
+ null));
+ } catch (URISyntaxException e) {
+ log.error("Syntax Error while creating URI for the device: "
+ + additionalSsp
+ + " couldn't persist the device onto the store", e);
+ throw new IllegalArgumentException("Can't create device ID from " + additionalSsp, e);
+ }
+ }
+}
diff --git a/protocols/snmp/ctl/src/main/java/org/onosproject/snmp/ctl/package-info.java b/protocols/snmp/ctl/src/main/java/org/onosproject/snmp/ctl/package-info.java
new file mode 100644
index 0000000..455a73c
--- /dev/null
+++ b/protocols/snmp/ctl/src/main/java/org/onosproject/snmp/ctl/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 implementation fo SNMP elements.
+ */
+package org.onosproject.snmp.ctl;
diff --git a/protocols/snmp/pom.xml b/protocols/snmp/pom.xml
new file mode 100644
index 0000000..6173d61
--- /dev/null
+++ b/protocols/snmp/pom.xml
@@ -0,0 +1,58 @@
+<?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-protocols</artifactId>
+ <groupId>org.onosproject</groupId>
+ <version>1.6.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>onos-snmp-protocol</artifactId>
+ <packaging>pom</packaging>
+ <modules>
+ <module>api</module>
+ <module>ctl</module>
+ </modules>
+ <dependencies>
+ <dependency>
+ <groupId>com.btisystems</groupId>
+ <artifactId>snmp-core</artifactId>
+ <version>1.3-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>com.btisystems.mibbler.mibs</groupId>
+ <artifactId>bti7000</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>com.btisystems.mibbler.mibs</groupId>
+ <artifactId>net-snmp</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-api</artifactId>
+ <version>1.6.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+
+</project>
\ No newline at end of file
diff --git a/providers/snmp/alarm/BUCK b/providers/snmp/alarm/BUCK
index 6695f13..63f0826 100644
--- a/providers/snmp/alarm/BUCK
+++ b/providers/snmp/alarm/BUCK
@@ -11,9 +11,8 @@
'//lib:bti7000',
'//lib:mibs-net-snmp',
'//lib:mibs-rfc',
- '//protocols/ovsdb/api:onos-ovsdb-api',
- '//protocols/ovsdb/rfc:onos-ovsdb-rfc',
'//incubator/api:onos-incubator-api',
+ '//protocols/snmp/api:onos-snmp-api',
]
TEST_DEPS = [
diff --git a/providers/snmp/app/app.xml b/providers/snmp/app/app.xml
index 625021d..d77b4b2 100644
--- a/providers/snmp/app/app.xml
+++ b/providers/snmp/app/app.xml
@@ -21,4 +21,12 @@
<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>
+
+ <artifact>mvn:com.btisystems/snmp-core/1.3-SNAPSHOT</artifact>
+ <artifact>mvn:com.btisystems.mibbler.mibs/bti7000/1.0-SNAPSHOT</artifact>
+ <artifact>mvn:com.btisystems.mibbler.mibs/net-snmp/1.0-SNAPSHOT</artifact>
+
</app>
diff --git a/providers/snmp/app/features.xml b/providers/snmp/app/features.xml
index b8ab857..6b51e3d 100644
--- a/providers/snmp/app/features.xml
+++ b/providers/snmp/app/features.xml
@@ -19,9 +19,12 @@
description="${project.description}">
<feature>onos-api</feature>
<bundle>mvn:io.netty/netty/3.9.2.Final</bundle>
- <bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.snmp4j/2.3.4_1</bundle>
+ <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>
<bundle>mvn:com.btisystems.mibbler.mibs/bti7000/1.0-SNAPSHOT</bundle>
<bundle>mvn:com.btisystems.mibbler.mibs/net-snmp/1.0-SNAPSHOT</bundle>
diff --git a/providers/snmp/device/BUCK b/providers/snmp/device/BUCK
index 1f05085..749a7e2 100644
--- a/providers/snmp/device/BUCK
+++ b/providers/snmp/device/BUCK
@@ -11,9 +11,9 @@
'//lib:bti7000',
'//lib:mibs-net-snmp',
'//lib:mibs-rfc',
- '//protocols/ovsdb/api:onos-ovsdb-api',
- '//protocols/ovsdb/rfc:onos-ovsdb-rfc',
'//incubator/api:onos-incubator-api',
+ '//protocols/snmp/api:onos-snmp-api',
+ '//protocols/snmp/ctl:onos-snmp-ctl',
]
TEST_DEPS = [
diff --git a/providers/snmp/device/pom.xml b/providers/snmp/device/pom.xml
index c7e043e..bde52f6 100644
--- a/providers/snmp/device/pom.xml
+++ b/providers/snmp/device/pom.xml
@@ -36,20 +36,50 @@
<groupId>org.osgi</groupId>
<artifactId>org.osgi.compendium</artifactId>
</dependency>
- <!-- <dependency>
- <groupId>javax.ws.rs</groupId>
- <artifactId>javax.ws.rs-api</artifactId>
- <version>2.0.1</version>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-snmp-api</artifactId>
+ <version>1.6.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
- <artifactId>onos-incubator-api</artifactId>
+ <artifactId>onos-snmp-ctl</artifactId>
+ <version>1.6.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicemix.bundles</groupId>
+ <artifactId>org.apache.servicemix.bundles.snmp4j</artifactId>
+ <version>2.3.4_1</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>log4j</artifactId>
+ <groupId>log4j</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>com.btisystems</groupId>
+ <artifactId>snmp-core</artifactId>
+ <version>1.3-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.btisystems.mibbler.mibs</groupId>
+ <artifactId>bti7000</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.btisystems.mibbler.mibs</groupId>
+ <artifactId>net-snmp</artifactId>
+ <version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
- <artifactId>onos-core-serializers</artifactId>
- <version>${project.version}</version>
- </dependency>-->
+ <artifactId>onos-core-net</artifactId>
+ <version>1.6.0-SNAPSHOT</version>
+ </dependency>
</dependencies>
<build>
<plugins>
diff --git a/providers/snmp/device/src/main/java/org/onosproject/provider/snmp/device/impl/Bti7000DeviceDescriptionProvider.java b/providers/snmp/device/src/main/java/org/onosproject/provider/snmp/device/impl/Bti7000DeviceDescriptionProvider.java
deleted file mode 100644
index 8726673..0000000
--- a/providers/snmp/device/src/main/java/org/onosproject/provider/snmp/device/impl/Bti7000DeviceDescriptionProvider.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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.provider.snmp.device.impl;
-
-import com.btisystems.mibbler.mibs.bti7000.bti7000_13_2_0.I_Device;
-import com.btisystems.mibbler.mibs.bti7000.bti7000_13_2_0._OidRegistry;
-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 org.onosproject.net.device.DefaultDeviceDescription;
-import org.onosproject.net.device.DeviceDescription;
-import org.slf4j.Logger;
-import org.snmp4j.smi.OID;
-
-import java.io.IOException;
-import java.util.Arrays;
-
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * A vendor-specific implementation supporting BTI Systems BTI-7000 equipment.
- * @deprecated 1.5.0 Falcon, not compliant with ONOS SB and driver architecture.
- */
-@Deprecated
-public class Bti7000DeviceDescriptionProvider implements SnmpDeviceDescriptionProvider {
- private final Logger log = getLogger(getClass());
- protected static final IClassRegistry CLASS_REGISTRY =
- new ClassRegistry(_OidRegistry.oidRegistry, I_Device.class);
- private static final String UNKNOWN = "unknown";
-
- @Override
- public DeviceDescription populateDescription(ISnmpSession session, DeviceDescription description) {
- NetworkDevice networkDevice = new NetworkDevice(CLASS_REGISTRY,
- session.getAddress().getHostAddress());
- try {
- session.walkDevice(networkDevice, Arrays.asList(new OID[]{
- CLASS_REGISTRY.getClassToOidMap().get(
- com.btisystems.mibbler.mibs.bti7000.bti7000_13_2_0.mib_2.System.class)}));
-
- com.btisystems.mibbler.mibs.bti7000.bti7000_13_2_0.mib_2.System systemTree =
- (com.btisystems.mibbler.mibs.bti7000.bti7000_13_2_0.mib_2.System)
- networkDevice.getRootObject().getEntity(CLASS_REGISTRY.getClassToOidMap().get(
- com.btisystems.mibbler.mibs.bti7000.bti7000_13_2_0.mib_2.System.class));
- if (systemTree != null) {
- String[] systemComponents = systemTree.getSysDescr().split(";");
- return new DefaultDeviceDescription(description.deviceUri(), description.type(),
- systemComponents[0], systemComponents[2], systemComponents[3],
- UNKNOWN, description.chassisId(), description.annotations());
- }
- } catch (IOException ex) {
- log.error("Error reading details for device {}.", session.getAddress(), ex);
- }
- return description;
- }
-
-}
diff --git a/providers/snmp/device/src/main/java/org/onosproject/provider/snmp/device/impl/DeviceState.java b/providers/snmp/device/src/main/java/org/onosproject/provider/snmp/device/impl/DeviceState.java
deleted file mode 100644
index e358927..0000000
--- a/providers/snmp/device/src/main/java/org/onosproject/provider/snmp/device/impl/DeviceState.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.provider.snmp.device.impl;
- /**
- * The Device State is used to determine whether the device is active or inactive. This state information will help
- * Device Creator to add or delete the device from the core.
- */
- public enum DeviceState {
- /* Used to specify Active state of the device */
-
- ACTIVE,
- /* Used to specify inactive state of the device */
- INACTIVE,
- /* Used to specify invalid state of the device */
- INVALID
- }
diff --git a/providers/snmp/device/src/main/java/org/onosproject/provider/snmp/device/impl/LumentumDeviceDescriptionProvider.java b/providers/snmp/device/src/main/java/org/onosproject/provider/snmp/device/impl/LumentumDeviceDescriptionProvider.java
deleted file mode 100644
index 70286b6..0000000
--- a/providers/snmp/device/src/main/java/org/onosproject/provider/snmp/device/impl/LumentumDeviceDescriptionProvider.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.provider.snmp.device.impl;
-
-import com.btisystems.pronx.ems.core.snmp.ISnmpSession;
-import org.onosproject.net.Device;
-import org.onosproject.net.device.DefaultDeviceDescription;
-import org.onosproject.net.device.DeviceDescription;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Device description provider for Lumentum SDN ROADMs.
- * @deprecated 1.5.0 Falcon, not compliant with ONOS SB and driver architecture.
- */
-@Deprecated
-public class LumentumDeviceDescriptionProvider implements SnmpDeviceDescriptionProvider {
-
- private static final Logger log = LoggerFactory.getLogger(LumentumDeviceDescriptionProvider.class);
-
- @Override
- public DeviceDescription populateDescription(ISnmpSession session, DeviceDescription description) {
- return new DefaultDeviceDescription(description.deviceUri(), Device.Type.ROADM,
- "Lumentum", "SDN ROADM", "1.0", "v1", description.chassisId(), description.annotations());
- }
-}
diff --git a/providers/snmp/device/src/main/java/org/onosproject/provider/snmp/device/impl/NetSnmpDeviceDescriptionProvider.java b/providers/snmp/device/src/main/java/org/onosproject/provider/snmp/device/impl/NetSnmpDeviceDescriptionProvider.java
deleted file mode 100644
index a84a43c..0000000
--- a/providers/snmp/device/src/main/java/org/onosproject/provider/snmp/device/impl/NetSnmpDeviceDescriptionProvider.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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.provider.snmp.device.impl;
-
-import com.btisystems.mibbler.mibs.netsnmp.netsnmp.I_Device;
-import com.btisystems.mibbler.mibs.netsnmp.netsnmp._OidRegistry;
-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 org.apache.commons.lang.StringUtils;
-import org.onosproject.net.device.DefaultDeviceDescription;
-import org.onosproject.net.device.DeviceDescription;
-import org.slf4j.Logger;
-import org.snmp4j.smi.OID;
-
-import java.io.IOException;
-import java.util.Arrays;
-
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * A agent-specific implementation supporting NET-SNMP agents.
- * @deprecated 1.5.0 Falcon, not compliant with ONOS SB and driver architecture.
- */
-@Deprecated
-public class NetSnmpDeviceDescriptionProvider implements SnmpDeviceDescriptionProvider {
- private final Logger log = getLogger(getClass());
- protected static final IClassRegistry CLASS_REGISTRY =
- new ClassRegistry(_OidRegistry.oidRegistry, I_Device.class);
- private static final String UNKNOWN = "unknown";
-
- @Override
- public DeviceDescription populateDescription(ISnmpSession session, DeviceDescription description) {
- NetworkDevice networkDevice = new NetworkDevice(CLASS_REGISTRY,
- session.getAddress().getHostAddress());
- try {
- session.walkDevice(networkDevice, Arrays.asList(new OID[]{
- CLASS_REGISTRY.getClassToOidMap().get(
- com.btisystems.mibbler.mibs.netsnmp.netsnmp.mib_2.System.class)}));
-
- com.btisystems.mibbler.mibs.netsnmp.netsnmp.mib_2.System systemTree =
- (com.btisystems.mibbler.mibs.netsnmp.netsnmp.mib_2.System)
- networkDevice.getRootObject().getEntity(CLASS_REGISTRY.getClassToOidMap().get(
- com.btisystems.mibbler.mibs.netsnmp.netsnmp.mib_2.System.class));
- if (systemTree != null) {
- // TODO SNMP sys-contacts may be verbose; ONOS-GUI doesn't abbreviate fields neatly;
- // so cut it here until supported in prop displayer
- String manufacturer = StringUtils.abbreviate(systemTree.getSysContact(), 20);
- return new DefaultDeviceDescription(description.deviceUri(), description.type(), manufacturer,
- UNKNOWN, UNKNOWN, UNKNOWN, description.chassisId(), description.annotations());
- }
- } catch (IOException ex) {
- log.error("Error reading details for device {}.", session.getAddress(), ex);
- }
- return description;
- }
-
-}
diff --git a/providers/snmp/device/src/main/java/org/onosproject/provider/snmp/device/impl/SnmpDevice.java b/providers/snmp/device/src/main/java/org/onosproject/provider/snmp/device/impl/SnmpDevice.java
deleted file mode 100644
index 8b385dc..0000000
--- a/providers/snmp/device/src/main/java/org/onosproject/provider/snmp/device/impl/SnmpDevice.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.provider.snmp.device.impl;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.slf4j.LoggerFactory.getLogger;
-
-
-import org.slf4j.Logger;
-
-/**
- * This is a logical representation of actual SNMP device, carrying all the necessary information to connect and execute
- * SNMP operations.
- */
-public class SnmpDevice {
-
- private final Logger log = getLogger(SnmpDevice.class);
-
-
- private static final int DEFAULT_SNMP_PORT = 161;
-
- private final String snmpHost;
- private int snmpPort = DEFAULT_SNMP_PORT;
- private final String community;
- private boolean reachable = false;
-
- private DeviceState deviceState = DeviceState.INVALID;
-
- protected SnmpDevice(String snmpHost, int snmpPort, String community) {
-
- this.snmpHost = checkNotNull(snmpHost, "SNMP Device IP cannot be null");
- this.snmpPort = checkNotNull(snmpPort, "SNMP Device snmp port cannot be null");
- this.community = community;
- }
-
- /**
- * This will try to connect to SNMP device.
- *
- */
- public void init() {
-
- reachable = true;
- }
-
- /**
- * This would return host IP and host Port, used by this particular SNMP Device.
- *
- * @return Device Information.
- */
- public String deviceInfo() {
- return new StringBuilder("host: ").append(snmpHost).append(". port: ")
- .append(snmpPort).toString();
- }
-
- /**
- * This will terminate the device connection.
- */
- public void disconnect() {
- log.info("disconnect");
- reachable = false;
- }
-
- /**
- * This api is intended to know whether the device is connected or not.
- *
- * @return true if connected
- */
- public boolean isReachable() {
- return reachable;
- }
-
- /**
- * This will return the IP used connect ssh on the device.
- *
- * @return SNMP Device IP
- */
- public String getSnmpHost() {
- return snmpHost;
- }
-
- /**
- * This will return the SSH Port used connect the device.
- *
- * @return SSH Port number
- */
- public int getSnmpPort() {
- return snmpPort;
- }
-
- public String getCommunity() {
- return community;
- }
-
- /**
- * Retrieve current state of the device.
- *
- * @return Current Device State
- */
- public DeviceState getDeviceState() {
- return deviceState;
- }
-
- /**
- * This is set the state information for the device.
- *
- * @param deviceState Next Device State
- */
- public void setDeviceState(DeviceState deviceState) {
- this.deviceState = deviceState;
- }
-
- /**
- * Check whether the device is in Active state.
- *
- * @return true if the device is Active
- */
- public boolean isActive() {
- return deviceState == DeviceState.ACTIVE;
- }
-
-}
diff --git a/providers/snmp/device/src/main/java/org/onosproject/provider/snmp/device/impl/SnmpDeviceDescriptionProvider.java b/providers/snmp/device/src/main/java/org/onosproject/provider/snmp/device/impl/SnmpDeviceDescriptionProvider.java
deleted file mode 100644
index 4b8fb34..0000000
--- a/providers/snmp/device/src/main/java/org/onosproject/provider/snmp/device/impl/SnmpDeviceDescriptionProvider.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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.provider.snmp.device.impl;
-
-import com.btisystems.pronx.ems.core.snmp.ISnmpSession;
-import org.onosproject.net.device.DeviceDescription;
-
-/**
- * Abstraction of an entity which updates a device description with information retrieved via SNMP.
- * @deprecated 1.5.0 Falcon, not compliant with ONOS SB and driver architecture.
- */
-@Deprecated
-public interface SnmpDeviceDescriptionProvider {
-
- /**
- * Generated an updated device description.
- * @deprecated 1.5.0 Falcon
- * @param session SNMP session
- * @param description old device description
- * @return new updated description
- */
- @Deprecated
- DeviceDescription populateDescription(ISnmpSession session, DeviceDescription description);
-}
diff --git a/providers/snmp/device/src/main/java/org/onosproject/provider/snmp/device/impl/SnmpDeviceProvider.java b/providers/snmp/device/src/main/java/org/onosproject/provider/snmp/device/impl/SnmpDeviceProvider.java
index c32296c..4cd809b 100644
--- a/providers/snmp/device/src/main/java/org/onosproject/provider/snmp/device/impl/SnmpDeviceProvider.java
+++ b/providers/snmp/device/src/main/java/org/onosproject/provider/snmp/device/impl/SnmpDeviceProvider.java
@@ -15,23 +15,16 @@
*/
package org.onosproject.provider.snmp.device.impl;
-import com.btisystems.pronx.ems.core.snmp.DefaultSnmpConfigurationFactory;
-import com.btisystems.pronx.ems.core.snmp.ISnmpConfiguration;
-import com.btisystems.pronx.ems.core.snmp.ISnmpConfigurationFactory;
-import com.btisystems.pronx.ems.core.snmp.ISnmpSession;
-import com.btisystems.pronx.ems.core.snmp.ISnmpSessionFactory;
-import com.btisystems.pronx.ems.core.snmp.SnmpSessionFactory;
-import com.btisystems.pronx.ems.core.snmp.V2cSnmpConfiguration;
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.onlab.packet.ChassisId;
-import org.onosproject.cfg.ComponentConfigService;
-import org.onosproject.cluster.ClusterService;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.core.CoreService;
+import org.onosproject.incubator.net.config.basics.ConfigException;
import org.onosproject.net.AnnotationKeys;
import org.onosproject.net.DefaultAnnotations;
import org.onosproject.net.Device;
@@ -39,33 +32,32 @@
import org.onosproject.net.MastershipRole;
import org.onosproject.net.PortNumber;
import org.onosproject.net.SparseAnnotations;
-import org.onosproject.net.behaviour.PortDiscovery;
+import org.onosproject.net.config.ConfigFactory;
+import org.onosproject.net.config.NetworkConfigEvent;
+import org.onosproject.net.config.NetworkConfigListener;
+import org.onosproject.net.config.NetworkConfigRegistry;
import org.onosproject.net.device.DefaultDeviceDescription;
import org.onosproject.net.device.DeviceDescription;
+import org.onosproject.net.device.DeviceDescriptionDiscovery;
import org.onosproject.net.device.DeviceProvider;
import org.onosproject.net.device.DeviceProviderRegistry;
import org.onosproject.net.device.DeviceProviderService;
import org.onosproject.net.device.DeviceService;
+import org.onosproject.net.device.DeviceStore;
import org.onosproject.net.provider.AbstractProvider;
import org.onosproject.net.provider.ProviderId;
+import org.onosproject.snmp.SnmpController;
+import org.onosproject.snmp.SnmpDevice;
+import org.onosproject.snmp.ctl.DefaultSnmpDevice;
import org.osgi.service.component.ComponentContext;
import org.slf4j.Logger;
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.Dictionary;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
-import static com.google.common.base.Strings.isNullOrEmpty;
-import static org.onlab.util.Tools.delay;
-import static org.onlab.util.Tools.get;
import static org.onlab.util.Tools.groupedThreads;
+import static org.onosproject.net.config.basics.SubjectFactories.APP_SUBJECT_FACTORY;
import static org.slf4j.LoggerFactory.getLogger;
/**
@@ -79,81 +71,81 @@
private final Logger log = getLogger(SnmpDeviceProvider.class);
private static final String UNKNOWN = "unknown";
-
- protected Map<DeviceId, SnmpDevice> snmpDeviceMap = new ConcurrentHashMap<>();
+ private static final String APP_NAME = "org.onosproject.snmp";
+ private static final String SCHEME = "snmp";
private DeviceProviderService providerService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected SnmpController controller;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected DeviceProviderRegistry providerRegistry;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected DeviceService deviceService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected ClusterService clusterService;
+ protected DeviceStore deviceStore;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected ComponentConfigService cfgService;
+ protected CoreService coreService;
- private final ExecutorService deviceBuilder = Executors
- .newFixedThreadPool(1, groupedThreads("onos/snmp", "device-creator", log));
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected NetworkConfigRegistry netCfgService;
- // Delay between events in ms.
- private static final int EVENTINTERVAL = 5;
+ private final ExecutorService deviceBuilderExecutor = Executors
+ .newFixedThreadPool(5, groupedThreads("onos/snmp", "device-creator", log));
- private static final String SCHEME = "snmp";
+ private final NetworkConfigListener cfgLister = new InternalNetworkConfigListener();
- @Property(name = "devConfigs", value = "", label = "Instance-specific configurations")
- private String devConfigs = null;
+ private ApplicationId appId;
- @Property(name = "devPasswords", value = "", label = "Instance-specific password")
- private String devPasswords = null;
+ private final ConfigFactory factory =
+ new ConfigFactory<ApplicationId, SnmpProviderConfig>(APP_SUBJECT_FACTORY,
+ SnmpProviderConfig.class,
+ "devices",
+ true) {
+ @Override
+ public SnmpProviderConfig createConfig() {
+ return new SnmpProviderConfig();
+ }
+ };
- //TODO Could be replaced with a service lookup, and bundles per device variant.
- Map<String, SnmpDeviceDescriptionProvider> providers = new HashMap<>();
-
- private final ISnmpSessionFactory sessionFactory;
/**
* Creates a provider with the supplier identifier.
*/
public SnmpDeviceProvider() {
super(new ProviderId("snmp", "org.onosproject.provider.device"));
- sessionFactory = new SnmpSessionFactory(
- new DefaultSnmpConfigurationFactory(new V2cSnmpConfiguration()));
- //TODO refactor, no hardcoding in provider, device information should be in drivers
- providers.put("1.3.6.1.4.1.18070.2.2", new Bti7000DeviceDescriptionProvider());
- providers.put("1.3.6.1.4.1.20408", new NetSnmpDeviceDescriptionProvider());
- providers.put("1.3.6.1.4.562.73.6", new LumentumDeviceDescriptionProvider());
+ //FIXME multiple type of SNMP sessions
}
@Activate
public void activate(ComponentContext context) {
- log.info("activating for snmp devices ...");
- cfgService.registerProperties(getClass());
+
providerService = providerRegistry.register(this);
+ appId = coreService.registerApplication(APP_NAME);
+ netCfgService.registerConfigFactory(factory);
+ netCfgService.addListener(cfgLister);
modified(context);
- log.info("activated ok");
+ log.info("Started");
}
@Deactivate
public void deactivate(ComponentContext context) {
- log.info("deactivating for snmp devices ...");
-
- cfgService.unregisterProperties(getClass(), false);
try {
- snmpDeviceMap
- .entrySet().stream().forEach((deviceEntry) -> {
- deviceBuilder.execute(new DeviceCreator(deviceEntry.getValue(), false));
- });
- deviceBuilder.awaitTermination(1000, TimeUnit.MILLISECONDS);
+ controller.getDevices().stream().forEach(device -> {
+ deviceBuilderExecutor.execute(new DeviceFactory(device, false));
+ });
+ deviceBuilderExecutor.awaitTermination(1000, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
log.error("Device builder did not terminate");
}
- deviceBuilder.shutdownNow();
- snmpDeviceMap.clear();
+ deviceBuilderExecutor.shutdownNow();
+ netCfgService.unregisterConfigFactory(factory);
+ netCfgService.removeListener(cfgLister);
providerRegistry.unregister(this);
providerService = null;
log.info("Stopped");
@@ -161,100 +153,36 @@
@Modified
public void modified(ComponentContext context) {
- log.info("modified ...");
-
- if (context == null) {
- log.info("No configuration file");
- return;
- }
- Dictionary<?, ?> properties = context.getProperties();
-
- log.info("properties={}", context.getProperties());
-
- String deviceCfgValue = get(properties, "devConfigs");
- log.info("Settings: devConfigs={}", deviceCfgValue);
- if (!isNullOrEmpty(deviceCfgValue)) {
- addOrRemoveDevicesConfig(deviceCfgValue);
- }
- log.info("... modified");
-
+ log.info("Modified");
}
- private void addOrRemoveDevicesConfig(String deviceConfig) {
- for (String deviceEntry : deviceConfig.split(",")) {
- SnmpDevice device = processDeviceEntry(deviceEntry);
- if (device != null) {
- log.info("Device Detail:host={}, port={}, state={}",
- new Object[]{device.getSnmpHost(),
- device.getSnmpPort(),
- device.getDeviceState().name()}
- );
- if (device.isActive()) {
- deviceBuilder.execute(new DeviceCreator(device, true));
- } else {
- deviceBuilder.execute(new DeviceCreator(device, false));
- }
- }
- }
- }
-
- private SnmpDevice processDeviceEntry(String deviceEntry) {
- if (deviceEntry == null) {
- log.info("No content for Device Entry, so cannot proceed further.");
- return null;
- }
- log.info("Trying to convert {} to a SNMP Device Object", deviceEntry);
- SnmpDevice device = null;
- try {
- String userInfo = deviceEntry.substring(0, deviceEntry
- .lastIndexOf('@'));
- String hostInfo = deviceEntry.substring(deviceEntry
- .lastIndexOf('@') + 1);
- String[] infoSplit = userInfo.split(":");
- String username = infoSplit[0];
- String password = infoSplit[1];
- infoSplit = hostInfo.split(":");
- String hostIp = infoSplit[0];
- Integer hostPort;
+ private void addOrRemoveDevicesConfig() {
+ SnmpProviderConfig cfg = netCfgService.getConfig(appId, SnmpProviderConfig.class);
+ if (cfg != null) {
try {
- hostPort = Integer.parseInt(infoSplit[1]);
- } catch (NumberFormatException nfe) {
- log.error("Bad Configuration Data: Failed to parse host port number string: "
- + infoSplit[1]);
- throw nfe;
+ cfg.getDevicesInfo().stream().forEach(info -> {
+ SnmpDevice device = new DefaultSnmpDevice(info.ip().toString(),
+ info.port(), info.username(), info.password());
+ buildDevice(device);
+ });
+ } catch (ConfigException e) {
+ log.error("Cannot read config error " + e);
}
- String deviceState = infoSplit[2];
- if (isNullOrEmpty(username) || isNullOrEmpty(password)
- || isNullOrEmpty(hostIp) || hostPort == 0) {
- log.warn("Bad Configuration Data: both user and device information parts of Configuration "
- + deviceEntry + " should be non-nullable");
- } else {
- device = new SnmpDevice(hostIp, hostPort, password);
- if (!isNullOrEmpty(deviceState)) {
- if (deviceState.toUpperCase().equals(DeviceState.ACTIVE.name())) {
- device.setDeviceState(DeviceState.ACTIVE);
- } else if (deviceState.toUpperCase()
- .equals(DeviceState.INACTIVE.name())) {
- device.setDeviceState(DeviceState.INACTIVE);
- } else {
- log.warn("Device State Information can not be empty, so marking the state as INVALID");
- device.setDeviceState(DeviceState.INVALID);
- }
- } else {
- log.warn("The device entry do not specify state information, so marking the state as INVALID");
- device.setDeviceState(DeviceState.INVALID);
- }
- }
- } catch (ArrayIndexOutOfBoundsException aie) {
- log.error("Error while reading config infromation from the config file: "
- + "The user, host and device state infomation should be "
- + "in the order 'userInfo@hostInfo:deviceState'"
- + deviceEntry, aie);
- } catch (Exception e) {
- log.error("Error while parsing config information for the device entry: "
- + deviceEntry, e);
}
- return device;
+ }
+
+ private void buildDevice(SnmpDevice device) {
+ if (device != null) {
+ log.debug("Device Detail:host={}, port={}, state={}",
+ device.getSnmpHost(),
+ device.getSnmpPort(),
+ device.isReachable());
+ if (device.isReachable()) {
+ deviceBuilderExecutor.execute(new DeviceFactory(device, true));
+ } else {
+ deviceBuilderExecutor.execute(new DeviceFactory(device, false));
+ }
+ }
}
@Override
@@ -265,16 +193,16 @@
@Override
public void roleChanged(DeviceId deviceId, MastershipRole newRole) {
-
+ // TODO Implement Masterhsip Service
}
@Override
public boolean isReachable(DeviceId deviceId) {
- SnmpDevice snmpDevice = snmpDeviceMap.get(deviceId);
+ SnmpDevice snmpDevice = controller.getDevice(deviceId);
if (snmpDevice == null) {
log.warn("BAD REQUEST: the requested device id: "
- + deviceId.toString()
- + " is not associated to any SNMP Device");
+ + deviceId.toString()
+ + " is not associated to any SNMP Device");
return false;
}
return snmpDevice.isReachable();
@@ -285,12 +213,13 @@
* 'SnmpDevice' content. The functionality runs as a thread and depending on the 'createFlag' value it will create
* or remove Device entry from the core.
*/
- private class DeviceCreator implements Runnable {
+ //FIXME consider rework.
+ private class DeviceFactory implements Runnable {
private SnmpDevice device;
private boolean createFlag;
- public DeviceCreator(SnmpDevice device, boolean createFlag) {
+ public DeviceFactory(SnmpDevice device, boolean createFlag) {
this.device = device;
this.createFlag = createFlag;
}
@@ -298,10 +227,10 @@
@Override
public void run() {
if (createFlag) {
- log.info("Trying to create Device Info on ONOS core");
+ log.debug("Trying to create Device Info on ONOS core");
advertiseDevices();
} else {
- log.info("Trying to remove Device Info on ONOS core");
+ log.debug("Trying to remove Device Info on ONOS core");
removeDevices();
}
}
@@ -314,24 +243,16 @@
log.warn("The Request SNMP Device is null, cannot proceed further");
return;
}
- try {
- DeviceId did = getDeviceId();
- if (!snmpDeviceMap.containsKey(did)) {
- log.error("BAD Request: 'Currently device is not discovered, "
- + "so cannot remove/disconnect the device: "
- + device.deviceInfo() + "'");
- return;
- }
- providerService.deviceDisconnected(did);
- device.disconnect();
- snmpDeviceMap.remove(did);
- delay(EVENTINTERVAL);
- } catch (URISyntaxException uriSyntaxExcpetion) {
- log.error("Syntax Error while creating URI for the device: "
- + device.deviceInfo()
- + " couldn't remove the device from the store",
- uriSyntaxExcpetion);
+ DeviceId did = device.deviceId();
+ if (controller.getDevice(did) == null) {
+ log.error("BAD Request: 'Currently device is not discovered, "
+ + "so cannot remove/disconnect the device: "
+ + device.deviceInfo() + "'");
+ return;
}
+ providerService.deviceDisconnected(did);
+ device.disconnect();
+ controller.removeDevice(did);
}
/**
@@ -343,8 +264,7 @@
log.warn("The Request SNMP Device is null, cannot proceed further");
return;
}
- device.init();
- DeviceId did = getDeviceId();
+ DeviceId did = device.deviceId();
ChassisId cid = new ChassisId();
SparseAnnotations annotations = DefaultAnnotations.builder()
@@ -354,79 +274,46 @@
DeviceDescription desc = new DefaultDeviceDescription(
did.uri(), Device.Type.OTHER, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, cid, annotations);
- desc = populateDescriptionFromDevice(did, desc);
+ log.debug("Persisting Device " + did.uri().toString());
- log.info("Persisting Device " + did.uri().toString());
-
- snmpDeviceMap.put(did, device);
+ controller.addDevice(did, device);
providerService.deviceConnected(did, desc);
- log.info("Done with Device Info Creation on ONOS core. Device Info: "
- + device.deviceInfo() + " " + did.uri().toString());
-
- // Do port discovery if driver supports it
+ log.info("Added device to ONOS core. Device Info: "
+ + device.deviceInfo() + " " + did.uri().toString());
+ //FIXME this description will be populated only if driver is pushed from outside
+ // becuase otherwise default driver is used
Device d = deviceService.getDevice(did);
- if (d.is(PortDiscovery.class)) {
- PortDiscovery portConfig = d.as(PortDiscovery.class);
- if (portConfig != null) {
- providerService.updatePorts(did, portConfig.getPorts());
- }
+ if (d.is(DeviceDescriptionDiscovery.class)) {
+ DeviceDescriptionDiscovery descriptionDiscovery = d.as(DeviceDescriptionDiscovery.class);
+ DeviceDescription description = descriptionDiscovery.discoverDeviceDetails();
+ deviceStore.createOrUpdateDevice(
+ new ProviderId("snmp", "org.onosproject.provider.device"),
+ did, description);
+ providerService.updatePorts(did, descriptionDiscovery.discoverPortDetails());
} else {
- log.warn("No port discovery behaviour for device {}", did);
+ log.warn("No populate description and ports behaviour for device {}", did);
}
-
- delay(EVENTINTERVAL);
- } catch (URISyntaxException e) {
- log.error("Syntax Error while creating URI for the device: "
- + device.deviceInfo()
- + " couldn't persist the device onto the store", e);
} catch (Exception e) {
log.error("Error while initializing session for the device: "
- + (device != null ? device.deviceInfo() : null), e);
+ + (device != null ? device.deviceInfo() : null), e);
}
}
- /**
- * @deprecated 1.5.0 Falcon, not compliant with ONOS SB and driver architecture.
- */
- @Deprecated
- private DeviceDescription populateDescriptionFromDevice(DeviceId did, DeviceDescription desc) {
- String[] deviceComponents = did.toString().split(":");
- if (deviceComponents.length > 1) {
- String ipAddress = deviceComponents[1];
- String port = deviceComponents[2];
-
- ISnmpConfiguration config = new V2cSnmpConfiguration();
- config.setPort(Integer.parseInt(port));
-
- try (ISnmpSession session = sessionFactory.createSession(config, ipAddress)) {
- // Each session will be auto-closed.
- String deviceOid = session.identifyDevice();
-
- if (providers.containsKey(deviceOid)) {
- desc = providers.get(deviceOid).populateDescription(session, desc);
- }
-
- } catch (IOException | RuntimeException ex) {
- log.error("Failed to walk device.", ex.getMessage());
- log.debug("Detailed problem was ", ex);
- }
- }
- return desc;
- }
-
- /**
- * This will build a device id for the device.
- */
- private DeviceId getDeviceId() throws URISyntaxException {
- String additionalSsp = new StringBuilder(
- device.getSnmpHost()).append(":")
- .append(device.getSnmpPort()).toString();
- return DeviceId.deviceId(new URI(SCHEME, additionalSsp,
- null));
- }
}
- protected ISnmpSessionFactory getSessionFactory(ISnmpConfigurationFactory configurationFactory) {
- return new SnmpSessionFactory(configurationFactory);
+ private class InternalNetworkConfigListener implements NetworkConfigListener {
+
+
+ @Override
+ public void event(NetworkConfigEvent event) {
+ addOrRemoveDevicesConfig();
+ }
+
+ @Override
+ public boolean isRelevant(NetworkConfigEvent event) {
+ return event.configClass().equals(SnmpProviderConfig.class) &&
+ (event.type() == NetworkConfigEvent.Type.CONFIG_ADDED ||
+ event.type() == NetworkConfigEvent.Type.CONFIG_UPDATED);
+ }
}
@Override
diff --git a/providers/snmp/device/src/main/java/org/onosproject/provider/snmp/device/impl/SnmpProviderConfig.java b/providers/snmp/device/src/main/java/org/onosproject/provider/snmp/device/impl/SnmpProviderConfig.java
new file mode 100644
index 0000000..14bc6f8
--- /dev/null
+++ b/providers/snmp/device/src/main/java/org/onosproject/provider/snmp/device/impl/SnmpProviderConfig.java
@@ -0,0 +1,142 @@
+/*
+ * 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.provider.snmp.device.impl;
+
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.google.common.annotations.Beta;
+import com.google.common.collect.Sets;
+import org.onlab.packet.IpAddress;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.incubator.net.config.basics.ConfigException;
+import org.onosproject.net.config.Config;
+
+import java.util.Set;
+
+/**
+ * Configuration decoder for SNMP provider.
+ */
+@Beta
+public class SnmpProviderConfig extends Config<ApplicationId> {
+
+ public static final String CONFIG_VALUE_ERROR = "Error parsing config value";
+ private static final String IP = "ip";
+ private static final int DEFAULT_TCP_PORT = 830;
+ private static final String PORT = "port";
+ private static final String NAME = "username";
+ private static final String PASSWORD = "password";
+
+ /**
+ * Retrieves a set of SnmpDeviceInfo containing all the device
+ * configuration pertaining to the SNMP device provider.
+ * @return set of device configurations.
+ *
+ * @throws ConfigException if configuration can't be read
+ */
+ public Set<SnmpDeviceInfo> getDevicesInfo() throws ConfigException {
+ Set<SnmpDeviceInfo> deviceInfos = Sets.newHashSet();
+
+ try {
+ for (JsonNode node : array) {
+ String ip = node.path(IP).asText();
+ IpAddress ipAddr = ip.isEmpty() ? null : IpAddress.valueOf(ip);
+ int port = node.path(PORT).asInt(DEFAULT_TCP_PORT);
+ String name = node.path(NAME).asText();
+ String password = node.path(PASSWORD).asText();
+ deviceInfos.add(new SnmpDeviceInfo(ipAddr, port, name, password));
+
+ }
+ } catch (IllegalArgumentException e) {
+ throw new ConfigException(CONFIG_VALUE_ERROR, e);
+ }
+
+ return deviceInfos;
+ }
+
+ /**
+ * Contains information about a SNMP device retrieved form the net-cfg subsystem.
+ */
+ public class SnmpDeviceInfo {
+ private final IpAddress ip;
+ private final int port;
+ private final String username;
+ private final String password;
+
+ /**
+ * Build an information object containing the given device specifics.
+ * @param ip ip
+ * @param port port
+ * @param username username
+ * @param password password (a.k.a community in SNMP)
+ */
+ public SnmpDeviceInfo(IpAddress ip, int port, String username, String password) {
+ this.ip = ip;
+ this.port = port;
+ this.username = username;
+ this.password = password;
+ }
+
+ /**
+ * Returns IpAddress of the device.
+ * @return ip
+ */
+ public IpAddress ip() {
+ return ip;
+ }
+
+ /**
+ * Returns port of the device.
+ * @return port
+ */
+ public int port() {
+ return port;
+ }
+
+ /**
+ * Returns username of the device.
+ * @return username
+ */
+ public String username() {
+ return username;
+ }
+
+ /**
+ * Returns password of the device.
+ * @return password
+ */
+ public String password() {
+ return password;
+ }
+ }
+
+}
+
diff --git a/providers/snmp/pom.xml b/providers/snmp/pom.xml
index 4f7b06b..4d2218b 100644
--- a/providers/snmp/pom.xml
+++ b/providers/snmp/pom.xml
@@ -36,38 +36,7 @@
<module>app</module>
<module>alarm</module>
</modules>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.servicemix.bundles</groupId>
- <artifactId>org.apache.servicemix.bundles.snmp4j</artifactId>
- <version>2.3.4_1</version>
- <exclusions>
- <exclusion>
- <artifactId>log4j</artifactId>
- <groupId>log4j</groupId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>com.btisystems</groupId>
- <artifactId>snmp-core</artifactId>
- <version>1.3-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>com.btisystems.mibbler.mibs</groupId>
- <artifactId>bti7000</artifactId>
- <version>1.0-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>com.btisystems.mibbler.mibs</groupId>
- <artifactId>net-snmp</artifactId>
- <version>1.0-SNAPSHOT</version>
- </dependency>
- </dependencies>
+
<repositories>
<repository>
<!-- TODO move over to release snmp-core when it becomes available. ONOS-3646 -->