kmcpeake | b172d5f | 2015-12-10 11:30:43 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 3 | * you may not use this file except in compliance with the License. |
| 4 | * You may obtain a copy of the License at |
| 5 | * |
| 6 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | * |
| 8 | * Unless required by applicable law or agreed to in writing, software |
| 9 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | * See the License for the specific language governing permissions and |
| 12 | * limitations under the License. |
| 13 | */ |
| 14 | package org.onosproject.provider.snmp.device.impl; |
| 15 | |
| 16 | import com.btisystems.mibbler.mibs.bti7000.bti7000_13_2_0.I_Device; |
| 17 | import com.btisystems.mibbler.mibs.bti7000.bti7000_13_2_0._OidRegistry; |
| 18 | import com.btisystems.pronx.ems.core.model.ClassRegistry; |
| 19 | import com.btisystems.pronx.ems.core.model.IClassRegistry; |
| 20 | import com.btisystems.pronx.ems.core.model.NetworkDevice; |
| 21 | import com.btisystems.pronx.ems.core.snmp.ISnmpSession; |
kmcpeake | b172d5f | 2015-12-10 11:30:43 +0000 | [diff] [blame] | 22 | import org.onosproject.net.device.DefaultDeviceDescription; |
| 23 | import org.onosproject.net.device.DeviceDescription; |
| 24 | import org.slf4j.Logger; |
kmcpeake | b172d5f | 2015-12-10 11:30:43 +0000 | [diff] [blame] | 25 | import org.snmp4j.smi.OID; |
| 26 | |
Marc De Leenheer | c662d32 | 2016-02-18 16:05:10 -0800 | [diff] [blame] | 27 | import java.io.IOException; |
| 28 | import java.util.Arrays; |
| 29 | |
| 30 | import static org.slf4j.LoggerFactory.getLogger; |
| 31 | |
kmcpeake | b172d5f | 2015-12-10 11:30:43 +0000 | [diff] [blame] | 32 | /** |
| 33 | * A vendor-specific implementation supporting BTI Systems BTI-7000 equipment. |
Andrea Campanella | 3eca4a8 | 2016-02-10 17:35:14 -0800 | [diff] [blame] | 34 | * @deprecated 1.5.0 Falcon, not compliant with ONOS SB and driver architecture. |
kmcpeake | b172d5f | 2015-12-10 11:30:43 +0000 | [diff] [blame] | 35 | */ |
Andrea Campanella | 3eca4a8 | 2016-02-10 17:35:14 -0800 | [diff] [blame] | 36 | @Deprecated |
kmcpeake | b172d5f | 2015-12-10 11:30:43 +0000 | [diff] [blame] | 37 | public class Bti7000DeviceDescriptionProvider implements SnmpDeviceDescriptionProvider { |
| 38 | private final Logger log = getLogger(getClass()); |
| 39 | protected static final IClassRegistry CLASS_REGISTRY = |
| 40 | new ClassRegistry(_OidRegistry.oidRegistry, I_Device.class); |
| 41 | private static final String UNKNOWN = "unknown"; |
| 42 | |
| 43 | @Override |
| 44 | public DeviceDescription populateDescription(ISnmpSession session, DeviceDescription description) { |
| 45 | NetworkDevice networkDevice = new NetworkDevice(CLASS_REGISTRY, |
| 46 | session.getAddress().getHostAddress()); |
| 47 | try { |
| 48 | session.walkDevice(networkDevice, Arrays.asList(new OID[]{ |
| 49 | CLASS_REGISTRY.getClassToOidMap().get( |
| 50 | com.btisystems.mibbler.mibs.bti7000.bti7000_13_2_0.mib_2.System.class)})); |
| 51 | |
| 52 | 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) |
| 54 | networkDevice.getRootObject().getEntity(CLASS_REGISTRY.getClassToOidMap().get( |
| 55 | com.btisystems.mibbler.mibs.bti7000.bti7000_13_2_0.mib_2.System.class)); |
| 56 | if (systemTree != null) { |
| 57 | String[] systemComponents = systemTree.getSysDescr().split(";"); |
| 58 | return new DefaultDeviceDescription(description.deviceUri(), description.type(), |
| 59 | systemComponents[0], systemComponents[2], systemComponents[3], |
Marc De Leenheer | c662d32 | 2016-02-18 16:05:10 -0800 | [diff] [blame] | 60 | UNKNOWN, description.chassisId(), description.annotations()); |
kmcpeake | b172d5f | 2015-12-10 11:30:43 +0000 | [diff] [blame] | 61 | } |
| 62 | } catch (IOException ex) { |
| 63 | log.error("Error reading details for device {}.", session.getAddress(), ex); |
| 64 | } |
| 65 | return description; |
| 66 | } |
| 67 | |
| 68 | } |