Andrea Campanella
Committed by Gerrit Code Review

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

Change-Id: Ie87ee6c181c9550ffac602397f2ee74a691bbdfa
Showing 33 changed files with 1077 additions and 218 deletions
1 +SRC = 'src/main/java/org/onosproject/**/'
2 +
3 +CURRENT_NAME = 'onos-drivers-bti'
4 +CURRENT_TARGET = ':' + CURRENT_NAME
5 +
6 +COMPILE_DEPS = [
7 + '//lib:CORE_DEPS',
8 + '//protocols/netconf/api:onos-snmp-api',
9 + '//incubator/api:onos-incubator-api'
10 +]
11 +
12 +java_library(
13 + name = CURRENT_NAME,
14 + srcs = glob([SRC + '/*.java']),
15 + deps = COMPILE_DEPS,
16 + visibility = ['PUBLIC'],
17 + resources_root = 'src/main/resources',
18 + resources = glob(['src/main/resources/**']),
19 +)
1 +<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2 +
3 +<!--
4 + ~ Copyright 2016 Open Networking Laboratory
5 + ~
6 + ~ Licensed under the Apache License, Version 2.0 (the "License");
7 + ~ you may not use this file except in compliance with the License.
8 + ~ You may obtain a copy of the License at
9 + ~
10 + ~ http://www.apache.org/licenses/LICENSE-2.0
11 + ~
12 + ~ Unless required by applicable law or agreed to in writing, software
13 + ~ distributed under the License is distributed on an "AS IS" BASIS,
14 + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 + ~ See the License for the specific language governing permissions and
16 + ~ limitations under the License.
17 + -->
18 +<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" name="${project.artifactId}-${project.version}">
19 + <feature name="${project.artifactId}" version="${project.version}"
20 + description="${project.description}">
21 + <feature>onos-api</feature>
22 +
23 + <bundle>mvn:${project.groupId}/${project.artifactId}/${project.version}</bundle>
24 +
25 + <bundle>mvn:${project.groupId}/onos-snmp-api/${project.version}</bundle>
26 +
27 + <bundle>mvn:${project.groupId}/onos-incubator-api/${project.version}</bundle>
28 +
29 + </feature>
30 +</features>
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<!--
3 + ~ Copyright 2016 Open Networking Laboratory
4 + ~
5 + ~ Licensed under the Apache License, Version 2.0 (the "License");
6 + ~ you may not use this file except in compliance with the License.
7 + ~ You may obtain a copy of the License at
8 + ~
9 + ~ http://www.apache.org/licenses/LICENSE-2.0
10 + ~
11 + ~ Unless required by applicable law or agreed to in writing, software
12 + ~ distributed under the License is distributed on an "AS IS" BASIS,
13 + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 + ~ See the License for the specific language governing permissions and
15 + ~ limitations under the License.
16 + -->
17 +
18 +<project xmlns="http://maven.apache.org/POM/4.0.0"
19 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
20 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
21 + <parent>
22 + <artifactId>onos-drivers-general</artifactId>
23 + <groupId>org.onosproject</groupId>
24 + <version>1.6.0-SNAPSHOT</version>
25 + </parent>
26 + <modelVersion>4.0.0</modelVersion>
27 +
28 + <artifactId>onos-drivers-bti</artifactId>
29 + <packaging>bundle</packaging>
30 +
31 + <properties>
32 + <onos.app.name>org.onosproject.drivers.bti</onos.app.name>
33 + <onos.app.origin>ON.Lab</onos.app.origin>
34 + <onos.app.category>Drivers</onos.app.category>
35 + <onos.app.title>Bti Device Drivers</onos.app.title>
36 + <onos.app.url>http://onosproject.org</onos.app.url>
37 + <onos.app.requires>
38 + org.onosproject.snmp
39 + </onos.app.requires>
40 + </properties>
41 +
42 + <dependencies>
43 + <dependency>
44 + <groupId>org.onosproject</groupId>
45 + <artifactId>onos-snmp-api</artifactId>
46 + <version>1.6.0-SNAPSHOT</version>
47 + </dependency>
48 + <dependency>
49 + <groupId>org.onosproject</groupId>
50 + <artifactId>onos-incubator-api</artifactId>
51 + <version>1.6.0-SNAPSHOT</version>
52 + </dependency>
53 + </dependencies>
54 +
55 +</project>
...\ No newline at end of file ...\ No newline at end of file
1 /* 1 /*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
2 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * Licensed under the Apache License, Version 2.0 (the "License");
3 * you may not use this file except in compliance with the License. 5 * you may not use this file except in compliance with the License.
4 * You may obtain a copy of the License at 6 * You may obtain a copy of the License at
5 * 7 *
6 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
7 * 9 *
8 * Unless required by applicable law or agreed to in writing, software 10 * Unless required by applicable law or agreed to in writing, software
9 * distributed under the License is distributed on an "AS IS" BASIS, 11 * distributed under the License is distributed on an "AS IS" BASIS,
...@@ -11,58 +13,102 @@ ...@@ -11,58 +13,102 @@
11 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
12 * limitations under the License. 14 * limitations under the License.
13 */ 15 */
14 -package org.onosproject.provider.snmp.device.impl; 16 +
17 +package org.onosproject.drivers.bti;
15 18
16 import com.btisystems.mibbler.mibs.bti7000.bti7000_13_2_0.I_Device; 19 import com.btisystems.mibbler.mibs.bti7000.bti7000_13_2_0.I_Device;
17 import com.btisystems.mibbler.mibs.bti7000.bti7000_13_2_0._OidRegistry; 20 import com.btisystems.mibbler.mibs.bti7000.bti7000_13_2_0._OidRegistry;
21 +import com.btisystems.mibbler.mibs.bti7000.bti7000_13_2_0.mib_2.System;
18 import com.btisystems.pronx.ems.core.model.ClassRegistry; 22 import com.btisystems.pronx.ems.core.model.ClassRegistry;
19 import com.btisystems.pronx.ems.core.model.IClassRegistry; 23 import com.btisystems.pronx.ems.core.model.IClassRegistry;
20 import com.btisystems.pronx.ems.core.model.NetworkDevice; 24 import com.btisystems.pronx.ems.core.model.NetworkDevice;
25 +import com.btisystems.pronx.ems.core.snmp.ISnmpConfiguration;
21 import com.btisystems.pronx.ems.core.snmp.ISnmpSession; 26 import com.btisystems.pronx.ems.core.snmp.ISnmpSession;
27 +import com.btisystems.pronx.ems.core.snmp.V2cSnmpConfiguration;
28 +import com.google.common.collect.ImmutableList;
29 +import org.onosproject.net.Device;
30 +import org.onosproject.net.DeviceId;
31 +import org.onosproject.net.SparseAnnotations;
22 import org.onosproject.net.device.DefaultDeviceDescription; 32 import org.onosproject.net.device.DefaultDeviceDescription;
23 import org.onosproject.net.device.DeviceDescription; 33 import org.onosproject.net.device.DeviceDescription;
34 +import org.onosproject.net.device.DeviceDescriptionDiscovery;
35 +import org.onosproject.net.device.DeviceService;
36 +import org.onosproject.net.device.PortDescription;
37 +import org.onosproject.net.driver.AbstractHandlerBehaviour;
38 +import org.onosproject.snmp.SnmpController;
39 +import org.onosproject.snmp.SnmpDevice;
24 import org.slf4j.Logger; 40 import org.slf4j.Logger;
25 -import org.snmp4j.smi.OID;
26 41
27 import java.io.IOException; 42 import java.io.IOException;
28 -import java.util.Arrays; 43 +import java.util.Collections;
44 +import java.util.List;
29 45
46 +import static com.google.common.base.Preconditions.checkNotNull;
30 import static org.slf4j.LoggerFactory.getLogger; 47 import static org.slf4j.LoggerFactory.getLogger;
31 48
32 /** 49 /**
33 - * A vendor-specific implementation supporting BTI Systems BTI-7000 equipment. 50 + * Bti 7000 SNMP device description behaviour. Provides device description and port information.
34 - * @deprecated 1.5.0 Falcon, not compliant with ONOS SB and driver architecture.
35 */ 51 */
36 -@Deprecated 52 +public class Bti7000DeviceDescriptor extends AbstractHandlerBehaviour implements DeviceDescriptionDiscovery {
37 -public class Bti7000DeviceDescriptionProvider implements SnmpDeviceDescriptionProvider { 53 +
38 private final Logger log = getLogger(getClass()); 54 private final Logger log = getLogger(getClass());
39 protected static final IClassRegistry CLASS_REGISTRY = 55 protected static final IClassRegistry CLASS_REGISTRY =
40 new ClassRegistry(_OidRegistry.oidRegistry, I_Device.class); 56 new ClassRegistry(_OidRegistry.oidRegistry, I_Device.class);
41 private static final String UNKNOWN = "unknown"; 57 private static final String UNKNOWN = "unknown";
42 58
43 @Override 59 @Override
44 - public DeviceDescription populateDescription(ISnmpSession session, DeviceDescription description) { 60 + public DeviceDescription discoverDeviceDetails() {
61 + SnmpController controller = checkNotNull(handler().get(SnmpController.class));
62 + DeviceId deviceId = handler().data().deviceId();
63 + SnmpDevice snmpDevice = controller.getDevice(deviceId);
64 + DeviceService deviceService = checkNotNull(handler().get(DeviceService.class));
65 + Device device = deviceService.getDevice(deviceId);
66 + DeviceDescription desc = null;
67 + String ipAddress = snmpDevice.getSnmpHost();
68 + int port = snmpDevice.getSnmpPort();
69 +
70 + ISnmpConfiguration config = new V2cSnmpConfiguration();
71 + config.setPort(port);
72 +
73 + try (ISnmpSession session = controller.getSession(deviceId)) {
74 + // Each session will be auto-closed.
75 + String deviceOid = session.identifyDevice();
76 + desc = populateDescription(session, device);
77 +
78 + } catch (IOException | RuntimeException ex) {
79 + log.error("Failed to walk device.", ex.getMessage());
80 + log.debug("Detailed problem was ", ex);
81 + }
82 + return desc;
83 + }
84 +
85 + @Override
86 + public List<PortDescription> discoverPortDetails() {
87 + //TODO implement
88 + return ImmutableList.of();
89 + }
90 +
91 + private DeviceDescription populateDescription(ISnmpSession session, Device device) {
45 NetworkDevice networkDevice = new NetworkDevice(CLASS_REGISTRY, 92 NetworkDevice networkDevice = new NetworkDevice(CLASS_REGISTRY,
46 - session.getAddress().getHostAddress()); 93 + session.getAddress().getHostAddress());
47 try { 94 try {
48 - session.walkDevice(networkDevice, Arrays.asList(new OID[]{ 95 + session.walkDevice(networkDevice, Collections.singletonList(CLASS_REGISTRY.getClassToOidMap().get(
49 - CLASS_REGISTRY.getClassToOidMap().get( 96 + System.class)));
50 - com.btisystems.mibbler.mibs.bti7000.bti7000_13_2_0.mib_2.System.class)}));
51 97
52 com.btisystems.mibbler.mibs.bti7000.bti7000_13_2_0.mib_2.System systemTree = 98 com.btisystems.mibbler.mibs.bti7000.bti7000_13_2_0.mib_2.System systemTree =
53 (com.btisystems.mibbler.mibs.bti7000.bti7000_13_2_0.mib_2.System) 99 (com.btisystems.mibbler.mibs.bti7000.bti7000_13_2_0.mib_2.System)
54 - networkDevice.getRootObject().getEntity(CLASS_REGISTRY.getClassToOidMap().get( 100 + networkDevice.getRootObject().getEntity(CLASS_REGISTRY.getClassToOidMap().get(
55 com.btisystems.mibbler.mibs.bti7000.bti7000_13_2_0.mib_2.System.class)); 101 com.btisystems.mibbler.mibs.bti7000.bti7000_13_2_0.mib_2.System.class));
56 if (systemTree != null) { 102 if (systemTree != null) {
57 String[] systemComponents = systemTree.getSysDescr().split(";"); 103 String[] systemComponents = systemTree.getSysDescr().split(";");
58 - return new DefaultDeviceDescription(description.deviceUri(), description.type(), 104 + return new DefaultDeviceDescription(device.id().uri(), device.type(),
59 - systemComponents[0], systemComponents[2], systemComponents[3], 105 + systemComponents[0], systemComponents[2],
60 - UNKNOWN, description.chassisId(), description.annotations()); 106 + systemComponents[3], UNKNOWN, device.chassisId(),
107 + (SparseAnnotations) device.annotations());
61 } 108 }
62 } catch (IOException ex) { 109 } catch (IOException ex) {
63 - log.error("Error reading details for device {}.", session.getAddress(), ex); 110 + throw new IllegalArgumentException("Error reading details for device." + session.getAddress(), ex);
64 } 111 }
65 - return description; 112 + return null;
66 } 113 }
67 -
68 } 114 }
......
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.drivers.bti;
18 +
19 +import org.apache.felix.scr.annotations.Component;
20 +import org.onosproject.net.driver.AbstractDriverLoader;
21 +
22 +/**
23 + * Loader for BTI device drivers.
24 + */
25 +@Component(immediate = true)
26 +public class BtiDriversLoader extends AbstractDriverLoader {
27 +
28 + public BtiDriversLoader() {
29 + super("/bti-drivers.xml");
30 + }
31 +}
1 /* 1 /*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
2 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * Licensed under the Apache License, Version 2.0 (the "License");
3 * you may not use this file except in compliance with the License. 5 * you may not use this file except in compliance with the License.
4 * You may obtain a copy of the License at 6 * You may obtain a copy of the License at
5 * 7 *
6 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
7 * 9 *
8 * Unless required by applicable law or agreed to in writing, software 10 * Unless required by applicable law or agreed to in writing, software
9 * distributed under the License is distributed on an "AS IS" BASIS, 11 * distributed under the License is distributed on an "AS IS" BASIS,
...@@ -11,60 +13,107 @@ ...@@ -11,60 +13,107 @@
11 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
12 * limitations under the License. 14 * limitations under the License.
13 */ 15 */
14 -package org.onosproject.provider.snmp.device.impl; 16 +
17 +package org.onosproject.drivers.bti;
15 18
16 import com.btisystems.mibbler.mibs.netsnmp.netsnmp.I_Device; 19 import com.btisystems.mibbler.mibs.netsnmp.netsnmp.I_Device;
17 import com.btisystems.mibbler.mibs.netsnmp.netsnmp._OidRegistry; 20 import com.btisystems.mibbler.mibs.netsnmp.netsnmp._OidRegistry;
21 +import com.btisystems.mibbler.mibs.netsnmp.netsnmp.mib_2.System;
18 import com.btisystems.pronx.ems.core.model.ClassRegistry; 22 import com.btisystems.pronx.ems.core.model.ClassRegistry;
19 import com.btisystems.pronx.ems.core.model.IClassRegistry; 23 import com.btisystems.pronx.ems.core.model.IClassRegistry;
20 import com.btisystems.pronx.ems.core.model.NetworkDevice; 24 import com.btisystems.pronx.ems.core.model.NetworkDevice;
25 +import com.btisystems.pronx.ems.core.snmp.ISnmpConfiguration;
21 import com.btisystems.pronx.ems.core.snmp.ISnmpSession; 26 import com.btisystems.pronx.ems.core.snmp.ISnmpSession;
27 +import com.btisystems.pronx.ems.core.snmp.V2cSnmpConfiguration;
28 +import com.google.common.collect.ImmutableList;
22 import org.apache.commons.lang.StringUtils; 29 import org.apache.commons.lang.StringUtils;
30 +import org.onosproject.net.Device;
31 +import org.onosproject.net.DeviceId;
32 +import org.onosproject.net.SparseAnnotations;
23 import org.onosproject.net.device.DefaultDeviceDescription; 33 import org.onosproject.net.device.DefaultDeviceDescription;
24 import org.onosproject.net.device.DeviceDescription; 34 import org.onosproject.net.device.DeviceDescription;
35 +import org.onosproject.net.device.DeviceDescriptionDiscovery;
36 +import org.onosproject.net.device.DeviceService;
37 +import org.onosproject.net.device.PortDescription;
38 +import org.onosproject.net.driver.AbstractHandlerBehaviour;
39 +import org.onosproject.snmp.SnmpController;
40 +import org.onosproject.snmp.SnmpDevice;
25 import org.slf4j.Logger; 41 import org.slf4j.Logger;
26 -import org.snmp4j.smi.OID;
27 42
28 import java.io.IOException; 43 import java.io.IOException;
29 -import java.util.Arrays; 44 +import java.util.Collections;
45 +import java.util.List;
30 46
47 +import static com.google.common.base.Preconditions.checkNotNull;
31 import static org.slf4j.LoggerFactory.getLogger; 48 import static org.slf4j.LoggerFactory.getLogger;
32 49
33 /** 50 /**
34 - * A agent-specific implementation supporting NET-SNMP agents. 51 + * Net SNMP device description behaviour. Provides device description and port information.
35 - * @deprecated 1.5.0 Falcon, not compliant with ONOS SB and driver architecture.
36 */ 52 */
37 -@Deprecated 53 +public class NetSnmpDeviceDescriptor extends AbstractHandlerBehaviour implements DeviceDescriptionDiscovery {
38 -public class NetSnmpDeviceDescriptionProvider implements SnmpDeviceDescriptionProvider {
39 private final Logger log = getLogger(getClass()); 54 private final Logger log = getLogger(getClass());
40 protected static final IClassRegistry CLASS_REGISTRY = 55 protected static final IClassRegistry CLASS_REGISTRY =
41 new ClassRegistry(_OidRegistry.oidRegistry, I_Device.class); 56 new ClassRegistry(_OidRegistry.oidRegistry, I_Device.class);
42 private static final String UNKNOWN = "unknown"; 57 private static final String UNKNOWN = "unknown";
43 58
59 +
60 + //TODO evaluate a common abstract class for all Snmp description discovery
61 + @Override
62 + public DeviceDescription discoverDeviceDetails() {
63 + SnmpController controller = checkNotNull(handler().get(SnmpController.class));
64 + DeviceId deviceId = handler().data().deviceId();
65 + SnmpDevice snmpDevice = controller.getDevice(deviceId);
66 + DeviceService deviceService = checkNotNull(handler().get(DeviceService.class));
67 + Device device = deviceService.getDevice(deviceId);
68 + DeviceDescription desc = null;
69 + String ipAddress = snmpDevice.getSnmpHost();
70 + int port = snmpDevice.getSnmpPort();
71 +
72 + ISnmpConfiguration config = new V2cSnmpConfiguration();
73 + config.setPort(port);
74 +
75 + try (ISnmpSession session = controller.getSession(deviceId)) {
76 + // Each session will be auto-closed.
77 + String deviceOid = session.identifyDevice();
78 + //TODO obtain desctiption
79 + desc = populateDescription(session, device);
80 +
81 + } catch (IOException | RuntimeException ex) {
82 + log.error("Failed to walk device.", ex.getMessage());
83 + log.debug("Detailed problem was ", ex);
84 + }
85 +
86 + return desc;
87 + }
88 +
44 @Override 89 @Override
45 - public DeviceDescription populateDescription(ISnmpSession session, DeviceDescription description) { 90 + public List<PortDescription> discoverPortDetails() {
91 + //TODO implement
92 + return ImmutableList.of();
93 + }
94 +
95 + private DeviceDescription populateDescription(ISnmpSession session, Device device) {
46 NetworkDevice networkDevice = new NetworkDevice(CLASS_REGISTRY, 96 NetworkDevice networkDevice = new NetworkDevice(CLASS_REGISTRY,
47 - session.getAddress().getHostAddress()); 97 + session.getAddress().getHostAddress());
48 try { 98 try {
49 - session.walkDevice(networkDevice, Arrays.asList(new OID[]{ 99 + session.walkDevice(networkDevice, Collections.singletonList(CLASS_REGISTRY.getClassToOidMap().get(
50 - CLASS_REGISTRY.getClassToOidMap().get( 100 + System.class)));
51 - com.btisystems.mibbler.mibs.netsnmp.netsnmp.mib_2.System.class)}));
52 101
53 com.btisystems.mibbler.mibs.netsnmp.netsnmp.mib_2.System systemTree = 102 com.btisystems.mibbler.mibs.netsnmp.netsnmp.mib_2.System systemTree =
54 (com.btisystems.mibbler.mibs.netsnmp.netsnmp.mib_2.System) 103 (com.btisystems.mibbler.mibs.netsnmp.netsnmp.mib_2.System)
55 - networkDevice.getRootObject().getEntity(CLASS_REGISTRY.getClassToOidMap().get( 104 + networkDevice.getRootObject().getEntity(CLASS_REGISTRY.getClassToOidMap().get(
56 com.btisystems.mibbler.mibs.netsnmp.netsnmp.mib_2.System.class)); 105 com.btisystems.mibbler.mibs.netsnmp.netsnmp.mib_2.System.class));
57 if (systemTree != null) { 106 if (systemTree != null) {
58 // TODO SNMP sys-contacts may be verbose; ONOS-GUI doesn't abbreviate fields neatly; 107 // TODO SNMP sys-contacts may be verbose; ONOS-GUI doesn't abbreviate fields neatly;
59 // so cut it here until supported in prop displayer 108 // so cut it here until supported in prop displayer
60 String manufacturer = StringUtils.abbreviate(systemTree.getSysContact(), 20); 109 String manufacturer = StringUtils.abbreviate(systemTree.getSysContact(), 20);
61 - return new DefaultDeviceDescription(description.deviceUri(), description.type(), manufacturer, 110 + return new DefaultDeviceDescription(device.id().uri(), device.type(),
62 - UNKNOWN, UNKNOWN, UNKNOWN, description.chassisId(), description.annotations()); 111 + manufacturer, UNKNOWN, UNKNOWN, UNKNOWN,
112 + device.chassisId(), (SparseAnnotations) device.annotations());
63 } 113 }
64 } catch (IOException ex) { 114 } catch (IOException ex) {
65 - log.error("Error reading details for device {}.", session.getAddress(), ex); 115 + throw new IllegalArgumentException("Error reading details for device." + session.getAddress(), ex);
66 } 116 }
67 - return description; 117 + return null;
68 } 118 }
69 -
70 } 119 }
......
1 /* 1 /*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2016 Open Networking Laboratory
3 * 3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License. 5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at 6 * You may obtain a copy of the License at
7 * 7 *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 * 9 *
10 * Unless required by applicable law or agreed to in writing, software 10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, 11 * distributed under the License is distributed on an "AS IS" BASIS,
...@@ -14,17 +14,7 @@ ...@@ -14,17 +14,7 @@
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 16
17 -package org.onosproject.provider.snmp.device.impl; 17 +/**
18 - /** 18 + * Package for BTI device drivers.
19 - * The Device State is used to determine whether the device is active or inactive. This state information will help 19 + */
20 - * Device Creator to add or delete the device from the core. 20 +package org.onosproject.drivers.bti;
21 - */
22 - public enum DeviceState {
23 - /* Used to specify Active state of the device */
24 -
25 - ACTIVE,
26 - /* Used to specify inactive state of the device */
27 - INACTIVE,
28 - /* Used to specify invalid state of the device */
29 - INVALID
30 - }
...\ No newline at end of file ...\ No newline at end of file
......
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +
3 +<!--
4 + ~ Copyright 2016 Open Networking Laboratory
5 + ~
6 + ~ Licensed under the Apache License, Version 2.0 (the "License");
7 + ~ you may not use this file except in compliance with the License.
8 + ~ You may obtain a copy of the License at
9 + ~
10 + ~ http://www.apache.org/licenses/LICENSE-2.0
11 + ~
12 + ~ Unless required by applicable law or agreed to in writing, software
13 + ~ distributed under the License is distributed on an "AS IS" BASIS,
14 + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 + ~ See the License for the specific language governing permissions and
16 + ~ limitations under the License.
17 + -->
18 +<drivers>
19 + <driver name="bti7000" manufacturer="bti" hwVersion="1.0.0" swVersion="1.0.0">
20 + <behaviour api="org.onosproject.net.device.DeviceDescriptionDiscovery"
21 + impl="org.onosproject.drivers.bti.Bti7000DeviceDescriptor"/>
22 + </driver>
23 + <driver name="NetSnmp" manufacturer="bti" hwVersion="1.0.0" swVersion="1.0.0">
24 + <behaviour api="org.onosproject.net.device.DeviceDescriptionDiscovery"
25 + impl="org.onosproject.drivers.bti.NetSnmpDeviceDescriptor"/>
26 + </driver>
27 +</drivers>
28 +
...@@ -20,8 +20,6 @@ ...@@ -20,8 +20,6 @@
20 <feature>onos-api</feature> 20 <feature>onos-api</feature>
21 <bundle>mvn:${project.groupId}/${project.artifactId}/${project.version}</bundle> 21 <bundle>mvn:${project.groupId}/${project.artifactId}/${project.version}</bundle>
22 22
23 - <bundle>mvn:${project.groupId}/onos-restsb-api/${project.version}</bundle>
24 -
25 <bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.snmp4j/2.3.4_1</bundle> 23 <bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.snmp4j/2.3.4_1</bundle>
26 24
27 </feature> 25 </feature>
......
...@@ -35,6 +35,9 @@ ...@@ -35,6 +35,9 @@
35 <onos.app.category>Drivers</onos.app.category> 35 <onos.app.category>Drivers</onos.app.category>
36 <onos.app.title>Lumentum Device Drivers</onos.app.title> 36 <onos.app.title>Lumentum Device Drivers</onos.app.title>
37 <onos.app.url>http://onosproject.org</onos.app.url> 37 <onos.app.url>http://onosproject.org</onos.app.url>
38 + <onos.app.requires>
39 + org.onosproject.snmp
40 + </onos.app.requires>
38 </properties> 41 </properties>
39 42
40 <dependencies> 43 <dependencies>
......
...@@ -19,9 +19,14 @@ package org.onosproject.drivers.lumentum; ...@@ -19,9 +19,14 @@ package org.onosproject.drivers.lumentum;
19 import com.google.common.collect.Lists; 19 import com.google.common.collect.Lists;
20 import org.onosproject.net.AnnotationKeys; 20 import org.onosproject.net.AnnotationKeys;
21 import org.onosproject.net.DefaultAnnotations; 21 import org.onosproject.net.DefaultAnnotations;
22 +import org.onosproject.net.Device;
23 +import org.onosproject.net.DeviceId;
22 import org.onosproject.net.PortNumber; 24 import org.onosproject.net.PortNumber;
23 import org.onosproject.net.SparseAnnotations; 25 import org.onosproject.net.SparseAnnotations;
24 -import org.onosproject.net.behaviour.PortDiscovery; 26 +import org.onosproject.net.device.DefaultDeviceDescription;
27 +import org.onosproject.net.device.DeviceDescription;
28 +import org.onosproject.net.device.DeviceDescriptionDiscovery;
29 +import org.onosproject.net.device.DeviceService;
25 import org.onosproject.net.device.OmsPortDescription; 30 import org.onosproject.net.device.OmsPortDescription;
26 import org.onosproject.net.device.PortDescription; 31 import org.onosproject.net.device.PortDescription;
27 import org.onosproject.net.driver.AbstractHandlerBehaviour; 32 import org.onosproject.net.driver.AbstractHandlerBehaviour;
...@@ -34,22 +39,37 @@ import java.io.IOException; ...@@ -34,22 +39,37 @@ import java.io.IOException;
34 import java.util.Collections; 39 import java.util.Collections;
35 import java.util.List; 40 import java.util.List;
36 41
42 +import static com.google.common.base.Preconditions.checkNotNull;
37 import static org.slf4j.LoggerFactory.getLogger; 43 import static org.slf4j.LoggerFactory.getLogger;
38 44
39 /** 45 /**
40 - * Discovers the ports of a Lumentum SDN ROADM device using SNMP. 46 + * Device description behaviour for Lumentum Snmp devices.
41 */ 47 */
42 -public class PortDiscoveryLumentumRoadm extends AbstractHandlerBehaviour 48 +public class LumentumRoadmDeviceDescription extends AbstractHandlerBehaviour implements DeviceDescriptionDiscovery {
43 - implements PortDiscovery {
44 49
45 - private final Logger log = getLogger(PortDiscoveryLumentumRoadm.class); 50 + private final Logger log = getLogger(getClass());
46 51
47 private static final String CTRL_PORT_STATE = ".1.3.6.1.4.1.46184.1.4.1.1.3."; 52 private static final String CTRL_PORT_STATE = ".1.3.6.1.4.1.46184.1.4.1.1.3.";
48 53
49 private LumentumSnmpDevice snmp; 54 private LumentumSnmpDevice snmp;
50 55
51 @Override 56 @Override
52 - public List<PortDescription> getPorts() { 57 + public DeviceDescription discoverDeviceDetails() {
58 + //TODO get device description
59 + DeviceService deviceService = checkNotNull(handler().get(DeviceService.class));
60 + DeviceId deviceId = handler().data().deviceId();
61 + Device device = deviceService.getDevice(deviceId);
62 + return new DefaultDeviceDescription(device.id().uri(), Device.Type.ROADM,
63 + "Lumentum", "SDN ROADM", "1.0", "v1",
64 + device.chassisId(), (SparseAnnotations) device.annotations());
65 + }
66 +
67 + @Override
68 + public List<PortDescription> discoverPortDetails() {
69 + return this.getPorts();
70 + }
71 +
72 + private List<PortDescription> getPorts() {
53 try { 73 try {
54 snmp = new LumentumSnmpDevice(handler().data().deviceId()); 74 snmp = new LumentumSnmpDevice(handler().data().deviceId());
55 } catch (IOException e) { 75 } catch (IOException e) {
...@@ -119,5 +139,3 @@ public class PortDiscoveryLumentumRoadm extends AbstractHandlerBehaviour ...@@ -119,5 +139,3 @@ public class PortDiscoveryLumentumRoadm extends AbstractHandlerBehaviour
119 return ports; 139 return ports;
120 } 140 }
121 } 141 }
122 -
123 -
......
...@@ -16,8 +16,8 @@ ...@@ -16,8 +16,8 @@
16 --> 16 -->
17 <drivers> 17 <drivers>
18 <driver name="lumentum" manufacturer="Lumentum" hwVersion="SDN ROADM" swVersion="1.0"> 18 <driver name="lumentum" manufacturer="Lumentum" hwVersion="SDN ROADM" swVersion="1.0">
19 - <behaviour api="org.onosproject.net.behaviour.PortDiscovery" 19 + <behaviour api="org.onosproject.net.device.DeviceDescriptionDiscovery"
20 - impl="org.onosproject.drivers.lumentum.PortDiscoveryLumentumRoadm"/> 20 + impl="org.onosproject.drivers.lumentum.LumentumRoadmDeviceDescription"/>
21 <behaviour api="org.onosproject.net.behaviour.LambdaQuery" 21 <behaviour api="org.onosproject.net.behaviour.LambdaQuery"
22 impl="org.onosproject.drivers.lumentum.LambdaQueryLumentumRoadm"/> 22 impl="org.onosproject.drivers.lumentum.LambdaQueryLumentumRoadm"/>
23 <behaviour api="org.onosproject.net.flow.FlowRuleProgrammable" 23 <behaviour api="org.onosproject.net.flow.FlowRuleProgrammable"
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
40 <module>ovsdb</module> 40 <module>ovsdb</module>
41 <module>utilities</module> 41 <module>utilities</module>
42 <module>lumentum</module> 42 <module>lumentum</module>
43 + <module>bti</module>
43 </modules> 44 </modules>
44 45
45 <!--<properties> 46 <!--<properties>
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
40 <module>rest</module> 40 <module>rest</module>
41 <module>ospf</module> 41 <module>ospf</module>
42 <module>isis</module> 42 <module>isis</module>
43 + <module>snmp</module>
43 </modules> 44 </modules>
44 45
45 <dependencies> 46 <dependencies>
......
1 +SRC = 'src/main/java/org/onosproject/**/'
2 +
3 +CURRENT_NAME = 'onos-snmp-api'
4 +CURRENT_TARGET = ':' + CURRENT_NAME
5 +
6 +COMPILE_DEPS = [
7 + '//lib:CORE_DEPS',
8 + '//incubator/api:onos-incubator-api',
9 + '//lib:org.apache.servicemix.bundles.snmp4j',
10 + '//lib:snmp-core',
11 + '//lib:bti7000',
12 + '//lib:mibs-net-snmp',
13 + '//lib:mibs-rfc',
14 +]
15 +
16 +java_library(
17 + name = CURRENT_NAME,
18 + srcs = glob([SRC + '/*.java']),
19 + deps = COMPILE_DEPS,
20 + visibility = ['PUBLIC'],
21 +)
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<!--
3 + ~ Copyright 2016 Open Networking Laboratory
4 + ~
5 + ~ Licensed under the Apache License, Version 2.0 (the "License");
6 + ~ you may not use this file except in compliance with the License.
7 + ~ You may obtain a copy of the License at
8 + ~
9 + ~ http://www.apache.org/licenses/LICENSE-2.0
10 + ~
11 + ~ Unless required by applicable law or agreed to in writing, software
12 + ~ distributed under the License is distributed on an "AS IS" BASIS,
13 + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 + ~ See the License for the specific language governing permissions and
15 + ~ limitations under the License.
16 + -->
17 +
18 +<project xmlns="http://maven.apache.org/POM/4.0.0"
19 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
20 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
21 + <parent>
22 + <artifactId>onos-snmp-protocol</artifactId>
23 + <groupId>org.onosproject</groupId>
24 + <version>1.6.0-SNAPSHOT</version>
25 + <relativePath>../pom.xml</relativePath>
26 + </parent>
27 + <modelVersion>4.0.0</modelVersion>
28 +
29 + <artifactId>onos-snmp-api</artifactId>
30 + <packaging>bundle</packaging>
31 +
32 + <dependencies>
33 + <dependency>
34 + <groupId>org.onosproject</groupId>
35 + <artifactId>onos-incubator-api</artifactId>
36 + <version>1.6.0-SNAPSHOT</version>
37 + </dependency>
38 + </dependencies>
39 +
40 +
41 +</project>
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.snmp;
18 +
19 +import com.btisystems.pronx.ems.core.snmp.ISnmpSession;
20 +import org.onosproject.incubator.net.faultmanagement.alarm.DefaultAlarm;
21 +import org.onosproject.net.DeviceId;
22 +
23 +import java.io.IOException;
24 +import java.util.Collection;
25 +
26 +/**
27 + * Snmp Controller.
28 + */
29 +public interface SnmpController {
30 +
31 + /**
32 + * Return all the devices that this controller has notion of.
33 + * @return Set of all Snmp devices
34 + */
35 + Collection<SnmpDevice> getDevices();
36 +
37 + /**
38 + * Gets a device for a specific deviceId.
39 + * @param deviceId device id of the device
40 + * @return SnmpDevice for given deviceId
41 + */
42 + SnmpDevice getDevice(DeviceId deviceId);
43 +
44 + /**
45 + * Removes a specific device.
46 + * @param deviceId device id of the device to be removed
47 + */
48 + void removeDevice(DeviceId deviceId);
49 +
50 + /**
51 + * Add a device with a specific DeviceId.
52 + * @param deviceId deviceId of the device
53 + * @param device device to add to this controller
54 + */
55 + void addDevice(DeviceId deviceId, SnmpDevice device);
56 +
57 + /**
58 + * Gets an Instance of ISnmpSession for a specific device.
59 + *
60 + * @param deviceId device to retrieve the session for.
61 + * @return ISnmp session.
62 + * @throws IOException if the session can't be established.
63 + */
64 + ISnmpSession getSession(DeviceId deviceId) throws IOException;
65 +
66 + /**
67 + * Creates an error alarm if the interaction with the device failed.
68 + *
69 + * @param deviceId the device with a failed interaction
70 + * @return default alarm error
71 + */
72 + DefaultAlarm buildWalkFailedAlarm(DeviceId deviceId);
73 +}
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.snmp;
18 +
19 +import org.onosproject.net.DeviceId;
20 +
21 +/**
22 + * Abstraction a default Snmp Device.
23 + */
24 +public interface SnmpDevice {
25 +
26 + /**
27 + * Returns host IP and host Port, used by this particular SNMP Device.
28 + *
29 + * @return Device Information.
30 + */
31 + String deviceInfo();
32 +
33 + /**
34 + * Terminates the device connection.
35 + */
36 + void disconnect();
37 +
38 + /**
39 + * Retrieves the device state.
40 + *
41 + * @return true if connected
42 + */
43 + boolean isReachable();
44 +
45 + /**
46 + * Returns the IP used connect ssh on the device.
47 + *
48 + * @return SNMP Device IP
49 + */
50 + String getSnmpHost();
51 +
52 + /**
53 + * Returns the SSH Port used connect the device.
54 + *
55 + * @return SSH Port number
56 + */
57 + int getSnmpPort();
58 +
59 + /**
60 + * Retrieves the username of the device.
61 + *
62 + * @return username
63 + */
64 + String getUsername();
65 +
66 + /**
67 + * Retrieves the community (password) of the device.
68 + *
69 + * @return password
70 + */
71 + String getCommunity();
72 +
73 + /**
74 + * Return the SNMP device deviceID.
75 + *
76 + * @return DeviceId
77 + */
78 + DeviceId deviceId();
79 +}
...@@ -13,27 +13,8 @@ ...@@ -13,27 +13,8 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 -package org.onosproject.provider.snmp.device.impl;
17 -
18 -import com.btisystems.pronx.ems.core.snmp.ISnmpSession;
19 -import org.onosproject.net.Device;
20 -import org.onosproject.net.device.DefaultDeviceDescription;
21 -import org.onosproject.net.device.DeviceDescription;
22 -import org.slf4j.Logger;
23 -import org.slf4j.LoggerFactory;
24 16
25 /** 17 /**
26 - * Device description provider for Lumentum SDN ROADMs. 18 + * Package for SNMP apis interfaces.
27 - * @deprecated 1.5.0 Falcon, not compliant with ONOS SB and driver architecture.
28 */ 19 */
29 -@Deprecated 20 +package org.onosproject.snmp;
30 -public class LumentumDeviceDescriptionProvider implements SnmpDeviceDescriptionProvider {
31 -
32 - private static final Logger log = LoggerFactory.getLogger(LumentumDeviceDescriptionProvider.class);
33 -
34 - @Override
35 - public DeviceDescription populateDescription(ISnmpSession session, DeviceDescription description) {
36 - return new DefaultDeviceDescription(description.deviceUri(), Device.Type.ROADM,
37 - "Lumentum", "SDN ROADM", "1.0", "v1", description.chassisId(), description.annotations());
38 - }
39 -}
......
1 +SRC = 'src/main/java/org/onosproject/**/'
2 +TEST = 'src/test/java/org/onosproject/**/'
3 +CURRENT_NAME = 'onos-snmp-ctl'
4 +CURRENT_TARGET = ':' + CURRENT_NAME
5 +
6 +COMPILE_DEPS = [
7 + '//lib:CORE_DEPS',
8 + '//incubator/api:onos-incubator-api',
9 + '//protocols/snmp/api:onos-snmp-api',
10 + '//lib:org.apache.servicemix.bundles.snmp4j',
11 + '//lib:snmp-core',
12 + '//lib:bti7000',
13 + '//lib:mibs-net-snmp',
14 + '//lib:mibs-rfc',
15 +]
16 +
17 +TEST_DEPS = [
18 + '//lib:TEST',
19 +]
20 +
21 +java_library(
22 + name = CURRENT_NAME,
23 + srcs = glob([SRC + '/*.java']),
24 + deps = COMPILE_DEPS,
25 + visibility = ['PUBLIC'],
26 +)
27 +
28 +java_test(
29 + name = 'tests',
30 + srcs = glob([TEST + '/*.java']),
31 + deps = COMPILE_DEPS +
32 + TEST_DEPS +
33 + [CURRENT_TARGET],
34 + source_under_test = [CURRENT_TARGET],
35 +)
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<!--
3 + ~ Copyright 2016 Open Networking Laboratory
4 + ~
5 + ~ Licensed under the Apache License, Version 2.0 (the "License");
6 + ~ you may not use this file except in compliance with the License.
7 + ~ You may obtain a copy of the License at
8 + ~
9 + ~ http://www.apache.org/licenses/LICENSE-2.0
10 + ~
11 + ~ Unless required by applicable law or agreed to in writing, software
12 + ~ distributed under the License is distributed on an "AS IS" BASIS,
13 + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 + ~ See the License for the specific language governing permissions and
15 + ~ limitations under the License.
16 + -->
17 +
18 +<project xmlns="http://maven.apache.org/POM/4.0.0"
19 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
20 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
21 + <parent>
22 + <artifactId>onos-snmp-protocol</artifactId>
23 + <groupId>org.onosproject</groupId>
24 + <version>1.6.0-SNAPSHOT</version>
25 + </parent>
26 + <modelVersion>4.0.0</modelVersion>
27 +
28 + <artifactId>onos-snmp-ctl</artifactId>
29 + <packaging>bundle</packaging>
30 +
31 + <dependencies>
32 + <dependency>
33 + <groupId>org.onosproject</groupId>
34 + <artifactId>onos-snmp-api</artifactId>
35 + <version>1.6.0-SNAPSHOT</version>
36 + </dependency>
37 + <dependency>
38 + <groupId>org.osgi</groupId>
39 + <artifactId>org.osgi.compendium</artifactId>
40 + </dependency>
41 + <dependency>
42 + <groupId>org.apache.felix</groupId>
43 + <artifactId>org.apache.felix.scr.annotations</artifactId>
44 + </dependency>
45 +
46 + <dependency>
47 + <groupId>org.onosproject</groupId>
48 + <artifactId>onos-incubator-api</artifactId>
49 + <version>1.6.0-SNAPSHOT</version>
50 + </dependency>
51 + </dependencies>
52 +
53 +
54 +</project>
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.snmp.ctl;
18 +
19 +import com.btisystems.pronx.ems.core.snmp.DefaultSnmpConfigurationFactory;
20 +import com.btisystems.pronx.ems.core.snmp.ISnmpConfiguration;
21 +import com.btisystems.pronx.ems.core.snmp.ISnmpSession;
22 +import com.btisystems.pronx.ems.core.snmp.ISnmpSessionFactory;
23 +import com.btisystems.pronx.ems.core.snmp.SnmpSessionFactory;
24 +import com.btisystems.pronx.ems.core.snmp.V2cSnmpConfiguration;
25 +import com.google.common.base.Preconditions;
26 +import org.apache.felix.scr.annotations.Activate;
27 +import org.apache.felix.scr.annotations.Deactivate;
28 +import org.apache.felix.scr.annotations.Service;
29 +import org.onosproject.incubator.net.faultmanagement.alarm.Alarm;
30 +import org.onosproject.incubator.net.faultmanagement.alarm.DefaultAlarm;
31 +import org.onosproject.net.DeviceId;
32 +import org.onosproject.snmp.SnmpController;
33 +import org.onosproject.snmp.SnmpDevice;
34 +import org.osgi.service.component.ComponentContext;
35 +import org.osgi.service.component.annotations.Component;
36 +import org.slf4j.Logger;
37 +import org.slf4j.LoggerFactory;
38 +
39 +import java.io.IOException;
40 +import java.util.Collection;
41 +import java.util.HashMap;
42 +import java.util.Map;
43 +import java.util.concurrent.ConcurrentHashMap;
44 +
45 +/**
46 + * Default implementation of the SNMP sub-controller.
47 + */
48 +@Component(immediate = true)
49 +@Service
50 +public class DefaultSnmpController implements SnmpController {
51 +
52 + private final Logger log = LoggerFactory
53 + .getLogger(getClass());
54 +
55 + private ISnmpSessionFactory sessionFactory;
56 +
57 + private final Map<DeviceId, ISnmpSession> sessionMap = new HashMap<>();
58 + protected Map<DeviceId, SnmpDevice> snmpDeviceMap = new ConcurrentHashMap<>();
59 +
60 + @Activate
61 + public void activate(ComponentContext context) {
62 + sessionFactory = new SnmpSessionFactory(
63 + new DefaultSnmpConfigurationFactory(new V2cSnmpConfiguration()));
64 + log.info("Started");
65 + }
66 +
67 + @Deactivate
68 + public void deactivate() {
69 + snmpDeviceMap.clear();
70 + log.info("Stopped");
71 + }
72 +
73 + @Override
74 + public ISnmpSession getSession(DeviceId deviceId) throws IOException {
75 + if (!sessionMap.containsKey(deviceId)) {
76 + SnmpDevice device = snmpDeviceMap.get(deviceId);
77 + String ipAddress = null;
78 + int port = -1;
79 + if (device != null) {
80 + ipAddress = device.getSnmpHost();
81 + port = device.getSnmpPort();
82 + } else {
83 + String[] deviceComponents = deviceId.toString().split(":");
84 + if (deviceComponents.length > 1) {
85 + ipAddress = deviceComponents[1];
86 + port = Integer.parseInt(deviceComponents[2]);
87 +
88 + } else {
89 + log.error("Cannot obtain correct information from device id", deviceId);
90 + }
91 + }
92 + Preconditions.checkNotNull(ipAddress, "ip address is empty, cannot start session");
93 + Preconditions.checkArgument(port != -1, "port is incorrect, cannot start session");
94 +
95 + ISnmpConfiguration config = new V2cSnmpConfiguration();
96 + config.setPort(port);
97 + sessionMap.put(deviceId, sessionFactory.createSession(config, ipAddress));
98 + }
99 + return sessionMap.get(deviceId);
100 + }
101 +
102 + @Override
103 + public Collection<SnmpDevice> getDevices() {
104 + return snmpDeviceMap.values();
105 + }
106 +
107 + @Override
108 + public SnmpDevice getDevice(DeviceId did) {
109 + return snmpDeviceMap.get(did);
110 + }
111 +
112 + @Override
113 + public void removeDevice(DeviceId did) {
114 + snmpDeviceMap.remove(did);
115 + }
116 +
117 + @Override
118 + public void addDevice(DeviceId did, SnmpDevice device) {
119 + snmpDeviceMap.put(did, device);
120 + }
121 +
122 + @Override
123 + public DefaultAlarm buildWalkFailedAlarm(DeviceId deviceId) {
124 + return new DefaultAlarm.Builder(
125 + deviceId, "SNMP alarm retrieval failed",
126 + Alarm.SeverityLevel.CRITICAL,
127 + System.currentTimeMillis()).build();
128 + }
129 +}
1 /* 1 /*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2016 Open Networking Laboratory
3 * 3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License. 5 * you may not use this file except in compliance with the License.
...@@ -13,122 +13,105 @@ ...@@ -13,122 +13,105 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 -package org.onosproject.provider.snmp.device.impl; 16 +package org.onosproject.snmp.ctl;
17 17
18 -import static com.google.common.base.Preconditions.checkNotNull; 18 +import org.onosproject.net.DeviceId;
19 -import static org.slf4j.LoggerFactory.getLogger; 19 +import org.onosproject.snmp.SnmpDevice;
20 +import org.slf4j.Logger;
20 21
22 +import java.net.URI;
23 +import java.net.URISyntaxException;
21 24
22 -import org.slf4j.Logger; 25 +import static com.google.common.base.Preconditions.checkNotNull;
26 +import static org.slf4j.LoggerFactory.getLogger;
23 27
24 /** 28 /**
25 * This is a logical representation of actual SNMP device, carrying all the necessary information to connect and execute 29 * This is a logical representation of actual SNMP device, carrying all the necessary information to connect and execute
26 * SNMP operations. 30 * SNMP operations.
27 */ 31 */
28 -public class SnmpDevice { 32 +public class DefaultSnmpDevice implements SnmpDevice {
29 33
30 - private final Logger log = getLogger(SnmpDevice.class); 34 + private final Logger log = getLogger(DefaultSnmpDevice.class);
31 35
32 36
33 private static final int DEFAULT_SNMP_PORT = 161; 37 private static final int DEFAULT_SNMP_PORT = 161;
34 38
39 + private static final String SCHEME = "snmp";
40 +
35 private final String snmpHost; 41 private final String snmpHost;
42 + private final DeviceId deviceId;
36 private int snmpPort = DEFAULT_SNMP_PORT; 43 private int snmpPort = DEFAULT_SNMP_PORT;
44 + private final String username;
45 + //Community is a conventional name for password in SNMP.
37 private final String community; 46 private final String community;
38 private boolean reachable = false; 47 private boolean reachable = false;
39 48
40 - private DeviceState deviceState = DeviceState.INVALID;
41 49
42 - protected SnmpDevice(String snmpHost, int snmpPort, String community) { 50 + public DefaultSnmpDevice(String snmpHost, int snmpPort, String username, String community) {
43 51
44 this.snmpHost = checkNotNull(snmpHost, "SNMP Device IP cannot be null"); 52 this.snmpHost = checkNotNull(snmpHost, "SNMP Device IP cannot be null");
45 - this.snmpPort = checkNotNull(snmpPort, "SNMP Device snmp port cannot be null"); 53 + this.snmpPort = checkNotNull(snmpPort, "SNMP Device port cannot be null");
54 + this.username = username;
46 this.community = community; 55 this.community = community;
47 - } 56 + this.deviceId = createDeviceId();
48 -
49 - /**
50 - * This will try to connect to SNMP device.
51 - *
52 - */
53 - public void init() {
54 -
55 reachable = true; 57 reachable = true;
56 } 58 }
57 59
58 - /** 60 + @Override
59 - * This would return host IP and host Port, used by this particular SNMP Device.
60 - *
61 - * @return Device Information.
62 - */
63 public String deviceInfo() { 61 public String deviceInfo() {
64 return new StringBuilder("host: ").append(snmpHost).append(". port: ") 62 return new StringBuilder("host: ").append(snmpHost).append(". port: ")
65 .append(snmpPort).toString(); 63 .append(snmpPort).toString();
66 } 64 }
67 65
68 - /** 66 + @Override
69 - * This will terminate the device connection.
70 - */
71 public void disconnect() { 67 public void disconnect() {
72 log.info("disconnect"); 68 log.info("disconnect");
73 reachable = false; 69 reachable = false;
74 } 70 }
75 71
76 - /** 72 + @Override
77 - * This api is intended to know whether the device is connected or not.
78 - *
79 - * @return true if connected
80 - */
81 public boolean isReachable() { 73 public boolean isReachable() {
82 return reachable; 74 return reachable;
83 } 75 }
84 76
85 - /** 77 + @Override
86 - * This will return the IP used connect ssh on the device.
87 - *
88 - * @return SNMP Device IP
89 - */
90 public String getSnmpHost() { 78 public String getSnmpHost() {
91 return snmpHost; 79 return snmpHost;
92 } 80 }
93 81
94 - /** 82 +
95 - * This will return the SSH Port used connect the device. 83 + @Override
96 - *
97 - * @return SSH Port number
98 - */
99 public int getSnmpPort() { 84 public int getSnmpPort() {
100 return snmpPort; 85 return snmpPort;
101 } 86 }
102 87
103 - public String getCommunity() { 88 + @Override
104 - return community; 89 + public String getUsername() {
90 + return username;
105 } 91 }
106 92
107 - /** 93 + @Override
108 - * Retrieve current state of the device. 94 + public String getCommunity() {
109 - * 95 + return community;
110 - * @return Current Device State
111 - */
112 - public DeviceState getDeviceState() {
113 - return deviceState;
114 } 96 }
115 97
116 - /** 98 + @Override
117 - * This is set the state information for the device. 99 + public DeviceId deviceId() {
118 - * 100 + return deviceId;
119 - * @param deviceState Next Device State
120 - */
121 - public void setDeviceState(DeviceState deviceState) {
122 - this.deviceState = deviceState;
123 } 101 }
124 102
125 - /** 103 + private DeviceId createDeviceId() {
126 - * Check whether the device is in Active state. 104 + String additionalSsp = new StringBuilder(
127 - * 105 + snmpHost).append(":")
128 - * @return true if the device is Active 106 + .append(snmpPort).toString();
129 - */ 107 + try {
130 - public boolean isActive() { 108 + return DeviceId.deviceId(new URI(SCHEME, additionalSsp,
131 - return deviceState == DeviceState.ACTIVE; 109 + null));
110 + } catch (URISyntaxException e) {
111 + log.error("Syntax Error while creating URI for the device: "
112 + + additionalSsp
113 + + " couldn't persist the device onto the store", e);
114 + throw new IllegalArgumentException("Can't create device ID from " + additionalSsp, e);
115 + }
132 } 116 }
133 -
134 } 117 }
......
1 /* 1 /*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
2 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * Licensed under the Apache License, Version 2.0 (the "License");
3 * you may not use this file except in compliance with the License. 5 * you may not use this file except in compliance with the License.
4 * You may obtain a copy of the License at 6 * You may obtain a copy of the License at
5 * 7 *
6 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
7 * 9 *
8 * Unless required by applicable law or agreed to in writing, software 10 * Unless required by applicable law or agreed to in writing, software
9 * distributed under the License is distributed on an "AS IS" BASIS, 11 * distributed under the License is distributed on an "AS IS" BASIS,
...@@ -11,25 +13,8 @@ ...@@ -11,25 +13,8 @@
11 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
12 * limitations under the License. 14 * limitations under the License.
13 */ 15 */
14 -package org.onosproject.provider.snmp.device.impl;
15 -
16 -import com.btisystems.pronx.ems.core.snmp.ISnmpSession;
17 -import org.onosproject.net.device.DeviceDescription;
18 16
19 /** 17 /**
20 - * Abstraction of an entity which updates a device description with information retrieved via SNMP. 18 + * Package for implementation fo SNMP elements.
21 - * @deprecated 1.5.0 Falcon, not compliant with ONOS SB and driver architecture.
22 */ 19 */
23 -@Deprecated 20 +package org.onosproject.snmp.ctl;
24 -public interface SnmpDeviceDescriptionProvider {
25 -
26 - /**
27 - * Generated an updated device description.
28 - * @deprecated 1.5.0 Falcon
29 - * @param session SNMP session
30 - * @param description old device description
31 - * @return new updated description
32 - */
33 - @Deprecated
34 - DeviceDescription populateDescription(ISnmpSession session, DeviceDescription description);
35 -}
......
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<!--
3 + ~ Copyright 2016 Open Networking Laboratory
4 + ~
5 + ~ Licensed under the Apache License, Version 2.0 (the "License");
6 + ~ you may not use this file except in compliance with the License.
7 + ~ You may obtain a copy of the License at
8 + ~
9 + ~ http://www.apache.org/licenses/LICENSE-2.0
10 + ~
11 + ~ Unless required by applicable law or agreed to in writing, software
12 + ~ distributed under the License is distributed on an "AS IS" BASIS,
13 + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 + ~ See the License for the specific language governing permissions and
15 + ~ limitations under the License.
16 + -->
17 +
18 +<project xmlns="http://maven.apache.org/POM/4.0.0"
19 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
20 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
21 + <parent>
22 + <artifactId>onos-protocols</artifactId>
23 + <groupId>org.onosproject</groupId>
24 + <version>1.6.0-SNAPSHOT</version>
25 + </parent>
26 + <modelVersion>4.0.0</modelVersion>
27 +
28 + <artifactId>onos-snmp-protocol</artifactId>
29 + <packaging>pom</packaging>
30 + <modules>
31 + <module>api</module>
32 + <module>ctl</module>
33 + </modules>
34 + <dependencies>
35 + <dependency>
36 + <groupId>com.btisystems</groupId>
37 + <artifactId>snmp-core</artifactId>
38 + <version>1.3-SNAPSHOT</version>
39 + </dependency>
40 + <dependency>
41 + <groupId>com.btisystems.mibbler.mibs</groupId>
42 + <artifactId>bti7000</artifactId>
43 + <version>1.0-SNAPSHOT</version>
44 + </dependency>
45 + <dependency>
46 + <groupId>com.btisystems.mibbler.mibs</groupId>
47 + <artifactId>net-snmp</artifactId>
48 + <version>1.0-SNAPSHOT</version>
49 + </dependency>
50 + <dependency>
51 + <groupId>org.onosproject</groupId>
52 + <artifactId>onos-api</artifactId>
53 + <version>1.6.0-SNAPSHOT</version>
54 + </dependency>
55 + </dependencies>
56 +
57 +
58 +</project>
...\ No newline at end of file ...\ No newline at end of file
...@@ -11,9 +11,8 @@ COMPILE_DEPS = [ ...@@ -11,9 +11,8 @@ COMPILE_DEPS = [
11 '//lib:bti7000', 11 '//lib:bti7000',
12 '//lib:mibs-net-snmp', 12 '//lib:mibs-net-snmp',
13 '//lib:mibs-rfc', 13 '//lib:mibs-rfc',
14 - '//protocols/ovsdb/api:onos-ovsdb-api',
15 - '//protocols/ovsdb/rfc:onos-ovsdb-rfc',
16 '//incubator/api:onos-incubator-api', 14 '//incubator/api:onos-incubator-api',
15 + '//protocols/snmp/api:onos-snmp-api',
17 ] 16 ]
18 17
19 TEST_DEPS = [ 18 TEST_DEPS = [
......
...@@ -21,4 +21,12 @@ ...@@ -21,4 +21,12 @@
21 <description>${project.description}</description> 21 <description>${project.description}</description>
22 <artifact>mvn:${project.groupId}/onos-snmp-provider-device/${project.version}</artifact> 22 <artifact>mvn:${project.groupId}/onos-snmp-provider-device/${project.version}</artifact>
23 <artifact>mvn:${project.groupId}/onos-snmp-provider-alarm/${project.version}</artifact> 23 <artifact>mvn:${project.groupId}/onos-snmp-provider-alarm/${project.version}</artifact>
24 +
25 + <artifact>mvn:${project.groupId}/onos-snmp-api/${project.version}</artifact>
26 + <artifact>mvn:${project.groupId}/onos-snmp-ctl/${project.version}</artifact>
27 +
28 + <artifact>mvn:com.btisystems/snmp-core/1.3-SNAPSHOT</artifact>
29 + <artifact>mvn:com.btisystems.mibbler.mibs/bti7000/1.0-SNAPSHOT</artifact>
30 + <artifact>mvn:com.btisystems.mibbler.mibs/net-snmp/1.0-SNAPSHOT</artifact>
31 +
24 </app> 32 </app>
......
...@@ -19,9 +19,12 @@ ...@@ -19,9 +19,12 @@
19 description="${project.description}"> 19 description="${project.description}">
20 <feature>onos-api</feature> 20 <feature>onos-api</feature>
21 <bundle>mvn:io.netty/netty/3.9.2.Final</bundle> 21 <bundle>mvn:io.netty/netty/3.9.2.Final</bundle>
22 - <bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.snmp4j/2.3.4_1</bundle> 22 + <bundle>mvn:${project.groupId}/onos-snmp-api/${project.version}</bundle>
23 + <bundle>mvn:${project.groupId}/onos-snmp-ctl/${project.version}</bundle>
23 <bundle>mvn:${project.groupId}/onos-snmp-provider-device/${project.version}</bundle> 24 <bundle>mvn:${project.groupId}/onos-snmp-provider-device/${project.version}</bundle>
24 <bundle>mvn:${project.groupId}/onos-snmp-provider-alarm/${project.version}</bundle> 25 <bundle>mvn:${project.groupId}/onos-snmp-provider-alarm/${project.version}</bundle>
26 +
27 + <bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.snmp4j/2.3.4_1</bundle>
25 <bundle>mvn:com.btisystems/snmp-core/1.3-SNAPSHOT</bundle> 28 <bundle>mvn:com.btisystems/snmp-core/1.3-SNAPSHOT</bundle>
26 <bundle>mvn:com.btisystems.mibbler.mibs/bti7000/1.0-SNAPSHOT</bundle> 29 <bundle>mvn:com.btisystems.mibbler.mibs/bti7000/1.0-SNAPSHOT</bundle>
27 <bundle>mvn:com.btisystems.mibbler.mibs/net-snmp/1.0-SNAPSHOT</bundle> 30 <bundle>mvn:com.btisystems.mibbler.mibs/net-snmp/1.0-SNAPSHOT</bundle>
......
...@@ -11,9 +11,9 @@ COMPILE_DEPS = [ ...@@ -11,9 +11,9 @@ COMPILE_DEPS = [
11 '//lib:bti7000', 11 '//lib:bti7000',
12 '//lib:mibs-net-snmp', 12 '//lib:mibs-net-snmp',
13 '//lib:mibs-rfc', 13 '//lib:mibs-rfc',
14 - '//protocols/ovsdb/api:onos-ovsdb-api',
15 - '//protocols/ovsdb/rfc:onos-ovsdb-rfc',
16 '//incubator/api:onos-incubator-api', 14 '//incubator/api:onos-incubator-api',
15 + '//protocols/snmp/api:onos-snmp-api',
16 + '//protocols/snmp/ctl:onos-snmp-ctl',
17 ] 17 ]
18 18
19 TEST_DEPS = [ 19 TEST_DEPS = [
......
...@@ -36,20 +36,50 @@ ...@@ -36,20 +36,50 @@
36 <groupId>org.osgi</groupId> 36 <groupId>org.osgi</groupId>
37 <artifactId>org.osgi.compendium</artifactId> 37 <artifactId>org.osgi.compendium</artifactId>
38 </dependency> 38 </dependency>
39 - <!-- <dependency> 39 + <dependency>
40 - <groupId>javax.ws.rs</groupId> 40 + <groupId>org.onosproject</groupId>
41 - <artifactId>javax.ws.rs-api</artifactId> 41 + <artifactId>onos-snmp-api</artifactId>
42 - <version>2.0.1</version> 42 + <version>1.6.0-SNAPSHOT</version>
43 </dependency> 43 </dependency>
44 <dependency> 44 <dependency>
45 <groupId>org.onosproject</groupId> 45 <groupId>org.onosproject</groupId>
46 - <artifactId>onos-incubator-api</artifactId> 46 + <artifactId>onos-snmp-ctl</artifactId>
47 + <version>1.6.0-SNAPSHOT</version>
48 + </dependency>
49 + <dependency>
50 + <groupId>org.apache.servicemix.bundles</groupId>
51 + <artifactId>org.apache.servicemix.bundles.snmp4j</artifactId>
52 + <version>2.3.4_1</version>
53 + <exclusions>
54 + <exclusion>
55 + <artifactId>log4j</artifactId>
56 + <groupId>log4j</groupId>
57 + </exclusion>
58 + </exclusions>
59 + </dependency>
60 +
61 + <dependency>
62 + <groupId>com.btisystems</groupId>
63 + <artifactId>snmp-core</artifactId>
64 + <version>1.3-SNAPSHOT</version>
65 + </dependency>
66 +
67 + <dependency>
68 + <groupId>com.btisystems.mibbler.mibs</groupId>
69 + <artifactId>bti7000</artifactId>
70 + <version>1.0-SNAPSHOT</version>
71 + </dependency>
72 +
73 + <dependency>
74 + <groupId>com.btisystems.mibbler.mibs</groupId>
75 + <artifactId>net-snmp</artifactId>
76 + <version>1.0-SNAPSHOT</version>
47 </dependency> 77 </dependency>
48 <dependency> 78 <dependency>
49 <groupId>org.onosproject</groupId> 79 <groupId>org.onosproject</groupId>
50 - <artifactId>onos-core-serializers</artifactId> 80 + <artifactId>onos-core-net</artifactId>
51 - <version>${project.version}</version> 81 + <version>1.6.0-SNAPSHOT</version>
52 - </dependency>--> 82 + </dependency>
53 </dependencies> 83 </dependencies>
54 <build> 84 <build>
55 <plugins> 85 <plugins>
......
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.provider.snmp.device.impl;
18 +
19 +/*
20 + * Copyright 2015 Open Networking Laboratory
21 + *
22 + * Licensed under the Apache License, Version 2.0 (the "License");
23 + * you may not use this file except in compliance with the License.
24 + * You may obtain a copy of the License at
25 + *
26 + * http://www.apache.org/licenses/LICENSE-2.0
27 + *
28 + * Unless required by applicable law or agreed to in writing, software
29 + * distributed under the License is distributed on an "AS IS" BASIS,
30 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31 + * See the License for the specific language governing permissions and
32 + * limitations under the License.
33 + */
34 +
35 +import com.fasterxml.jackson.databind.JsonNode;
36 +import com.google.common.annotations.Beta;
37 +import com.google.common.collect.Sets;
38 +import org.onlab.packet.IpAddress;
39 +import org.onosproject.core.ApplicationId;
40 +import org.onosproject.incubator.net.config.basics.ConfigException;
41 +import org.onosproject.net.config.Config;
42 +
43 +import java.util.Set;
44 +
45 +/**
46 + * Configuration decoder for SNMP provider.
47 + */
48 +@Beta
49 +public class SnmpProviderConfig extends Config<ApplicationId> {
50 +
51 + public static final String CONFIG_VALUE_ERROR = "Error parsing config value";
52 + private static final String IP = "ip";
53 + private static final int DEFAULT_TCP_PORT = 830;
54 + private static final String PORT = "port";
55 + private static final String NAME = "username";
56 + private static final String PASSWORD = "password";
57 +
58 + /**
59 + * Retrieves a set of SnmpDeviceInfo containing all the device
60 + * configuration pertaining to the SNMP device provider.
61 + * @return set of device configurations.
62 + *
63 + * @throws ConfigException if configuration can't be read
64 + */
65 + public Set<SnmpDeviceInfo> getDevicesInfo() throws ConfigException {
66 + Set<SnmpDeviceInfo> deviceInfos = Sets.newHashSet();
67 +
68 + try {
69 + for (JsonNode node : array) {
70 + String ip = node.path(IP).asText();
71 + IpAddress ipAddr = ip.isEmpty() ? null : IpAddress.valueOf(ip);
72 + int port = node.path(PORT).asInt(DEFAULT_TCP_PORT);
73 + String name = node.path(NAME).asText();
74 + String password = node.path(PASSWORD).asText();
75 + deviceInfos.add(new SnmpDeviceInfo(ipAddr, port, name, password));
76 +
77 + }
78 + } catch (IllegalArgumentException e) {
79 + throw new ConfigException(CONFIG_VALUE_ERROR, e);
80 + }
81 +
82 + return deviceInfos;
83 + }
84 +
85 + /**
86 + * Contains information about a SNMP device retrieved form the net-cfg subsystem.
87 + */
88 + public class SnmpDeviceInfo {
89 + private final IpAddress ip;
90 + private final int port;
91 + private final String username;
92 + private final String password;
93 +
94 + /**
95 + * Build an information object containing the given device specifics.
96 + * @param ip ip
97 + * @param port port
98 + * @param username username
99 + * @param password password (a.k.a community in SNMP)
100 + */
101 + public SnmpDeviceInfo(IpAddress ip, int port, String username, String password) {
102 + this.ip = ip;
103 + this.port = port;
104 + this.username = username;
105 + this.password = password;
106 + }
107 +
108 + /**
109 + * Returns IpAddress of the device.
110 + * @return ip
111 + */
112 + public IpAddress ip() {
113 + return ip;
114 + }
115 +
116 + /**
117 + * Returns port of the device.
118 + * @return port
119 + */
120 + public int port() {
121 + return port;
122 + }
123 +
124 + /**
125 + * Returns username of the device.
126 + * @return username
127 + */
128 + public String username() {
129 + return username;
130 + }
131 +
132 + /**
133 + * Returns password of the device.
134 + * @return password
135 + */
136 + public String password() {
137 + return password;
138 + }
139 + }
140 +
141 +}
142 +
...@@ -36,38 +36,7 @@ ...@@ -36,38 +36,7 @@
36 <module>app</module> 36 <module>app</module>
37 <module>alarm</module> 37 <module>alarm</module>
38 </modules> 38 </modules>
39 - 39 +
40 - <dependencies>
41 - <dependency>
42 - <groupId>org.apache.servicemix.bundles</groupId>
43 - <artifactId>org.apache.servicemix.bundles.snmp4j</artifactId>
44 - <version>2.3.4_1</version>
45 - <exclusions>
46 - <exclusion>
47 - <artifactId>log4j</artifactId>
48 - <groupId>log4j</groupId>
49 - </exclusion>
50 - </exclusions>
51 - </dependency>
52 -
53 - <dependency>
54 - <groupId>com.btisystems</groupId>
55 - <artifactId>snmp-core</artifactId>
56 - <version>1.3-SNAPSHOT</version>
57 - </dependency>
58 -
59 - <dependency>
60 - <groupId>com.btisystems.mibbler.mibs</groupId>
61 - <artifactId>bti7000</artifactId>
62 - <version>1.0-SNAPSHOT</version>
63 - </dependency>
64 -
65 - <dependency>
66 - <groupId>com.btisystems.mibbler.mibs</groupId>
67 - <artifactId>net-snmp</artifactId>
68 - <version>1.0-SNAPSHOT</version>
69 - </dependency>
70 - </dependencies>
71 <repositories> 40 <repositories>
72 <repository> 41 <repository>
73 <!-- TODO move over to release snmp-core when it becomes available. ONOS-3646 --> 42 <!-- TODO move over to release snmp-core when it becomes available. ONOS-3646 -->
......